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

Solution (Python):
s=input()
A, B, C, D = [int(s_) for s_ in s]

for ii in range(8):
    first  = ii >> 0 & 1
    second = ii >> 1 & 1
    third  = ii >> 2 & 1
    sum = A
    if first == 0:
        sum -= B
        first_op = '-'
    else:
        sum += B
        first_op = '+'
    if second == 0:
        sum -= C
        second_op = '-'
    else:
        sum += C
        second_op = '+'
    if third == 0:
        sum -= D
        third_op = '-'
    else:
        sum += D
        third_op = '+'
    if sum == 7:
        print(str(A)+first_op+str(B)+second_op+str(C)+third_op+str(D)+'=7')
        exit()

Solution (Python):
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]))
s = input()
dfs(0,s[0],int(s[0]))

Solution (Python):
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[j]="+"

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

Solution (Python):
A, B, C, D = map(int, input())
O = [B, C, D]

N = len(O)
ans = []



for i in range(2**(N)):
    tmp_list = []
    tmp_count = 0
    for j in range(N):
        if (i>>j)&1:
            tmp_list.append("+")
            tmp_count += O[j]
        else:
            tmp_list.append("-")
            tmp_count -= O[j]
            
    if A + tmp_count == 7:
        ans = []
        for k in range(N):
            ans.append(tmp_list[k] + str(O[k]))


print(str(A) + "".join(ans) + "=7")

Solution (Python):
S = input()
N = len(S)
op_cnt = N - 1

for i in range(2 ** op_cnt):
    op = ["+"] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = "-"
    op.append("")
    ans = []
    for num,ops in zip(S,op):
        ans.append(num)
        ans.append(ops)
    ans = [_ for _ in ans if _ != ""]
    ans = ''.join(ans)
    if eval(ans) == 7:
        print(ans + '=7')
        break

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

def helper(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ""
    
    op_p = helper(i+1, x+int(s[i]), op + "+" + s[i])
    if op_p != "":
        return op_p
    
    op_m = helper(i+1, x-int(s[i]), op + "-" + s[i])
    if op_m != "":
        return op_m
    
    return ""


result = helper(1, int(s[0]), s[0])
if result == "":
    print(result)
else:
    print(result + "=7")

Solution (Python):
S = input()
for i in range(2 ** (len(S) - 1)):
    ope = ['-'] * (len(S) - 1)
    for j in range(len(S) - 1):
        if ((i >> j) & 1):
            ope[2 - j] = '+' 
    ans = ''
    ans += S[0]+ope[0]+S[1]+ope[1]+S[2]+ope[2]+S[3]
    if eval(ans) == 7:
        ans += '=7'
        break

print(ans)

Solution (Python):
s = str(input())

ans = ''
for i in range(8):
  bin_str = format(i, '03b')
  

  total = int(s[0])
  formula = s[0]
  for oper, num in zip(bin_str, s[1:]):
    if int(oper) == 1:
      total += int(num)
      formula += '+' + str(num)
    else:
      total -= int(num)
      formula += '-' + str(num)

  if total == 7:
    ans = formula
    break

print(ans + '=7')

Solution (Python):
s=list(input())

hugou=[]
for i in range(8):
  z=[]
  k=0
  ans=0
  for j in range(3):
    if k==0:
      z.append(s[k])
      ans+=int(s[k])
    if ((i>>j)&1):
      z.append("+")
      k+=1
      ans+=int(s[k])
      z.append(s[k])
    else:
      z.append("-")
      k+=1
      ans-=int(s[k])
      z.append(s[k])
  if ans==7:
    print("".join(z)+"=7")
    break

Solution (Python):
s=list(input())

hugou=[]
for i in range(8):
  z=[]
  k=0
  ans=0
  for j in range(3):
    if k==0:
      z.append(s[k])
      ans+=int(s[k])
    if ((i>>j)&1):
      z.append("+")
      k+=1
      ans+=int(s[k])
      z.append(s[k])
    else:
      z.append("-")
      k+=1
      ans-=int(s[k])
      z.append(s[k])
  if ans==7:
    print("".join(z)+"=7")
    break

Solution (Python):
n = input()
op_cntttt = len(n) - 1 
for i in range(2 ** op_cntttt):
    op = ["-"] * op_cntttt
    for j in range(op_cntttt):
        if ((i >> j) & 1):
            op[op_cntttt - 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

Solution (Python):
s = list(map(int, input()))
for bit in range(1 << 3):
    n = 7 - s[0]
    ans = str(s[0])
    for i in range(3):
        if bit & (1 << i):  
            n -= s[i + 1]
            ans += '+' + str(s[i + 1])
        else:
            n += s[i+ 1]
            ans += '-' + str(s[i+1])
    if n == 0:
        print(ans + '=7')
        break

Solution (Python):
S = input()
for i in range((len(S) - 1) ** 2 - 1):
    ope = ['-'] * (len(S) - 1)
    for j in range(len(S) - 1):
        if ((i >> j) & 1):
            ope[2 - j] = '+' 
    ans = ''
    ans += S[0]+ope[0]+S[1]+ope[1]+S[2]+ope[2]+S[3]
    if eval(ans) == 7:
        ans += '=7'
        break

print(ans)

Solution (Python):
a, b, c, d = map(int, list(input()))


def add(x, y):
    return x + y


def sub(x, y):
    return x - y

for op1 in [('+', add), ('-', sub)]:
    for op2 in [('+', add), ('-', sub)]:
        for op3 in [('+', add), ('-', sub)]:
            result = op3[1](op2[1](op1[1](a, b), c), d)
            if result == 7:
                print(str(a) + op1[0] + str(b) + op2[0] + str(c) + op3[0] + str(d) + '=7')
                exit(0)

Solution (Python):
seq=input()
list=[]
for i in range(4):
    list.append(int(seq[i]))
ans=[]
brk=0
for a in range (2):
    for b in range (2):
        for c in range (2):
            if list[0]+(2*a-1)*list[1]+(2*b-1)*list[2]+(2*c-1)*list[3]==7:
                ans.append(a)
                ans.append(b)
                ans.append(c)
                brk+=1
                break
        if brk!=0:
            break
    if brk!=0:
        break
A=""
B=""
C=""
if a==0:
    A="-"
else:
    A="+"
if b==0:
    B="-"
else:
    B="+"    
if c==0:
    C="-"
else:
    C="+"
print(str(list[0])+A+str(list[1])+B+str(list[2])+C+str(list[3])+"=7")

Solution (Python):
import itertools
ns=""
def calc(nums,op):
    sum=int(nums[0])
    for i in range(0,3):
        if op[i]=="+":
            sum=sum+int(nums[i+1])
        elif op[i]=="-":
            sum=sum-int(nums[i+1])
    return sum
S=list(input())
l=["+","-"]
p_list=list(itertools.product(l,l,l))


for i in range(len(p_list)):
    if calc(S,list(p_list[i]))==7:
        
        ans=list(p_list[i])
        ns="".join((ns,S[0]))
        for i in range(3):
            ns="".join((ns,ans[i],S[i+1]))
        ns = "".join((ns,"=7"))
        print(ns)
        break

Solution (Python):
import sys

N = list(input())
op = ["-", "+"]
shiki = ""
ev = []
ans = 0
for bit in range(1 << 3):
    ev.append(N[0])
    for i in range(3):
        if bit & (1 << i):
            ev.append(op[0])
        else:
            ev.append(op[1])
        ev.append(N[i + 1])
    shiki = "".join(ev)
    ans = eval(shiki)
    if ans == 7:
        print(shiki + "=7")
        sys.exit()
    ev.clear()

Solution (Python):
a = list(input())
for i in range(4):
    a[i] = int(a[i])

n = 3

for i in range(2 ** n):
    sym = ["-"] * n
    for j in range(n):
        if (i >> j) & 1:
            sym[j] = "+"

    cal = "{}{}{}{}{}{}{}".format(a[0], sym[0], a[1], sym[1], a[2], sym[2], a[3])
    ans = eval(cal)
    if ans == 7:
        print("{}={}".format(cal, eval(cal)))
        break

Solution (Python):
number = input()

ans_list = []
indexes = [1, 3, 5]
def make_seven(num, index):
    if index == 3:
        if eval(num) == 7:
            ans_list.append(num+"=7")
        return

    make_seven(num[:indexes[index]]+"+"+num[indexes[index]:], index+1)
    make_seven(num[:indexes[index]]+"-"+num[indexes[index]:], index+1)

make_seven(number, 0)
print(ans_list[0])

Solution (Python):
N=list(input())
A=[]
for i in range(2**3):
   B=[0]*3
   for j in range(3):
      if i>>j&1:
         B[j]=1
   A.append(B)


for i in range(8):
   s=int(N[0])
   for j in range(3):
      if A[i][j]==0:
         s+=int(N[j+1])
      else:
         s-=int(N[j+1])
   if s==7:
      ans=[]
      for k in range(4):
         ans.append(N[k])
         if k<3:
            if A[i][k]==0:
               ans.append("+")
            else:
               ans.append("-")   
      print(''.join(ans)+'=7')   
      exit()

Solution (Python):
INF = float("inf") 
MOD = 10**9+7 
MAX = 510000 

import fractions
import itertools

def main():
    s = input()
    n = len(s) - 1 
    ans = 0

    for i in range(2**n):
        op = ["-"] * n
        for j in range(n):
            if (i>>j)&1:
                op[j] = "+"
            tmp = ""
            for a,b in zip(s,op+[""]):
                tmp += a + b
            if eval(tmp) == 7:
                print(tmp + "=7")
                return


if __name__ == "__main__":
    main()

Solution (Python):

S=input()
x=[int(s) for s in S]
for i in range(2**3):
    op=[]
    res=x[0]
    for j in range(3):
        if (i>>j)&1:
            op.append('+')
            res+=x[j+1]
        else:
            op.append('-')
            res-=x[j+1]
    if res==7:
        print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+'=7')
        exit()

Solution (Python):
num = [s.split()[0] for s in open(0)]
num = list(map(int, list(num[0])))


for i in range(len(num)**2):
    comb = ""
    sum_num = 0
    for k in range(len(num)):
        if (i  >> k) & 1:
            sum_num += num[k]
            if k == 0:
                comb += str(num[k])
            else:
                comb += "+" + str(num[k])  
        else:
            sum_num -= num[k]
            if k == 0:
                comb += str(num[k])
            else:
                comb += "-" + str(num[k])  
        
    if sum_num == 7:
        break
        
print(comb + "=7")

Solution (Python):
abcd = input()
a, b, c, d = int(abcd[0]), int(abcd[1]), int(abcd[2]), int(abcd[3])
ptn = []
for i in range(8):
    state = [0] * 3
    for j in range(3):
        state[j] = (i >> j) & 1
    ptn.append(state)

for op in ptn:
    val = a
    if op[0] == 0:
        val += b
        c1 = '+'
    else:
        val -= b
        c1 = '-'
    if op[1] == 0:
        val += c
        c2 = '+'
    else:
        val -= c
        c2 = '-'
    if op[2] == 0:
        val += d
        c3 = '+'
    else:
        val -= d
        c3 = '-'
    if val == 7:
        print(str(a) + c1 + str(b) + c2 + str(c) + c3 + str(d) + '=7')
        exit()

Solution (Python):

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import itertools


def main():
    S=input()
    
    def calc(L):
        temp=int(S[0])
        for i in range(3):
            a=1
            if L[i]==0:
                a=-1
            temp+=int(S[i+1])*a
        return temp
    
    ans=S[0]
    for ite in itertools.product([0,1], repeat=3):
        if calc(ite)==7:
            for i in range(3):
                if ite[i]==1:
                    ans+="+"
                else:
                    ans+="-"
                ans+=S[i+1]
            break
    print(ans+"=7")
    
            
        
    

main()

Solution (Python):
from sys import stdin
s = stdin.readline().rstrip()
for i in range(8):
    point = int(s[0])
    sin = s[0]
    for j in range(3):
        if ((i >> j) & 1):
            point += int(s[j+1])
            sin += "+"+s[j+1]
        else:
            point -= int(s[j+1])
            sin += "-"+s[j+1]
    if point == 7:
        print(sin+"=7")
        exit()

Solution (Python):
def main():
    abcd = input()

    for b in [format(i, '03b') for i in range(8)]:
        s = int(abcd[0])
        expr = abcd[0]
        for i in range(3):
            if b[i] == '0':
                s += int(abcd[i + 1])
                expr += '+'
            else:
                s -= int(abcd[i + 1])
                expr += '-'
            expr += abcd[i + 1]

        if s == 7:
            print(expr + '=7')
            exit()

if __name__ == "__main__":
    main()

Solution (Python):
import sys
import itertools


read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, D = list(readline().decode('utf8').strip())
for ops in itertools.product(['+', '-'], repeat=3):
    eq = A + ops[0] + B + ops[1] + C + ops[2] + D
    x = eval(eq)
    if x == 7:
        break
ans = eq + '=7'
print(ans)

Solution (Python):
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, D = list(readline().decode('utf8').strip())
for ops in itertools.product(['+', '-'], repeat=3):
    eq = A + ops[0] + B + ops[1] + C + ops[2] + D
    x = eval(eq)
    if x == 7:
        break
ans = eq + '=7'
print(ans)

Solution (Python):
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = readline().decode('utf8').strip()
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])

if A + B + C + D == 7:
    print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif A + B + C - D == 7:
    print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif A + B - C + D == 7:
    print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif A - B + C + D == 7:
    print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif A + B - C - D == 7:
    print('{}+{}-{}-{}=7'.format(A, B, C, D))
elif A - B + C - D == 7:
    print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif A - B - C + D == 7:
    print('{}-{}-{}+{}=7'.format(A, B, C, D))
else:
    print('{}-{}-{}-{}=7'.format(A, B, C, D))

Solution (Python):
S = input()
exp = len(S)-1

res = 0
for i in range(2**exp):
    eS = list("+".join(S))
    for j in range(exp):
        if (i >> j) & 1:
            eS[2*j+1] = "-"
    ans = "".join(eS)
    if eval(ans) == 7:
        res = ans + "=7"
        break

print(res)

Solution (Python):
s = list(map(int, input()))
n = 7 - s[0]
b, c, d = s[1], s[2], s[3]

for bit in range(1 << 3):
    n = 7 - s[0]
    ans = str(s[0])
    for i in range(3):
        if bit & (1 << i):
            n -= s[i+1]
            ans += "+" + str(s[i+1])
        else:
            n += s[i+1]
            ans += "-" + str(s[i+1])
    if not n:
        print(ans + "=7")
        break

Solution (Python):
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]))
    
s = input()
dfs(0, s[0], int(s[0]))

Solution (Python):
def main():
    a, b, c, d = input()
    for i in range(2**3):
        ls = ["+", "+", "+"]
        for j in range(len(ls)):
            if (i >> j) & 1:
                ls[j] = "-"
        sentence = a + ls[0] + b + ls[1] + c + ls[2] + d
        if eval(sentence) == 7:
            print(sentence + "=7")
            break


if __name__ == "__main__":
    main()

Solution (Python):
import sys
a = input()

for bit in range(2**3):
    x = a[0]
    for i in range(3):
        if ((bit>>i) & 1):
            x += "+"
        else:
            x += "-"
        x += a[i+1]
    if eval(x) == 7:
        print(str(x)+"=7")
        sys.exit()

Solution (Python):
def main():
    def plus(x, y):
        return x + y
    def minus(x, y):
        return x - y

    ans = ""
    func = {"+": plus, "-": minus}
    A, B, C, D = [int(v) for v in list(input())]
    for sym1 in ["+", "-"]:
        for sym2 in ["+", "-"]:
            for sym3 in ["+", "-"]:
                if func[sym3](func[sym2](func[sym1](A, B), C), D) == 7:
                    ans = str(A) + sym1 + str(B) + sym2 + str(C) + sym3 + str(D) + "=7"
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

def main():
    s = input()

    for i in {"+","-"}:
        for j in {"+","-"}:
            for k in {"+","-"}:
                eq = s[0]+i+s[1]+j+s[2]+k+s[3]
                if eval(eq) == 7:
                    print(eq + "=7")
                    exit()

import itertools
def main2():
    s = list(input())
    sign = ["+", "-"]
    ops = itertools.product(sign, repeat=3)

    for op in ops:
        tmp = ""
        for i in range(3):
            tmp += s[i]
            tmp += op[i]
        tmp += s[3]
        
        if eval(tmp) == 7:
            print(tmp + "=7")
            exit()

if __name__ == "__main__":
    main2()

Solution (Python):
X = input()
flag = ['+','-']
check = 0
for i in flag:
    if check == 1:
        break
    for j in flag:
        if check == 1:
            break
        for k in flag:
            ans = 0
            if i == '+':
                ans = int(X[0]) + int(X[1])
            else:
                ans = int(X[0]) - int(X[1])
            if i == '+':
                ans = int(X[0]) + int(X[1])
            else:
                ans = int(X[0]) - int(X[1])
            if j == '+':
                ans += int(X[2])
            else:
                ans -= int(X[2])
            if k == '+':
                ans += int(X[3])
            else:               
                ans -= int(X[3])
            if ans == 7:
                anslist = [X[0],i,X[1],j,X[2],k,X[3],'=','7']
                check = 1
print(''.join(anslist))

Solution (Python):
a, b, c, d = list( input())
 
op = ['+','-']
 
for i in op :
  for j  in op :
    for k in op :
      if eval( a+ i + b + j + c + k +d) == 7 :
        print('{}{}{}{}{}{}{}=7'.format( a,i, b,j,c,k,d))
        exit()

Solution (Python):
import copy
import sys
a = [int(i) for i in list(input())]

op = ['+', '-']
cmb = [[]]
for i in range(3): 
    tmp = len(cmb)
    for i in range(tmp):
        cmb.append(copy.deepcopy(cmb[i]))
    for j in range(2):
        for k in range(j * tmp, (j + 1) * tmp):
            cmb[k].append(op[j])



for i in range(len(cmb)):
    _sum = a[0]
    for j in range(1, 4):
        if cmb[i][j-1] == '+':
            _sum += a[j]
        else:
            _sum -= a[j]
    
    if _sum == 7:
        ans = str(a[0])
        for j in range(1, 4):
            ans += cmb[i][j-1] + str(a[j])
        ans += '=7'
        print(ans)
        sys.exit()

Solution (Python):
A = input()

def bfs(i, f):
    if i == 3:
        if eval(f) == 7:
            print(f+'=7')
            exit()
        else:
            return None
    bfs(i+1, f+'+'+A[i+1])
    bfs(i+1, f+'-'+A[i+1])
    return None

print(bfs(0, A[0]))

Solution (Python):
a_list = input()

for i in range(8):
    ans = int(a_list[0])
    z = format(i, '03b')

    if z[0] == "0":
      ans = ans + int(a_list[1])
      op1 = "+"
    else:
      ans = ans - int(a_list[1])
      op1 = "-"

    if z[1] == "0":
      ans = ans + int(a_list[2])
      op2 = "+"
    else:
      ans = ans - int(a_list[2])
      op2 = "-"

    if z[2] == "0":
      ans = ans + int(a_list[3])
      op3 = "+"
    else:
      ans = ans - int(a_list[3])
      op3 = "-"
    
    if ans == 7:
      print("{}{}{}{}{}{}{}=7".format(
        a_list[0], op1, a_list[1], op2, a_list[2], op3, a_list[3]
        ))
      break

Solution (Python):
S = input()
num = list(S)

for i in range(2**3) :
    pat = str(format(i, '03b'))
    ans = int(num[0])
    op = ["0", "0", "0"]
    for j in range(3) :
        if pat[j] == "1" :
            ans += int(num[j+1])
            op[j] = "+"
        else :
            ans -= int(num[j+1])
            op[j] = "-"
    if ans == 7 :
        print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
        exit()

Solution (Python):
n = input()
c = len(n)-1
for i in range(2**c):
    op = ['-']*c
    for j in range(c):
        if ((i>>j) & 1):
            op[c-1-j] = '+'
    op += ['']
    formula = ''
    for ni,oi in zip(n,op):
        formula += (ni+oi)
    if eval(formula)==7:
        print(formula+'=7')
        break

Solution (Python):
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)
from functools import lru_cache


s = input()

def dfs(index, ret, op1, op2, op3):
    if index == 4:
        if ret == 7:
            print(s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3] + "=7")
            sys.exit()
    if index == 1:
        dfs(index + 1, ret + int(s[index]), "+", op2, op3) or dfs(index + 1, ret - int(s[index]), "-", op2, op3)
    if index == 2:
        dfs(index + 1, ret + int(s[index]), op1, "+", op3) or dfs(index + 1, ret - int(s[index]), op1, "-", op3)
    if index == 3:
        dfs(index + 1, ret + int(s[index]), op1, op2, "+") or dfs(index + 1, ret - int(s[index]), op1, op2, "-")

dfs(1, int(s[0]), "", "", "")

Solution (Python):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a+b+c-d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')
    
elif a+b-c+d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a-b+c+d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a+b-c-d == 7:
	print(a, end='')
	print('+', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')
    
elif a-b-c+d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('+', end='')
	print(d, end='')
	print('=7')
    
elif a-b+c-d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('+', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')
    
elif a-b-c-d == 7:
	print(a, end='')
	print('-', end='')
	print(b, end='')
	print('-', end='')
	print(c, end='')
	print('-', end='')
	print(d, end='')
	print('=7')

Solution (Python):
def solve():
    N = list(input().split())[0]
    a,b,c,d = int(N[0]),int(N[1]),int(N[2]),int(N[3])

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

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

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

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

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

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

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

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





solve()

Solution (Python):
from itertools import product

a,b,c,d = [int(i) for i in list(input())]

formula = ''
for x,y,z in product(('+','-'), repeat=3):
    formula = '{}{}{}{}{}{}{}'.format(a,x,b,y,c,z,d)
    if eval(formula) == 7:
        break

print('{}=7'.format(formula))

Solution (Python):
s = list(input())

ops = ["-", "+"]

for i in range(0, 2**3):
    dig = (bin(i)[2:]).zfill(3)
    
    sum = int(s[0])
    for j in range(0, 3):
        x = -1 if int(dig[j]) == 0 else 1
        sum += int(s[j + 1]) * x
    if (sum == 7):
        print(s[0] + ops[int(dig[0])] + s[1] + ops[int(dig[1])] + s[2] +
              ops[int(dig[2])] + s[3] + "=7")
        break

Solution (Python):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d==7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a+b+c-d==7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c+d==7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a-b+c+d==7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a-b-c+d==7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a-b+c-d==7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c-d==7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a-b-c-d==7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))

Solution (Python):
a, b, c, d = (int(i) for i in input())
op = ["+", "-"]
for op_1 in op:
    ans_1 = eval("{}{}{}".format(a, op_1, b))
    for op_2 in op:
        ans_2 = eval("{}{}{}".format(ans_1, op_2, c))
        for op_3 in op:
            if eval("{}{}{}".format(ans_2, op_3, d)) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, op_1, b, op_2, c, op_3, d))
                exit()

Solution (Python):
a, b, c, d = (int(i) for i in input())

op = ["+", "-"]

def calculate(n_1, n_2, op):
    if op == 0:
        return n_1 + n_2
    else:
        return n_1 - n_2

for i in range(2):
    ans_1 = calculate(a, b, i)
    for j in range(2):
        ans_2 = calculate(ans_1, c, j)
        for k in range(2):
            if calculate(ans_2, d, k) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, op[i], b, op[j], c, op[k], d))
                exit()

Solution (Python):
a=list(input())

for i in range(2**3):
    status=[0]*3
    s=""
    for j in range(3):
        if ((i>>j)&1):
            status[j]="+"
        else:
            status[j]="-"
    for x,y in zip(a,status):
        s+=x
        s+=y
    s+=a[-1]
    if eval(s)==7:
        print(s+"=7")
        exit()

Solution (Python):
s = input()



for i in range(8):
    ans = int(s[0])
    f = s[0]
    for j in range(3):
        if i >> j & 1:
            ans += int(s[j + 1])
            f = f + "+" + s[j + 1]
        else:
            ans -= int(s[j + 1])
            f = f + "-" + s[j + 1]
    
    if ans == 7:
        print(f + "=7")
        break

Solution (Python):
abcd = input()
ans_word = []

for i in range(2**3):
    ans = int(abcd[0])
    for j in range(3):
        
        if((i>>j)&1 == 1):
            ans += int(abcd[j+1])
        else:
            ans -= int(abcd[j+1])
    
    if(ans == 7):
        for k in range(4):
            ans_word.append(abcd[k])
            if((i>>k)&1 == 1):
                ans_word.append('+')
            else:
                if(k < 3):
                    ans_word.append('-')
        ans_word.append("=7")
        print("".join(ans_word))
        break

Solution (Python):
ABCD = [int(i) for i in input()]

if ABCD[0] + ABCD[1] + ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] + ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] - ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] - ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] + ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] - ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] + ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] - ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

Solution (Python):
from itertools import product
a,b,c,d = input()
for op1,op2,op3 in product(["+","-"],repeat=3):
    eq = a+op1+b+op2+c+op3+d
    if eval(eq) == 7:
        print(eq + "=7")
        break

Solution (Python):



A,B,C,D = [ int(s) for s in list(input().strip()) ]


def check(A,B,C,D):
    for i in [-1,1]:
        for j in [-1,1]:
            for k in [-1,1]:
                sum = A + (-1)*i*B + (-1)*j*C + (-1)*k*D
                
                if sum == 7:
                    return A,(-1)*i*B,(-1)*j*C,(-1)*k*D

a,b,c,d = check(A,B,C,D)
print('{}{:+}{:+}{:+}=7'.format(a,b,c,d))

Solution (Python):
A=list(input())
for i in range(4):
  A[i]=int(A[i])

for bit in range(8):
  flag=["+","+","+"]
  for i in range(3):
    if not bit>>(2-i) & 1 :
      A[i+1]=-A[i+1]
      flag[i]="-"
  if sum(A)==7:
    print("{}{}{}{}{}{}{}=7".format(A[0],flag[0],abs(A[1]),flag[1],abs(A[2]),flag[2],abs(A[3])))
    exit()
  for i in range(4):
    A[i]=abs(A[i])

Solution (Python):
s=input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            sum=int(s[0])
            if i==0:
                sum+=int(s[1])
            else:
                sum-=int(s[1])
            if j==0:
                sum+=int(s[2])
            else:
                sum-=int(s[2])
            if k==0:
                sum+=int(s[3])
            else:
                sum-=int(s[3])
            if sum==7:
                a="-"
                b="-"
                c="-"
                if i==0:
                    a="+"
                if j==0:
                    b="+"
                if k==0:
                    c="+"
                print(s[0]+a+s[1]+b+s[2]+c+s[3]+"=7")
                exit()

Solution (Python):
ABCD = list(map(int, list(input())))
op_cnt = len(ABCD) -1
for i in range(2 ** op_cnt):
  ans_str = str(ABCD[0]) 
  ans = ABCD[0]
  op = ["-"]* op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt- j - 1] = "+"
  for i, f in enumerate(op):
    if f == "+":
      ans += ABCD[i+1]
      ans_str += "+" + str(ABCD[i+1])
    else:
      ans -= ABCD[i+1]
      ans_str += "-" + str(ABCD[i+1])
  if ans == 7:
    print(ans_str + "=7")
    break

Solution (Python):
a, b, c, d = map(int, input())

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, '=', 7, sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, '=', 7, sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, '=', 7, sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, '=', 7, sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, '=', 7, sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, '=', 7, sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, '=', 7, sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, '=', 7, sep='')

Solution (Python):
s = input()
op = ["-","+"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            com = s[0]+op[i]+s[1]+op[j]+s[2]+op[k]+s[3]
            if eval(com) ==7:
                print(com + "=7")
                exit(0)