TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
from sys import stdin
input = stdin.readline

S = input()
n = len(S)

tot = 0

for i in range(2**(n-1)):
  f = S[0]
  for j in range(n-1):
       if ((i >> j) & 1):
        f += " "
       f += S[j+1]
  
  tot += sum(map(int, f.split(" ")))

print(tot)

S = input()
n = len(S)

tot = 0

for i in range(2**(n-1)):
  f = S[0]
  for j in range(n-1):
       if ((i >> j) & 1):
        f += " "
       f += S[j+1]
  
  tot += sum(map(int, f.split(" ")))

print(tot)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)             

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def search(i,s):
	if i == n-1:
		li = []
		s = "".join(s)
		li = list(map(int,s.split("+")))
		total.append(sum(li))
		return

	else:
		search(i+1,s)

		_s = s[:-(n-i)+1] + ["+"] + s[-(n-i)+1:]
		search(i+1,_s)

search(0,s)
print(sum(total))

s = list(input())
total = []
n = len(s)

def search(i,s):
	if i == n-1:
		li = []
		s = "".join(s)
		li = list(map(int,s.split("+")))
		total.append(sum(li))
		return

	else:
		search(i+1,s)

		_s = s[:-(n-i)+1] + ["+"] + s[-(n-i)+1:]
		search(i+1,_s)

search(0,s)
print(sum(total))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
# print(s)

score = 0
for blocksize in range(1,len(s)+1):
    for startpoint in range(len(s)):
        
        if startpoint+blocksize >= (len(s)+1): continue
        block = s[startpoint:startpoint+blocksize]
        ss = int(block) * math.factorial(startpoint) * math.factorial(len(s) - (startpoint+blocksize))
        
        score += ss
print(score)
exit()

def f(n):
    if n <= -1:
        return 1
    return 2**(n-1)

s = input()

score = 0
for blocksize in range(1,len(s)+1):
    for startpoint in range(len(s)):
        if startpoint+blocksize >= (len(s)+1): continue
        block = s[startpoint:startpoint+blocksize]   
        ss = int(block) * f(startpoint-1) * f(len(s) - (startpoint+blocksize))
        score += ss
print(score)
exit()


def f(n):
    if n <= 0:
        return 1
    return 2**(n-1)

s = input()

score = 0
for blocksize in range(1,len(s)+1):
    for startpoint in range(len(s)):
        if startpoint+blocksize >= (len(s)+1): continue
        block = s[startpoint:startpoint+blocksize]  
        ss = int(block) * f(startpoint) * f(len(s) - (startpoint+blocksize))
        
        score += ss
print(score)
exit()

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
sr = input()
n = len(sr)

blist = []
for i in range(2**(n-1)):
    blist.append(list(map(int,list(bin(i)[2::].zfill(n-1)))))
print(blist)

ssum = 0
for k,num in enumerate(blist):
    bi = 0
    bsum = 0
    print(num)
    for i,j in enumerate(num):
        if j == 1:
            bsum += int(sr[bi:i+1])
            bi = i+1
        if i == (len(num)-1):
            bsum += int(sr[bi:])
    ssum += bsum
print(ssum)

sr = input()
n = len(sr)

blist = []
for i in range(2**(n-1)):
    blist.append(list(map(int,list(bin(i)[2::].zfill(n-1)))))

ssum = 0
for k,num in enumerate(blist):
    bi = 0
    bsum = 0
    print(num)
    for i,j in enumerate(num):
        if j == 1:
            bsum += int(sr[bi:i+1])
            bi = i+1
        if i == (len(num)-1):
            bsum += int(sr[bi:])
    ssum += bsum
print(ssum)

sr = input()
n = len(sr)

blist = []
for i in range(2**(n-1)):
    blist.append(list(map(int,list(bin(i)[2::].zfill(n-1)))))

ssum = 0
for k,num in enumerate(blist):
    bi = 0
    bsum = 0
    for i,j in enumerate(num):
        if j == 1:
            bsum += int(sr[bi:i+1])
            bi = i+1
        if i == (len(num)-1):
            bsum += int(sr[bi:])
    ssum += bsum
print(ssum)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

s = input()
n = len(s) - 1
sum = 0

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

print(sum)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
print(l)
indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
    indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]
#print(indexes)
SUM=0
for j in range(2**(n-1)):
    L=len(indexes[j])
    if L==0:
        SUM+=int(s)
        #print(SUM)
    else:
        SUM+=int(s[:indexes[j][0]+1])
        #print(SUM)
        SUM+=int(s[indexes[j][L-1]+1:])
        #print(SUM)
        if L>1:
            for h in range(L-1):
                SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
                #print(SUM)
print(SUM)

s=input()
n=len(s)
l=[[] for _ in range(2**(n-1))]
for b in range(2**(n-1)):
    x=b
    for i in range(n-1):
        if x%2==1:
            l[b].append(1)
        else:
            l[b].append(0)
        x//=2
print(l)
indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
    indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]
#print(indexes)
SUM=0
for j in range(2**(n-1)):
    L=len(indexes[j])
    if L==0:
        SUM+=int(s)
        #print(SUM)
    else:
        SUM+=int(s[:indexes[j][0]+1])
        #print(SUM)
        SUM+=int(s[indexes[j][L-1]+1:])
        #print(SUM)
        if L>1:
            for h in range(L-1):
                SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
                #print(SUM)
print(SUM)

s=input()
n=len(s)
l=[[] for _ in range(2**(n-1))]
for b in range(2**(n-1)):
    x=b
    for i in range(n-1):
        if x%2==1:
            l[b].append(1)
        else:
            l[b].append(0)
        x//=2
#print(l)
indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
    indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]
#print(indexes)
SUM=0
for j in range(2**(n-1)):
    L=len(indexes[j])
    if L==0:
        SUM+=int(s)
        #print(SUM)
    else:
        SUM+=int(s[:indexes[j][0]+1])
        #print(SUM)
        SUM+=int(s[indexes[j][L-1]+1:])
        #print(SUM)
        if L>1:
            for h in range(L-1):
                SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
                #print(SUM)
print(SUM)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
dp=["","+"]
s=input()
su=0
for i in range(2**(len(s)-1)):
    val=""
    for j in range(len(s)-1):
        val+=s[j]
        val+=dp[int(bin(i)[j+2])]
    val+=s[len(s)-1]
    su+=eval(val)
print(su)


dp=["","+"]
s=input()
su=0
for i in range(2**(len(s)-1)):
    val=""
    for j in range(len(s)-1):
        val+=s[j]+dp[bin(i)[j+2]]
    val+=s[len(s)-1]
    su+=eval(val)
print(su)

dp=["","+"]
s=input()
su=0
for i in range(2**(len(s)-1)):
    val=""
    for j in range(len(s)-1):
        val+=s[j]
        val+=dp[bin(i)[j+2]]
    val+=s[len(s)-1]
    su+=eval(val)
print(su)

dp=["","+"]
s=input()
su=0
for i in range(2**(len(s)-1)):
    val=""
    b=bin(i)[2:].zfill(len(s)-1)
    for j in range(len(s)-1):
        val+=s[j]+dp[int(b[j])]
    val+=s[len(s)-1]
    su+=eval(val)
print(su)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
s=list(map(int,list(input())))
n=len(s)
ans=0
for i in range(1<<(n-1)):

    S=s[0]
    for j in range(n-1):
        if i & (1<<j): 
            S+="+"+s[j+1]
        else: 
            S+=s[j+1]
    ans+=eval(S)
print(ans)

s=list(input())
n=len(s)
ans=0
for i in range(1<<(n-1)):

    

    S=s[0]
    for j in range(n-1):
        if i & (1<<j): 
            S+="+"+s[j+1]
        else: 
            S+=s[j+1]
    ans+=eval(S)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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):  
            eidx = item[j]
            count += int(s[sidx:eidx])
            sidx = eidx
    count += int(s[sidx:])
print(count)

import numpy as np
s = input()

n = len(s)
iters = 2 ** (n - 1)
count = 0
for i in range(iters):
    buf = s[0]
    for j in range(n - 1):
        if i & (2**j):
            count += int(buf)
            buf = s[j + 1]
        else:
            buf += s[j + 1]
    count += int(buf)
print(count)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
s=input()

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

s=input()

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
ans = 0
memo = []
for i in range(1 << len(s) -1):
    print(bin(i))
    tmp = s[0]
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            tmp+="+"
        tmp += s[j+1]
    if tmp not in memo:
        ans+=eval(tmp)
        memo.append(tmp)
print(ans)

s = input()
ans = 0
memo = []
for i in range(1 << len(s) -1):
    tmp = s[0]
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            tmp+="+"
        tmp += s[j+1]
    if tmp not in memo:
        ans+=eval(tmp)
        memo.append(tmp)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = str(input())
p = ["+",""]
total = 0

for i in range(2**(len(S)-1)):
    t = S[0]
    for j in range(len(S)-1):
        t = t + p[i>>j&1] + S[j+1]
    print(t)
    total += eval(t)
print(total)

S = str(input())
p = ["+",""]
total = 0

for i in range(2**(len(S)-1)):
    t = S[0]
    for j in range(len(S)-1):
        t = t + p[i>>j&1] + S[j+1]
    total += eval(t)
print(total)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = input()
n = len(S)
res = 0
for i in range(1 << n-1):
    subres = 0
    subst = S[0]
    for j in range(n-1):
        if i >> j & 1:
            subres += int(subst)
            subst = S[j+1]
        else:
            subst += S[j+1]
        if j == n - 2:
            subres += int(subst)
        print(bin(i),j,subst,subres)
    res += subres
print(res)




S = input()
n = len(S)
res = 0
for i in range(1 << n-1):
    subres = 0
    subst = S[0]
    for j in range(n-1):
        if i >> j & 1:
            subres += int(subst)
            subst = S[j+1]
        else:
            subst += S[j+1]
        if j == n - 2:
            subres += int(subst)
    res += subres
if n == 1:
    print(int(S))
else:
    print(res)




Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

def all_comb(n):
    comb = []
    for i in range(0, n+1):
        comb.extend(list(itertools.combinations(range(n), i)))
    return comb

if __name__=='__main__':
    str = input()
    comb = all_comb(len(str)-1)
    tail = 0
    sum = 0
    for plus_positions in comb:
        head = 0
        for plus_position in plus_positions:
            num = int(str[head:plus_position+1])
            sum += num
            head = plus_position + 1
        num = int(str[head:])
	sum += num
    print(sum)


#!/usr/bin/python3                                                                                                                                                                                          

import itertools

def all_comb(n):
    comb = []
    for i in range(0, n+1):
        comb.extend(list(itertools.combinations(range(n), i)))
    return comb

if __name__=='__main__':
    str = input()
    comb = all_comb(len(str)-1)
    tail = 0
    sum = 0
    for plus_positions in comb:
        head = 0
        for plus_position in plus_positions:
            num = int(str[head:plus_position+1])
            sum += num
            head = plus_position + 1
        num = int(str[head:])
        sum += num
    print(sum)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def dfs(i, sum):
    if i == len(s) - 1:
        return sum(list(map(int,sum.split("+"))))

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

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

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]))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

import itertools
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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
H, W, N = map(int, input().split())
mat = [[0]*W for _ in range(H)]

for _ in range(N):
    a, b = map(int, input().split())
    mat[a-1][b-1] = 1


dp = [[0]*W for _ in range(H)]
for h in range(H):
    cnt = 0
    if mat[h][0] == 1:
        dp[h][0] = 1
    for w in range(1, W):
        if mat[h][w] == 1:
            dp[h][w] += 1
        dp[h][w] += dp[h][w-1]


ans = [0]*10
for i in range(10):
    tmp = 0
    for h in range(H-3):
        for w in range(W-3):
            s = 0
            for k in range(3):
                s += dp[h+k][w+2]-dp[h+k][w]
            if s == i:
                tmp += 1
    ans[i] = tmp

for i in ans:
    print(i)


s = input()
nums = [int(v) for v in s]

l = len(s)

ans = 0
for i in range(1 << (l-1)):
    tmp = s[0]
    for j in range(l-1):
        if i & 1 << j:
            tmp += '+'+s[j+1]
        else:
            tmp += s[j+1]
    ans += eval(tmp)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#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)
    


#coding:utf-8
S=str(input())
n=len(S)-1
answer=0
for i in range(2**(n)):
  formula=S[0]
  for j in range(n):
    if ((i>>j)&1):
      formula+="+"
    formula+=S[j+1]
  answer+=sum(map(int,formula.split("+")))
print(answer)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):

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]))


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]))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
op = ['','+']
if len(s) == 1:
    print(s)
else:
    s = s + 'X'*(10 -len(s))
    ans = []
    for a in op:
        for b in op:
            for c in op:
                for d in op:
                    for e in op:
                        for f in op:
                            for g in op:
                                for h in op:
                                    for i in op:
                                        　　　ans.append(s[0]+a+s[1]+b+s[2]+c+s[3]+d+s[4]+e+s[5]+f+s[6]+g+s[7]+h+s[8]+i+s[9])
    for i in range(len(ans)):
        for j in range(len(ans[i])):
            if ans[i][j] == 'X':
                if ans[i][j-1] == '+':
                    ans[i] = ans[i][:j-1]
                else:
                    ans[i] = ans[i][:j]
                break
    sums = 0
    for i in set(ans):
        sums += eval(i)
    print(sums)


s = input()
op_cnt = len(s) - 1
ans = []
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] = '+'
    f = s[0]
    for p, q in zip(op, s[1:]):
        f += p + q
    ans.append(f)
sums = 0
for i in ans:
    sums += eval(i)
print(sums)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


import sys
input = sys.stdin.readline
s = input().strip()
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)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import itertools

def solve(S):
    
    count = 0
    bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
    for pattern in bit_list:
            
        start = 0
        for end in range(len(pattern)):
            if pattern[end] == 1:
                count += int(S[start:end+1])
                start = end + 1
                
            if end == len(bit) - 1:
                count += int(S[start:])
                
    print(count)


if __name__ == '__main__':
    S = input()
    solve(S)

import itertools

def solve(S):
    
    
    if len(S) == 1:
        print(int(S))
    else:
        count = 0
        bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
        for pattern in bit_list:
            
            start = 0
            for end in range(len(pattern)):
                if pattern[end] == 1:
                    count += int(S[start:end+1])
                    start = end + 1
    
            count += int(S[start:])

        print(count)


if __name__ == '__main__':
    S = input()
    solve(S)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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))


S = input()

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

res = []

dfs(res, 0, 0, S)
print(sum(res))


from functools import reduce
S = input()

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

res = []

dfs(res, 0, [], S)

print(sum(int(num) for nums in res for num in nums))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#include <stdio.h>
#include <stdlib.h>

#include <iomanip>

#include <string.h>
#include <string>
#include <map>
#include <stack>

#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	string S;
	cin >> S;

	ll ans = 0;

	ll size = S.length();
	
	vll N(size);
	
	for (ll i = 0; i < size; i++) {
		N[i] = ll(S[i]) - 48;
	}

	ll time = 0;

	for (ll bit = 0; bit < (1<<size-1) ; bit++) {

		ll local = 0;
		for (ll i = 0; i < size-1; i++) {

			local *= 10;
			local += N[i];

			if ((bit >> (size - 2 - i)) & 1) {
				ans += local;
				local = 0;

				if (i == size - 2) {

					ans += local + N[i + 1];
					local = 0;
				}
			}
			else {
				if (i == size - 2) {
					local *= 10;
					ans += local + N[i + 1];
					local = 0;
				}
			}



		}
		time++;
	}

	if (size == 1) {
		cout << S;
		return 0;
	}

	cout << ans << endl;





}



import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18





S = input()

S = S[::-1]



ans = int(S[0]) * (2**(len(S)-1))
for i in range(1, len(S)):
    final = 0    
    for keta in range(0, i+1):
        if keta == i:
            final = 1
        ans += int(S[i]) * (10**keta) * (2**int(len(S)-2-keta+final))
        #print(S[i], keta, int(S[i]) * (10**keta) * (2**int(len(S)-2-keta+final)))
print(ans)







Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np

N, M = map(int, input().split())
routes = np.array([list(map(int, input().split())) for _ in range(M)], 'i')
#print(routes)


dp = [{} for _ in range(N + 1)]
dp[1][0] = 0

for i in range(2, N + 1):
    for (f, t, m) in routes:
        if t != i:
            continue

        if m in dp[f]:
            dp[t][m] = dp[f][m]
        else:
            values = []
            for k, v in dp[f].items():
                if k != m: values.append(v)
            if len(values) > 0:
                dp[t][m] = min(values) + 1

if len(dp[N].values()) > 0:
    print(min(dp[N].values()))
else:
    print(-1)

import numpy as np

def many_fomulas(digits):
    mat = np.zeros((len(digits), len(digits)), 'i')

    for i, _ in enumerate(digits):
        if i >= 0:
            mat[i, :i] = 2 ** (i - 1)
        mat[i, i] = 2 ** i

    total = 0
    for i, _ in enumerate(digits):
        for j, v in enumerate(digits):
            total += 10 ** (len(digits) - i - 1) * int(mat[i, j]) * v

    print(total)

#many_fomulas([1, 2, 5])
#many_fomulas([9, 9, 9, 9, 9, 9, 9, 9, 9, 9])
many_fomulas([int(d) for d in input()])


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!

s = input()
sList = list(s)
sList = [int(i) for i in s]
sCount = len(sList)
#print(sCount)

aaa = 0

for i in range(2**(sCount-1)):

    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(sCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    
    for i in range(sCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+'
    
    #print(sList)
    #print(binaryNumber)
    
    result = [None]*(len(sList)+len(binaryNumber))
    result[::2] = sList
    result[1::2] = binaryNumber
    
    while 0 in result:
        result.remove(0)
    
    #print(result)    
    result = map(str, result)
    resultStr = ''.join(result)
    
    aaa = aaa + eval(resultStr)
    
    print(aaa)
        
    
    
    

# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!

s = input()
sList = list(s)
sList = [int(i) for i in s]
sCount = len(sList)
#print(sCount)

aaa = 0

for i in range(2**(sCount-1)):

    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(sCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    
    for i in range(sCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+'
    
    #print(sList)
    #print(binaryNumber)
    
    result = [None]*(len(sList)+len(binaryNumber))
    result[::2] = sList
    result[1::2] = binaryNumber
    
    while 0 in result:
        result.remove(0)
    
    #print(result)    
    result = map(str, result)
    resultStr = ''.join(result)
    
    aaa = aaa + eval(resultStr)
    
print(aaa)
        
    
    
    

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    eval = ''
    for j in range(l):
        if ((i >> j) & 1):
            eval += s[j] + '+'
        else:
            eval += s[j]
    ans += eval(eval)

s = input()
ans = 0
for i in range(s):
  ans += int(s[0:i]) + int(s[i:len(s)])
ans += int(s)
print(ans)

s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j]
    ans += eval(e)
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = input()

def dfs(res, depth, path, S):
    res[0] += int(path)
    for i in range(depth + 1, len(S) + 1):
        dfs(res, i, S[depth:i], S)

res = [0]

dfs(res, 0, 0, S)
print(res[0])


S = input()

def dfs(start, S, curSum, res):
	if start >= len(S):
		res[0] += curSum
		return

    # put a plus on each space until last
	for i in range(start+1, len(S) + 1):
		dfs(i, S, curSum+int(S[start:i]), res)

	
res = [0]

dfs(0, S, 0, res)
print(res[0])

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def insert_string_to_base(target_string, insert_point, insert_string):
    return target_string[:insert_point] + insert_string + target_string[insert_point:]

def main():
    N = str(input())
    l = len(N)-1

    result = 0
    for i in range(2 ** l):
        count = 1
        st = N
        for j in range(l):
            if ((i >> j) & 1):
                st = insert_string_to_base(st, j+count, "+")
                count+=1

        print(st)
        for v in st.split("+"):
            if(v != ''):
                result += int(v)
    print(result)


if __name__ == "__main__":
    main()



def insert_string_to_base(target_string, insert_point, insert_string):
    return target_string[:insert_point] + insert_string + target_string[insert_point:]

def main():
    N = str(input())
    l = len(N)-1

    result = 0
    for i in range(2 ** l):
        count = 1
        st = N
        for j in range(l):
            if ((i >> j) & 1):
                st = insert_string_to_base(st, j+count, "+")
                count+=1

        for v in st.split("+"):
            if(v != ''):
                result += int(v)
    print(result)


if __name__ == "__main__":
    main()



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import product
H, W, N = list(map(int, input().split()))
A = [tuple(map(int, input().split())) for _ in range(N)]
count = {}
for x, y in A:
    for xx, yy in product(range(x-1, x+2), range(y-1, y+2)):
        if not(2 <= xx <= H-1 and 2 <= yy <= W-1):
            continue
        count[(xx, yy)] = count.get((xx, yy), 0) + 1
ans = [0] * 10
for k, v in count.items():
    ans[v] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep="\n")


from itertools import product

S = tuple(input())
N = len(S)
res = 0
for ops in product(["+", ""], repeat=N-1):
    exp = "".join([n + op for n, op in zip(S, ops+("",))]).strip("+")
    res += eval(exp)
print(res)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = input()
ans=0
for i in range(1<<len(S)):
    f =S[0]
    for j in range(len(S)-1):
        if i &(1<<j):
            f +="+"
        f +=S[j+1]
    ans += sum(map(int, f.split("+")))
print(ans)


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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import copy

def main():
    sum=0
    S = list(map(str, input()))
    hoge = tmp = []
    print(S)

    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] = "+"

        print(i,op)

        S_tmp = copy.deepcopy(S)
        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])
        print("".join(S_tmp))
        sum+=(eval("".join(S_tmp)))
        print(sum)
    print(sum)

main()

import sys
import copy

def main():
    sum=0
    S = list(map(str, input()))
    hoge = tmp = []

    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] = "+"

        S_tmp = copy.deepcopy(S)
        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])
        sum+=(eval("".join(S_tmp)))
    print(sum)

main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

S = input()

N = len(S)-1
sum = 0

for i in range(2**N):

    op = [""]*(N)
    for j in range(N):
        if (i>>j)&1:
            op[j] = "+"
    s = ""
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[j]
    sum = sum + eval(s)
print(sum)

import sys

S = input()

N = len(S)-1
sum = 0

for i in range(2**N):

    op = [""]*(N)
    for j in range(N):
        if (i>>j)&1:
            op[j] = "+"
    s = ""
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[len(S)-1]
    sum = sum + eval(s)
print(sum)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
S = input()

def saiki(n, s=S[0]):
    _sum = 0
    
    if n==len(S)-1:
        print(s)
        return eval(s)
    
    _sum += saiki(n+1, s + "+" + S[n+1])
    _sum += saiki(n+1, s + S[n+1])
    
    return _sum
    
print(saiki(0))

S = input()

def saiki(n, s=S[0]):
    _sum = 0
    
    if n==len(S)-1:
#         print(s)
        return eval(s)
    
    _sum += saiki(n+1, s + "+" + S[n+1])
    _sum += saiki(n+1, s + S[n+1])
    
    return _sum
    
print(saiki(0))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
S = list(input())
N = len(S)
List = []
for i in range(2**(N-1)):
    tmp = ''
    for j in range(N-1):
        if ((i>>j) & 1):
            tmp += '1'
        else:
            tmp += '0'
    List.append(list(tmp))
ans = 0
for i in range(len(List)):
    start = 0
    tmp = ''
    for j in range(len(List[i])):
        if List[i][j] == '0':
            tmp += S[j]
        if List[i][j] == '1':
            tmp += S[j]
            ans += int(tmp)
            tmp = ''
    tmp += S[-1]
    ans += int(tmp)
print(ans)

            
print(ans)


S = list(input())
N = len(S)
List = []
for i in range(2**(N-1)):
    tmp = ''
    for j in range(N-1):
        if ((i>>j) & 1):
            tmp += '1'
        else:
            tmp += '0'
    List.append(list(tmp))
ans = 0
for i in range(len(List)):
    start = 0
    tmp = ''
    for j in range(len(List[i])):
        if List[i][j] == '0':
            tmp += S[j]
        if List[i][j] == '1':
            tmp += S[j]
            ans += int(tmp)
            tmp = ''
    tmp += S[-1]
    ans += int(tmp)

            
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque
S=input()
queue=deque()
lst=[]
lst.append([0,0])
for i in range(0,len(S)):
    l=len(lst)
    for _ in range(l):
        x,y=lst.pop(0)
        lst.append([x,y*10+int(S[i])])
        lst.append([x+y*10+int(S[i]),0])
l=len(lst)
for _ in range(l):
    x,y=lst.pop(0)
    lst.append(x+y)
print(sum(lst)/2)


from collections import deque
S=input()
queue=deque()
lst=[]
lst.append([0,0])
for i in range(0,len(S)):
    l=len(lst)
    for _ in range(l):
        x,y=lst.pop(0)
        lst.append([x,y*10+int(S[i])])
        lst.append([x+y*10+int(S[i]),0])
l=len(lst)
for _ in range(l):
    x,y=lst.pop(0)
    lst.append(x+y)
print(int(sum(lst)/2))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)
               

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)

Verdicts: Runtime Error

Accepted