Problem:


Score : 300 points

Problem Statement

Sitting in a station waiting room, Joisino is gazing at her train ticket.

The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).

In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.

The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Constraints

0≤A,B,C,D≤9

All input values are integers.

It is guaranteed that there is a solution.

Input

Input is given from Standard Input in the following format:

ABCD

Output

Print the formula you made, including the part =7.

Use the signs + and -.

Do not print a space between a digit and a sign.

Sample Input 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

0 - 2 + 9 - 0 = 7 is also a valid solution.

Sample Input 3

3242

Sample Output 3

3+2+4-2=7



Sample input:
1222


Sample output:
1+2+2+2=7

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 05:10:26 2020

@author: naoki
"""
import sys

N = input() # ABCDを入力
list2 = list(N) # リストに変換

A = int(list2[0])
B = int(list2[1])
C = int(list2[2])
D = int(list2[3])

op = [[1,1,1],[1,1,-1],[1,-1.1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
ans = ["0","0","0"]
       
for i in range(8):
    if A + op[i][0] * B + op[i][1] * C + op[i][2] * D == 7:
            for j in range(3):
                if op[i][j] == 1:
                    ans[j] = "+"
                else:
                    ans[j] = "-"
            print(str(A) + ans[0] + str(B) + ans[1] + str(C) + ans[2] + str(D) + "=7")
            sys.exit()

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input())
if A+B+C+D==7:
    a = "+"
    b = "+"
    c = "+"
elif A+B+C-D==7:
    a = "+"
    b = "+"
    c = "-"
elif A+B-C+D==7:
    a = "+"
    b = "-"
    c = "+"
elif A+B-C-D==7:
    a = "+"
    b = "-"
    c = "-"
elif A-B+C+D==7:
    a = "-"
    b = "+"
    c = "+"
elif A-B+C-D==7:
    a = "-"
    b = "+"
    c = "-"
elif A-B-C+D==7:
    a = "-"
    b = "-"
    c = "+"
elif A-B-C-D==7:
    a = "-"
    b = "-"
    c = "-"

print(f"{A}{a}{B}{b}{C}{c}{D}=7")

Submission status: Runtime Error

Solution code:
    s = input()
    for i in range(8):
        total = int(s[0])
        str = s[0]
        for j in range(1, 4):
            if i >> (j - 1) & 1:
                total += int(s[j])
                str += '+' + s[j]
            else:
                total -= int(s[j])
                str += '-' + s[j]
        if total == 7:
            print(str + '=7')
            exit()

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int,input().split())
if a+b+c+d==7:
    print("a+b+c+d=7")
elif a+b+c-d==7:
    print("a+b+c-d=7")
elif a+b-c+d==7:
    print("a+b-c+d=7")
elif a-b+c+d==7:
    print("a-b+c+d=7")
elif a+b-c-d==7:
    print("a+b-c-d=7")
elif a-b-c-d==7:
    print("a-b-c-d=7")
elif a-b+c-d==7:
    print("a-b+c-d=7")
elif a-b-c+d==7:
    print("a-b-c+d=7")

Submission status: Runtime Error

Solution code:
n = input()
l = []
for i in range(len(n)):
    l += int(n[i])
print(sum(l))

Submission status: Runtime Error

Solution code:
s = input()

for bit in range(1 << (3)):
    f = s[0]
    
    for i in range(3):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += s[i + 1]
    if sum(list(map(int, f.split('+')))) == 7:
        print(f"{f}=7")
        exit()

Submission status: Runtime Error

Solution code:
s = input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

if A+B+C+D == 7:
	print("{0}+{1}+{2}+{3}=7".format(A,B,C,D))
elif A+B+C-D == 7:
	print("{0}+{1}+{2}-{3}=7".format(A,B,C,D))
elif A+B-C-D == 7:
	print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))
elif A+B-C+D == 7:
	print("{0}+{1}-{2}+{3}=7".format(A,B,C,D))
elif A-B+C+D == 7:
	print("{0}-{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B+C-D == 7:
	print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))
elif A-B-C-D == 7:
	print("{0}-{1}-{2}-{3}=7".format(A,B,C,D))
else A-B-C+D == 7:
	print("{0}-{1}-{2}+{3}=7".format(A,B,C,D))

Submission status: Runtime Error

Solution code:
x = int(input())
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")

Submission status: Runtime Error

Solution code:
x = int(input())
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d))
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d))
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d))
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d))
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d))
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d))
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d))
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d))

Submission status: Runtime Error

Solution code:
import copy
import numpy as np

s = input()
n = 3
ans = 0

for i in range(1,3 ** n):
    x = copy.deepcopy(s)
    y = str(np.base_repr(i,3)).rjust(3,'0') #3進数に変換
    if y[0] == "0" and s[0] == "0":
        continue
    z = 1
    for j in range(3):
        if y[j] == "1": #フラグが立っていたら
            x = x[:j+z] + "+" + x[j+z:]
            z += 1
        if y[j] == "2": #フラグが立っていたら
            x = x[:j+z] + "-" + x[j+z:]
            z += 1
    if eval(x) == 7:
        print(x +"=7")
        exit()

Submission status: Runtime Error

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split(''))
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

a = ns()
for i in range(2**3):
    ans = f'{a[-1]}'
    for j in range(3):
        if (i >> j) & 1:
            ans = a[-1-(j+1)] + '+' + ans
        else:
            ans = a[-1-(j+1)] + '-' + ans
    if eval(ans) == 7:
        print(ans+'=7')
        break

Submission status: Runtime Error

Solution code:
s = input()
n = len(s) - 1
for i in range(2**n):
    tmp = []
    for j in range(n):
        tmp.append(s[i])
        if i >> j & 1:
            tmp.append("+")
        else:
            tmp.append("-")
    tmp.append(s[-1])
    for k in tmp:
        if eval(k) == 7:
            print(k + "=7")

Submission status: Runtime Error

Solution code:
s = input()
n = len(s)
for i in range(2**(n-1)):
    op = ["-"] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            op[n - 2 -j] = "+"
    #print(op)
    chk = ""
    for p_n, p_o in zip(n-1, op + [""]):
        chk += (p_n + p_o)
    if eval(chk) == 7:
        print(chk + "=7")
        exit()

Submission status: Runtime Error

Solution code:
c,*s=input()
for b in range(1<<n):
    t = c + ""
    for i in range(n):
        t += ["-","+"][b>>i & 1] + s[i]
    if eval(t) == 7:
        print(t+"=7")
        exit()

Submission status: Runtime Error

Solution code:
n=int(input())
t=[int(input()) for i in range(n)]
#print(t)
ans=float("INF")
def dfs(i,pork,beaf):
    global ans
    if i==n-1:
        ans=min(ans,max(pork,beaf))


    else:
        dfs(i+1,pork+t[i+1],beaf)
        dfs(i+1,pork,beaf+t[i+1])
dfs(0,t[0],0)
print(ans)

Submission status: Runtime Error

Solution code:
n = input()

op_cnt = len(n) -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] = "+"
    
            
    formula = ""
    for p_n,p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(f'{formula}=7')
        break

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)
s=input()
def dfs(i,f,sum):
    if i==len(s)-1:
        if sum==7:
            print(f+"=7")
            exit()
    dfs(i+1,f+"+"+s[i+1],sum+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],sum-int(s[i+1]))
print(dfs(0,s[0],int(s[0])))

Submission status: Runtime Error

Solution code:
from math import ceil


def dfs(i, sum, count, residue):
    global ans
    if i == d:
        if sum < g:
            use = max(residue)
            n = min(pc[use - 1][0], ceil((g - sum) / (use * 100)))
            count += n
            sum += n * use * 100

        if g <= sum:
            ans = min(ans, count)

    else:
        dfs(i + 1, sum, count, residue)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], residue - {i + 1})


d, g = map(int, input().split())

pc = [list(map(int, input().split())) for _ in range(d)]

ans = float('inf')

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

A, B, C, D = input()
for op1, op2, op3 in product("+-", repeat=3):
    expr = f"{A}{op1}{B}{op2}{C}{op3}{D}"
    if eval(expr) == 7:
        print(f"{A}{op1}{B}{op2}{C}{op3}{D}=7")
        break

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    abcd = list(map(int, list(readstr())))
    l = [['+', '+', '+'], ['+', '+', '-'], ['+', '-', '+'], ['+', '-', '-'], ['-', '+', '+'], ['-', '+', '-'], ['-', '-', '+'], ['-', '-', '-']]
    for ll in l:
        ans = abcd[0]
        for i, x in enumerate(ll):
            if x == '+':
                ans += abcd[i + 1]
            else:
                ans -= abcd[i + 1]
        if ans == 7:
            print(f'{abcd[0]}{ll[0]}{abcd[1]}{ll[1]}{abcd[2]}{ll[2]}{abcd[3]}=7')
            break


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
S = input()
def saiki(i,s=S[0]):
    if i == 3:
        if eval(s) == 7:
            print(str(s) + "=7")
            exit()
    saiki(i+1,s+"+"+S[i+1])
    saiki(i+1,s+"-"+S[i+1])

saiki(0)

Submission status: Runtime Error

Solution code:
ans = [''] * len(A)

for i in range(len(op)):
    sum = int(A[0])
    if op[i] == '+':
        sum += int(A[1])
        ans[0] = op[i]
    else:
        sum -= int(A[1])
        ans[0] = op[i]
    for j in range(len(op)):
        if op[j] == '+':
            sum += int(A[2])
            ans[1] = op[j]
        else:
            sum -= int(A[2])
            ans[1] = op[j]
        for k in range(len(op)):
            if op[k] == '+':
                sum += int(A[3])
                ans[2] = op[k]
            else:
                sum -= int(A[3])
                ans[2] = op[k]
            if sum == 7:
                print(A[0]+ans[0]+A[1]+ans[1]+A[2]+ans[2]+A[3]+'=7')
                exit()

Submission status: Runtime Error

Solution code:
def dfs(i, s, sum):
    if i == 3:
        if sum == 7:
            print(s + "=7")
            exit()
    dfs(i + 1, s + "+" + abcd[i + 1], sum + int(abcd[i + 1]))
    dfs(i + 1, s + "-" + abcd[i + 1], sum - int(abcd[i + 1]))
abcd = input()
dfs(0, abcd[0], int(abcd[0]))

Submission status: Runtime Error

Solution code:
def main():
    s = input()
    for i in range(1<<3):
        t = int(s[0])
        op = []
        for j in range(3):
            if 1 & (i>>j):
                t += int(s[j+1])
                op.append('+')
            else:
                t -= int(s[j+1])
                op.append('-')
        if t == 7:
            x = [f'{a}{b}' for a,b in zip(s, op)]
            print(f'{"".join(x)}{s[-1]}=7')
            break

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = [int(i) for i in input()]
op_cnt = len(n) - 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] = "+"

    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Runtime Error

Solution code:
 = list(input())
B = list(map(int, A))
for i in range(2**3):
  ans = B[0]
  for j in range(3):
    if ((i>>j) & 1):
      ans += B[j+1]
    else:
      ans -= B[j+1]
  if ans == 7:
    for k in range(3):
      print(B[k], end = "")
      if ((i>>k) & 1):
        print("+", end = "")
      else:
        print("-", end = "")
    print(B[3], end = "")
    print("=7")
    break

Submission status: Runtime Error

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

ans = 7

for bit in range(2**(n-1)):
    tmp = s[0]
    for i in range(n-1):
        if (1<<i)&bit:
            tmp += '+'
        else:
            total += '-'
        tmp += s[i+1]
    total = eval(tmp)
    if total == ans:
        print(tmp + '=7')
        sys.exit()

Submission status: Runtime Error

Solution code:
s = input()
length = 4 # fixed

for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  ans = 0
  f = s[0]  
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f+'=7')
    return

Submission status: Runtime Error

Solution code:

S=input()
num = len(S) - 1

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

    formula=""
    for l_num,l_m in zip(S,l+[""]):
        formula = l_num+l_m

    if eval(formula)==7:
        print(formula+'=7')
        break

Submission status: Runtime Error

Solution code:
def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            sys.exit()
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)
    
    # "+"を入れる場合
    ticket_sum(i+1, s[:pos]+"+"+s[pos:], num+int(s[pos]))
    # "-"を入れる場合
    ticket_sum(i+1, s[:pos]+"-"+s[pos:], num-int(s[pos]))

ticket_sum(1, S, int(S[0]))

Submission status: Runtime Error

Solution code:
S = input()

def ticket_sum(i, s, num, memo):
    if i == len(S):
        if num == 7:
            memo.append(s+"=7")
            return
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)
    
    # "+"を入れる場合
    ticket_sum(i+1, s[:pos]+"+"+s[pos:], num+int(s[pos]), memo)
    # "-"を入れる場合
    ticket_sum(i+1, s[:pos]+"-"+s[pos:], num-int(s[pos]), memo)

    return memo[0]
    
memo = []
print(ticket_sum(1, S, int(S[0]), memo))

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input().split())

for op1 in '+-':
    for op2 in '+-':
        for op3 in '+-':
            if eval(A+op1+B+op2+C+op3+D) == 7:
                print(A+op1+B+op2+C+op3+D+'=7')
                exit()

Submission status: Runtime Error

Solution code:
li = []
s = input()
li2 = []
for i in range(4):
  li.append(s[i])
n1 = 4
def func(n, t):
  if t < 0:
    return False
  elif n == 0:
    if t == 0:
      return True
    else:
      return False
  elif func(n-1, t+li[n-1]):
    li2.append('-')
    return True
  elif func(n-1, t-li[n-1]):
    li2.append('+')
    return True
  else:
    return False
if func(n1, 7):
  print(f'{li[0]}{li2[0]}{li[2]}{li2[1]}{li[3]}{li2[3]}{li[4]}=7')

Submission status: Runtime Error

Solution code:
n = input()

ans(0, int(n[0]), n[0])

def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
    else:      #return ではなぜかけない？
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]),
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

Submission status: Runtime Error

Solution code:
n = input()

print(ans(0, int(n[0]), n[0]))


def ans(i, j, k):
    if i == 3:
        if j == 7:
            return k + '=7'
    return ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]), ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

Submission status: Runtime Error

Solution code:
import numpy as np

s=list(map(int,input().split()))

s_array=np.array(s)

if np.sum(s_array)==7:
    Ans=['+'+str(i) for i in s]
    Ans[0]=str(s[0])
    print(''.join(Ans)+'=7')
    
else:
    for i in range(3):
        if np.sum(s_array)-2*s_array[i+1]==7:
            Ans=['+'+str(i) for i in s]
            Ans[0]=str(s[0])
            Ans[i+1]='-'+str(s[i+1])
            print(''.join(Ans)+'=7')
            break
            
        elif np.sum(s_array)-2*s_array[1]-2*s_array[2]==7:
            Ans=['+'+str(i) for i in s]
            Ans[0]=str(s[0])
            Ans[1]='-'+str(s[1])
            Ans[2]='-'+str(s[2])
            print(''.join(Ans)+'=7')
            break
            
        elif np.sum(s_array)-2*s_array[2]-2*s_array[3]==7:
            Ans=['+'+str(i) for i in s]
            Ans[0]=str(s[0])
            Ans[2]='-'+str(s[2])
            Ans[3]='-'+str(s[3])
            print(''.join(Ans)+'=7')
            break
        
        elif np.sum(s_array)-2*s_array[1]-2*s_array[3]==7:
            Ans=['+'+str(i) for i in s]
            Ans[0]=str(s[0])
            Ans[1]='-'+str(s[1])
            Ans[3]='-'+str(s[3])
            print(''.join(Ans)+'=7')
            break
            
        elif np.sum(s_array)-2*s_array[1]-2*s_array[2]-2*s_array[3]==7:
            Ans=['+'+str(i) for i in s]
            Ans[0]=str(s[0])
            Ans[1]='-'+str(s[1])
            Ans[2]='-'+str(s[2])
            Ans[3]='-'+str(s[3])
            print(''.join(Ans)+'=7')
            break

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())

for i in range(2**3):
  e=['+','+','+']
  for j in range(len(e)):
    if (i<<j)&1:
      e[j]='-'
  if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
    print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
	break

Submission status: Runtime Error

Solution code:
N = input()
n = [int(N[i]) for i in range(4)]  


def addd(lista,op):
    cnt = lista[0]


    tmp = [lista[0]]
    for i in range(len(op)):
        if op[i]==0:
            cnt+=lista[i+1]
            tmp.append("+")
            tmp.append(lista[i+1])
        else:
            cnt -=lista[i+1]
            tmp.append("-")
            tmp.append(lista[i+1])
    if cnt ==7:
        tmp.append("=7")
        return tmp
    else:
        False

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = addd(n,[i,j,k])
            if ans != False:
                print("".join([str(n) for n in ans]))
                exit()

Submission status: Runtime Error

Solution code:
ABCD=input()
L=list(ABCD)

def bfs(i,j,a,c):#i,hidari,migi
  if i==3:
    if j+int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"+"+L[3]+"=7"]
    elif j-int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"-"+L[3]+"=7"]
    return 
    
  else:
    bfs(i+1,j+int(L[i]),a+"+",c)
    bfs(i+1,j-int(L[i]),a+"-",c)
    return c[0]
  


print(bfs(1,int(L[0]),"",[]))

Submission status: Runtime Error

Solution code:
=list(input())
#sのi番目の次に＋かーを入れる。それまでの文字列char,合計sum
def dfs(i,char,sum):
  if i==3:
    if sum==7:
      print(char+"=7")
      exit()
  else:
    dfs(i+1,char+"+"+s[i+1],sum+int(s[i+1]))  
    dfs(i+1,char+"-"+s[i+1],sum-int(s[i+1]))
        
    
      
    
      
dfs(0,s[0],int(s[0]))

Submission status: Runtime Error

Solution code:
s=list(int(input()))
#sのi番目までの合計をsumとする
def dfs(i,sum):
  if i==4:
    return sum==7
  if dfs(i+1,sum+s[i]):
    return True
  if dfs(i+1,sum-s[i]):
    return True
  else:
    return False
if dfs(0,s[0]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = str(input())

length = 4 #nの長さ
spaces = length -1

masterlist = []
opelist = ["+"] * spaces

for i in range(2 ** spaces):
    opelist = ["+"] * spaces

    for j in range(spaces):
        if i >> j & 1:
            opelist[j] = "-"
        else:
            opelist[j] = "+"

    masterlist.append(opelist)

for opes in masterlist:
    nls = list(n)
    for k in range(len(opes)):
        nls.insert(2*k+1,opes[k])
        #print(nls)
    nstr = ''.join(nls)
    if eval(nstr) == 7:
        print(f"{nstr}=7")
        exit()

Submission status: Runtime Error

Solution code:
n = str(input())

length = 4 #nの長さ
spaces = length -1

masterlist = []
opelist = ["+"] * spaces

for i in range(2 ** spaces):
    opelist = ["+"] * spaces

    for j in range(spaces):
        if j >> j & 1:
            opelist[j] = "-"
        else:
            opelist[j] = "+"

    masterlist.append(opelist)

for opes in masterlist:
    nls = list(n)
    for k in range(len(opes)):
        nls.insert(2*k+1,opes[k])
        #print(nls)
    nstr = ''.join(nls)
    if eval(nstr) == 7:
        print(f"{nstr}=7")
        exit()

Submission status: Runtime Error

Solution code:
def ope(i, ans, ans_str):
    if i == 3:
        if ans == 7:
            print(ans_str)
    else:
        ope(i+1, ans+int(S[i+1]), ans_str + "+" + S[i+1])
        ope(i+1, ans-int(S[i+1]), ans_str + "-" + S[i+1])
S = list(input())
ope(0,int(S[0]),S[0])+"=7"

Submission status: Runtime Error

Solution code:
n = int(input())
op_cnt = len(n)-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] = "+" #フラブが立っている箇所を"+"へ
      
  formula = "" 
  for p_n,p_o in zip(n,op+[""]):
    formula += (p_n+p_o)
  if eval(formula) == 7:
    print(formula+ "=7")
    break

Submission status: Runtime Error

Solution code:
n = int(input())
op_cnu = len(n)-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] = "+" #フラブが立っている箇所を"+"へ
      
  formula = "" 
  for p_n,p_o in zip(n,op+[""]):
    formula += (p_n+p_o)
  if eval(formula) == 7:
    print(formula+ "=7")
    break

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = readline()
S = list(N)
bnk = len(N)-1
for i in range(2**bnk):
    op = ["-","-","-"]
    for j in range(bnk):
        if ((i>>j)&1):
            op[bnk-j-1] = "+"
    tmp = ""
    for k in range(bnk):
        tmp += S[k]+op[k]
    tmp = tmp+S[3]
    if eval(tmp)==7:
        print(tmp+"=7")
        exit()

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            ans = a
            if op1 == '+':
                ans += b
            else:
                ans -= b
            if op2 == '+':
                ans += c
            else:
                ans -= c
            if op3 == '+':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + '=7')
                exit()

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            ans = a
            if op1 == '+':
                ans += b
            else:
                ans -= b
            if op2 == '+':
                ans += c
            else:
                ans -= c
            if op3 == '+':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d))
                exit()

Submission status: Runtime Error

Solution code:
s= input()
def dfs(i,f,sum):
    if i==3:
        if sum ==7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1,f+"-"+s[i+1],sum-int(s[i+1]))
        dfs(i+1,f+"+"+s[i+1],sum+int(s[i+1]))
dfs(0,s[0],int(s[0])

Submission status: Runtime Error

Solution code:
N=list(input())
a,b,c,d=N[0],N[1],N[2],N[3]

if a+b+c+d==7 : print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
if a+b+c-d==7 : print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
if a+b-c+d==7 : print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
if a+b-c-d==7 : print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
if a-b+c+d==7 : print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
if a-b+c-d==7 : print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
if a-b-c+d==7 : print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
if a-b-c-d==7 : print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))

Submission status: Runtime Error

Solution code:
s=input()
op=[0]*3
for i in range(2):
    a=calc(s[0],s[1],i)
    for j in range(2):
        b=calc(a,s[2],j)
        for k in range(2):
            c=calc(b,s[3],k)
            if c==7:
                ret=[i,j,k]               
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")

Submission status: Runtime Error

Solution code:
def calc(a,b,f):
    if f==0:
        return a+b
    else:
        return a-b
s=input()
op=[0]*3
for i in range(2):
    tmp=calc(int(s[0]),int(s[1]),i)
    for j in range(2):
        tmp=calc(tmp,int(s[2]),j)
        for k in range(2):
            tmp=calc(tmp,int(s[3]),k)
            if tmp==7:
                ret=[i,j,k]
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")

Submission status: Runtime Error

Solution code:
s = input()
a, b, c, d = int(s[0]), int(s[1]), int(s[2]), int(s[3])
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'-str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'-str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'-str(d)+'=7')

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'-str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'-str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'-str(d)+'=7')

Submission status: Runtime Error

Solution code:
def dfs(i,Str,res):
    if i==num-1:
        if res==7:
            print(Str+"=7")
            exit()
        return
    dfs(i+1,Str+"+"+S[i+1],res+int(S[i+1]))
    dfs(i+1,Str+"-"+S[i+1],res-int(S[i+1]))    

S=input()
num=len(n)
dfs(0,S[0],int(S[0]))

Submission status: Runtime Error

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

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

    formula=""
    for l_num, l_m in zip(n,l+[""]):
        formula += l_num + l_m
    
    if eval(formula)==7:
        print(formula"=7")
        break

Submission status: Runtime Error

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

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

    formula=""
    for l_num, l_m in zip(n,l+""):
        formula += l_num + l_m
    
    if eval(formula)==7:
        print(formula"=7")
        break

Submission status: Runtime Error

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

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

    formula=""
    for l_num, l_m in zip(n,l+""):
        formula += l_num + l_m
    
    if eval(formula)==7
        print(formula"=7")
        break

Submission status: Runtime Error

Solution code:
n = input()

def dfs(i, f, s):
    if i == 3:
        if s==7:
            return f+"=7"
    return dfs(i+1, f+"+"+n[i+1], s+int(n[i+1])) or dfs(i+1, f+"-"+n[i+1], s-int(n[i+1]))

print(dfs(0, n[0], int(n[0])))

Submission status: Runtime Error

Solution code:
def dfs(i,s,res):
    if i==3:
        if res == 7:
            print(s+"=7")
          	exit()
        return
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
dfs(0,S[0],int(S[0]))

Submission status: Runtime Error

Solution code:
def dfs(i,s,res):
    if i==3:
        if res == 7:
            return s
        elif:
            exit()
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
print(dfs(0,S[0],int(S[0]))+"=7")

Submission status: Runtime Error

Solution code:
def dfs(i,s,res):
    if i==3:
        if res == 7:
            print(s+"=7")
     		return
          	exit()
         
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
dfs(0,S[0],int(S[0]))

Submission status: Runtime Error

Solution code:
def dfs(i,s,res):
    if i==3:
        if res == 7:
            return s
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
print(dfs(0,S[0],int(S[0]))+"=7")

Submission status: Runtime Error

Solution code:
def dfs(i,s,res):
    if i==2:
        if res == 7:
            return s
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
print(dfs(0,S[0],int(S[0]))+"=7")

Submission status: Runtime Error

Solution code:
def dfs(i,s,res):
    if i==2:
        if res == 7:
            return s
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))

S=input()
print(dfs(0,S[0],int(S[0])))

Submission status: Runtime Error

Solution code:
n = [int(x) for x in input()]
op_cnt = len(n) - 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] = "+"

    formula=""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)

    if eval(formula)==7:
        print(formula+"=7")
        break

Submission status: Runtime Error

Solution code:
import sys

a, b, c, d = input()

for i in range(2**3):
    op = ['','','']
    for j in range(3):
        if (i >> j) & 1:
            op[j] = '+'
        else:
            op[j] = '-'
        if eval(a + op[0] + b + op[1] + c + op[2] + d) == 7:
            print(a + op[0] + b + op[1] + c + op[2] + d + "=7")
            sys.exit()

Submission status: Runtime Error

Solution code:
import sys

a, b, c, d = input()

for i in range(2**3):
    op = ['','','']
    for j in range(len(3)):
        if (i >> j) & 1:
            op[j] = '+'
        else:
            op[j] = '-'
        if eval(a + op[0] + b + op[1] + c + op[2] + d) == 7:
            print(a + op[0] + b + op[1] + c + op[2] + d + "=7")
            sys.exit()