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):
import itertools
a = ["+", "-"]
b = ["+", "-"]
c = ["+", "-"]


A = input()
l = [str(c) for c in A]



for v in itertools.product(a, b,c):
    
    ans =  l[0] + v[0] + l[1] + v[1] + l[2] + v[2] + l[3]
    
    if eval(ans) == 7:
      print(ans + "=7")
      exit()

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


def dfs(index, formula, sum_number):
    if index + 1 == num_digits:
        if sum_number == 7:
            print(formula + "=7")
            exit()
    else:
        dfs(index + 1, formula + "+" + s[index + 1], sum_number + int(s[index + 1]))
        dfs(index + 1, formula + "-" + s[index + 1], sum_number - int(s[index + 1]))


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

Solution (Python):
def examC():
    ABCD = S()
    loop = 2**3
    for i in range(loop):
        cur = int(ABCD[0])
        for j in range(3):
            if (i>>j)&1==1:
                cur += int(ABCD[j+1])
            else:
                cur -= int(ABCD[j+1])
        if cur==7:
            cur = i
            break
    ans = str(ABCD[0])
    for i in range(3):
        if (cur>>i)&1 == 1:
            ans += "+"
        else:
            ans += "-"
        ans += str(ABCD[i+1])
    ans += "=7"
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
n = input()

if ((int(n[0]) + int(n[1])+ int(n[2]) + int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'+'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) - int(n[1])+ int(n[2]) + int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'+'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) + int(n[1]) - int(n[2]) + int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'-'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) + int(n[1]) - int(n[2]) - int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'-'+n[2]+'-'+n[3]+'=7')
elif ((int(n[0]) + int(n[1]) + int(n[2]) - int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'+'+n[2]+'-'+n[3]+'=7')
elif ((int(n[0]) - int(n[1]) - int(n[2]) + int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'-'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) - int(n[1]) + int(n[2]) - int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'+'+n[2]+'-'+n[3]+'=7')
elif ((int(n[0]) - int(n[1]) - int(n[2]) - int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'-'+n[2]+'-'+n[3]+'=7')

Solution (Python):
a, b, c, d = list(input())
en = ["+", "-"]
for x in en:
  for y in en:
    for z in en:
      s = a + x + b + y + c + z + d
      if eval(s) == 7:
        print(s + "=7")
        exit()

Solution (Python):
li = list(input())
op = ["+", "-"]

for i in op:
    for j in op:
        for k in op:
            s = li[0] + i + li[1] + j + li[2] + k + li[3]
            if eval(s) == 7:
                print(s+"=7")
                exit()

Solution (Python):
def output(i):
    symbol = []
    for j in range(n):
        if i>>j & 1:
            symbol.append('+')
        else:
            symbol.append('-')
    out =''
    for k in range(3):
        out += str(a[k]) + symbol[k]
    out += str(a[3])+'=7'
    print(out)

s = list(input())
a = list(map(int, s))

n = 3
comb= 2**n

for i in range(comb):
    x = a[0]
    
    for j in range(n):
        if i>>j & 1:            
            x += a[j+1]
            
        else:
            x -= a[j+1]
            
        
    if x ==7:
        
        output(i)
        break

Solution (Python):
A,B,C,D=list(input())

F=["+","-"]

for x in range(2):
    for y in range(2):
        for z in range(2):
            if eval(A+F[x]+B+F[y]+C+F[z]+D)==7:
                print(A+F[x]+B+F[y]+C+F[z]+D+"=7")
                exit()

Solution (Python):
a=input()
import itertools
l=list(itertools.product("+-",repeat=3))
for i in range(8):
    num=a[0]
    for j in range(3):
        num+=l[i][j]
        num+=a[j+1]
    if eval(num)==7:
        print(num+"=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]))
    
    return False
s=input()

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

Solution (Python):
S=str(input())
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
value1=A+B+C+D
value2=A+B+C-D
value3=A+B-C+D
value4=A+B-C-D
value5=A-B+C+D
value6=A-B+C-D
value7=A-B-C+D
value8=A-B-C-D
sum_dict={"{0}+{1}+{2}+{3}".format(A,B,C,D):value1,\
"{0}+{1}+{2}-{3}".format(A,B,C,D):value2,\
"{0}+{1}-{2}+{3}".format(A,B,C,D):value3,\
"{0}+{1}-{2}-{3}".format(A,B,C,D):value4,\
"{0}-{1}+{2}+{3}".format(A,B,C,D):value5,\
"{0}-{1}+{2}-{3}".format(A,B,C,D):value6,\
"{0}-{1}-{2}+{3}".format(A,B,C,D):value7,\
"{0}-{1}-{2}-{3}".format(A,B,C,D):value8}

for k,v in sum_dict.items():
    if v==7:
        print(k+"=7",sep="")
        break

Solution (Python):
from operator import sub,add
tmp = input()
A = int(tmp[0])
B = int(tmp[1])
C = int(tmp[2])
D = int(tmp[3])
dic = {0:sub,1:add}
ansdic = {0:"-",1:"+"}
ans = []
for i in [0,1]:
    for j in [0,1]:
        for k in [0,1]:
            tmp1 = dic[i](A,B)
            tmp2 = dic[j](tmp1,C)
            tmp3 = dic[k](tmp2,D)
            if tmp3 == 7:
                ans = [i,j,k]
                break
print(str(A)+ansdic[ans[0]]+str(B)+ansdic[ans[1]]+str(C)+ansdic[ans[2]]+str(D)+"=7")

Solution (Python):
a=list(input())
for i in range(4):
    a[i]=int(a[i])
if sum(a)==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]+a[1]+a[2]-a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'='+'7')
elif a[0]+a[1]-a[2]+a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]-a[1]+a[2]+a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]+a[1]-a[2]-a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'='+'7')
elif a[0]-a[1]+a[2]-a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'='+'7')
elif a[0]-a[1]-a[2]+a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]-a[1]-a[2]-a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'='+'7')

Solution (Python):
a,b,c,d = input()
for i in ('+','-'):
    for j in ('+','-'):
        for k in ('+','-'):
            if eval(a+i+b+j+c+k+d) == 7:
                print(a+i+b+j+c+k+d+'=7')
                exit()

Solution (Python):
A,B,C,D = list(map(int,list(input())))
def plus(x):
    if x == 0:
        return '+'
    else:
        return '-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+(1-2*i)*B+(1-2*j)*C+(1-2*k)*D
            if ans == 7:
                print(str(A)+plus(i)+str(B)+plus(j)+str(C)+plus(k)+str(D)+'=7')
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
A, B, C, D = list(map(int, list(input())))

def int_to_pm(x):
    if x == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A + (1-2*i)*B + (1-2*j)*C + (1-2*k)*D
            if ans == 7:
                print(str(A) + int_to_pm(i) + str(B) + int_to_pm(j) + str(C) + int_to_pm(k) + str(D) + '=7')
                break
        else:
            continue
        break
    else:
        continue
    break

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

for i in range(3**2):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[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

Solution (Python):
import sys
s = (input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ls = ["+","-"]
ans = a+b+c+d
if ans == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a+b+c-d
if ans == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    sys.exit()
ans = a+b-c+d
if ans == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a-b+c+d
if ans == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a-b-c+d
if ans == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    sys.exit()
ans = a+b-c-d
if ans == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    sys.exit()
ans = a-b+c-d
if ans == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    sys.exit()
ans = a-b-c-d
if ans == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    sys.exit()

Solution (Python):
s=input()
for i in range(2**3):
    op = ['+','+','+']
    for j in range(3):
        if ((i >> j) & 1):
            op[j] = '-'
    if eval(s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]) == 7:
        print(s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]+'=7')
        break

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

def calc(arg1, arg2, arg3):
    if arg1 == 0:
        arg2 += "+" + arg3
    else:
        arg2 += "-" + arg3
    return arg2


for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            ans = a
            ans = calc(op1, ans, b)
            ans = calc(op2, ans, c)
            ans = calc(op3, ans, d)
            if eval(ans) == 7:
               break
        else:
            continue
        break
    else:
        continue
    break

print(ans + "=7")

Solution (Python):
a,b,c,d = list(map(int, list(input())))
for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            if a + b * [1,-1][op1] + c * [1,-1][op2] + d * [1,-1][op3] == 7:
                print("%d%s%d%s%d%s%d=7" % (a, ["+", "-"][op1], b, ["+", "-"][op2], c, ["+", "-"][op3], d))
                exit()

Solution (Python):
from sys import exit
A, B, C, D = map(int, list(input()))
ops = ["+", "-"]
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            expr = "{0}{1}{2}{3}{4}{5}{6}".format(A, op1, B, op2, C, op3, D)
            if eval(expr) == 7:
                print(expr + "=7")
                exit()

Solution (Python):
S = input()
ans = ''


def calc(i, s, num):
    if i == 3:
        if num == 7:
            global ans
            ans = s + '=7'
    else:
        calc(i+1, s+'+'+S[i+1], num+int(S[i+1]))
        calc(i+1, s+'-'+S[i+1], num-int(S[i+1]))


def solve():
    calc(0, S[0], int(S[0]))
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
def dfs(i,e,s):
    if i==n-1:
        if s==7:
            print(e+'=7')
            exit()
    
    else:
        dfs(i+1,e+'+'+a[i+1],s+int(a[i+1]))
        dfs(i+1,e+'-'+a[i+1],s-int(a[i+1]))
    
a=input()
n=len(a)
dfs(0,a[0],int(a[0]))

Solution (Python):

A, B, C, D = input()
A = int(A)
B = int(B)
C = int(C)
D = int(D)
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")
else:
    print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Solution (Python):
A, B, C, D = list(map(int, list(input())))

def int_to_pm(x):
    if x == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A + (1-2*i)*B + (1-2*j)*C + (1-2*k)*D
            if ans == 7:
                print(str(A) + int_to_pm(i) + str(B) + int_to_pm(j) + str(C) + int_to_pm(k) + str(D) + '=7')
                break
        else:
            continue
        break
    else:
        continue
    break

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

Solution (Python):
a, b, c, d = [int(x) for x in input()]

bcd = [b, c, d]
var = [['+', '+', '+'],['+', '+', '-'], ['+', '-', '+'], ['+', '-', '-'], ['-', '+', '+'], ['-', '+', '-' ], ['-', '-', '+'], ['-', '-', '-']]
for va in var:
    ans = a
    for i, op in zip(bcd, va):
        if op == '+':
            ans += i
        else:
            ans -= i
    if ans == 7:
        print('{}{}{}{}{}{}{}=7'.format(a,va[0],b,va[1],c,va[2],d))
        break

Solution (Python):
s=int(input())
A=s//1000
B=s//100%10
C=s//10%10
D=s%10

for k in range(1<<3):
    op1=k&1
    op2=k>>1&1
    op3=k>>2&1
    t=A;ans=str(A)
    if op1:
        t+=B;ans+='+'+str(B)
    else:
        t-=B;ans+='-'+str(B)
    if op2:
        t+=C;ans+='+'+str(C)
    else:
        t-=C;ans+='-'+str(C)
    if op3:
        t+=D;ans+='+'+str(D)+'=7'
    else:
        t-=D;ans+='-'+str(D)+'=7'
    if t==7:
        print(ans)
        break

Solution (Python):
ABCD = input()

a = ABCD[0]
f = int(a)

def recur(total,formula,i):
  
  if i == 4:
    
    if total == 7:
      print(formula+"=7")
      exit()
  
  
  else:
    recur(total + int(ABCD[i]),formula + "+" + ABCD[i],i + 1),
    recur(total - int(ABCD[i]),formula + "-" + ABCD[i],i + 1)
  
recur(f,a,1)

Solution (Python):
S = input()
for i in range(2 ** 3):
    pm = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):  
            pm[3-1 - j] = "+"
    if eval(S[0]+pm[0]+S[1]+pm[1]+S[2]+pm[2]+S[3]) == 7:
        print(S[0]+pm[0]+S[1]+pm[1]+S[2]+pm[2]+S[3]+"=7")
        exit()

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

for i in range(2**3):
	res = int(s[0])
	m = []
	for j in range(3):
		if i>>j&1:
			res += int(s[j+1])
			m.append("+")
		else:
			res -= int(s[j+1])
			m.append("-")
	if res == 7:
		m.append("")
		break
		
for i in range(4):
	print(s[i] + m[i], end = "")
print("=7")

Solution (Python):
import sys
input = sys.stdin.readline
ABCD = list(map(int, list(input())[: -1]))
t = [[] for _ in range(4)]
t[0].append((ABCD[0], ""))
for i in range(3):
  for j in range(len(t[i])):
    t[i + 1].append((t[i][j][0] + ABCD[i + 1], t[i][j][1] + "+"))
    t[i + 1].append((t[i][j][0] - ABCD[i + 1], t[i][j][1] + "-"))

for i in range(len(t[-1])):
  if t[-1][i][0] == 7:
    print(str(ABCD[0]) + t[-1][i][1][0] + str(ABCD[1]) + t[-1][i][1][1] + str(ABCD[2]) + t[-1][i][1][2] + str(ABCD[3]) + "=7")
    exit(0)

Solution (Python):
ss=input()
s=[0]*4
for i in range(len(ss)):
  s[i]=int(ss[i])
dif=7-s[0]
ans=str(s[0])
found=False

for b in [s[1],-s[1]]:
  for c in [s[2],-s[2]]:
    for d in [s[3],-s[3]]:
      if b+c+d==dif:
        if b==s[1]:
          ans+="+"
        ans+=str(b)
        if c==s[2]:
          ans+="+"
        ans+=str(c)
        if d==s[3]:
          ans+="+"
        ans+=str(d)
        found=True
        break
    if found:
      break
  if found:
    break
print(ans+"=7")

Solution (Python):
ss=input()
s=[0]*4
for i in range(len(ss)):
  s[i]=int(ss[i])
dif=7-s[0]
ans=str(s[0])
found=False
for b in [s[1],-s[1]]:
  for c in [s[2],-s[2]]:
    for d in [s[3],-s[3]]:
      if b+c+d==dif:
        if b==s[1]:
          ans+="+"
        else:
          ans+="-"
        ans+=str(s[1])
        if c==s[2]:
          ans+="+"
        else:
          ans+="-"
        ans+=str(s[2])
        if d==s[3]:
          ans+="+"
        else:
          ans+="-"
        ans+=str(s[3])
        found=True
        break
    if found:
      break
  if found:
    break
print(ans+"=7")

Solution (Python):

import sys
S = list(input())
def dfs(i,f,s):
    if i == len(S)-1:
        if s == 7:
            print(f+"=7")
            sys.exit()
    else:
        return dfs(i+1, f+"+"+S[i+1], s+int(S[i+1])), dfs(i+1, f+"-"+S[i+1], s-int(S[i+1]))
dfs(0,S[0],int(S[0]))

Solution (Python):
ABCD = list(map(int,input()))
op=[""]*3
def dfs(opN, ans):
    if opN == 3:
        return ans == 7
    op[opN] = "+"
    if (dfs(opN + 1, ans + ABCD[opN + 1])):
        return True
    op[opN] = "-"
    if (dfs(opN + 1, ans - ABCD[opN + 1])):
        return True
    return False
dfs(0,ABCD[0])
print(str(ABCD[0])+op[0]+str(ABCD[1])+op[1]+str(ABCD[2])+op[2]+str(ABCD[3])+"=7")

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

op = ["+", "+", "+", ""]

for i in "+-":
    op[0] = i
    for j in "+-":
        op[1] = j
        for k in "+-":
            op[2] = k
            expression = "".join(l+m for l, m in zip(abcd, op))
            if eval(expression) == 7:
                print(expression+"=7")
                quit()

Solution (Python):
import sys
s = input()
a  = 7
n = len(s)
for i in range(2**(n-1)):
    total = int(s[0])
    ans = [s[0]]
    for j in range(n-1):
        if (i >> j) & 1:
            total += int(s[j+1])
            ans.append('+' + s[j+1])
        else:
            total -= int(s[j+1])
            ans.append('-'+s[j+1])
    if total == 7:
        print(''.join(ans) + '=7')
        sys.exit()

Solution (Python):
import sys 
target = list(map(int,input()))

if target[0]+target[1]+target[2]+target[3] == 7:
	print(str(target[0])+'+'+str(target[1])+'+'+str(target[2])+'+'+str(target[3])+'=7')
	sys.exit()
elif target[0]+target[1]+target[2]-target[3] == 7:
	print(str(target[0])+'+'+str(target[1])+'+'+str(target[2])+'-'+str(target[3])+'=7')
	sys.exit()
elif target[0]+target[1]-target[2]+target[3] == 7:
	print(str(target[0])+'+'+str(target[1])+'-'+str(target[2])+'+'+str(target[3])+'=7')
	sys.exit()
elif target[0]+target[1]-target[2]-target[3] == 7:
	print(str(target[0])+'+'+str(target[1])+'-'+str(target[2])+'-'+str(target[3])+'=7')
	sys.exit()
elif target[0]-target[1]+target[2]+target[3] == 7:
	print(str(target[0])+'-'+str(target[1])+'+'+str(target[2])+'+'+str(target[3])+'=7')
	sys.exit()
elif target[0]-target[1]+target[2]-target[3] == 7:
	print(str(target[0])+'-'+str(target[1])+'+'+str(target[2])+'-'+str(target[3])+'=7')
	sys.exit()
elif target[0]-target[1]-target[2]+target[3] == 7:
	print(str(target[0])+'-'+str(target[1])+'-'+str(target[2])+'+'+str(target[3])+'=7')
	sys.exit()
elif target[0]-target[1]-target[2]-target[3] == 7:
	print(str(target[0])+'-'+str(target[1])+'-'+str(target[2])+'-'+str(target[3])+'=7')
	sys.exit()

Solution (Python):
a, b, c, d = input()
ops = ['+', '+', '+']
ans = []

def dfs(i, ops):
    ops = ops.copy()
    if eval(a + ops[0] + b + ops[1] + c + ops[2] + d) == 7:
        ans.append(a + ops[0] + b + ops[1] + c + ops[2] + d + '=7')
    elif i == 3:
        pass
    else:
        dfs(i + 1, ops)
        ops[i] = '-'
        dfs(i + 1, ops)

dfs(0, ops)

print(ans[0])

Solution (Python):
abcd = list(input())
for i in range(2**3):
    tmp = abcd[:]
    bag = []
    for j in range(2, -1, -1):
        if (i >> j) & 1:
            tmp.insert(j+1, "+")
        else:
            tmp.insert(j+1, "-")
    if (eval(''.join(tmp)) == 7):
        print(''.join(tmp), "=7", sep="")
        exit()

Solution (Python):
S = input()

s = S[0]
n = int(s)

def F(ans,total,i):
  if i == 4:
    if total == 7:
      print(ans + "=7")
      exit()

  else:
    return F(ans + "+" + S[i],total + int(S[i]),i + 1),F(ans + "-" + S[i],total - int(S[i]),i + 1)

F(s,n,1)

Solution (Python):
s = input()
for i in range(2 ** 3):
    ans = s[0]
    for j in range(3):
        if ((i >> j) & 1):
            ans += "+" + s[j + 1]
        else:
            ans += "-" + s[j + 1]

    if eval(ans) == 7:
        print(ans + "=7")
        exit()

Solution (Python):
s = input()
for i in range(2 ** 3):
    res = int(s[0])
    ans = s[0]
    for j in range(3):
        if ((i >> j) & 1):
            res += int(s[j + 1])
            ans += "+" + s[j + 1]
        else:
            res -= int(s[j + 1])
            ans += "-" + s[j + 1]
    if res == 7:
        
        print(ans + "=7")
        exit()

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

def dp(i, abcd, s):
  if i == 3:
    s += abcd[3]
    if eval(s) == 7:
      return s, True
    else:
      return s, False
  for c in ['+', '-']:
    d, f = dp(i + 1, abcd, s + abcd[i] + c)
    if f:
      return d, True
  else:
    return d, False

s, f = dp(0, ABCD, '')
print(s + '=7')

Solution (Python):
import sys
s = input()
n = 4

for i in range(2**(n-1)):
    e = ""
    for j in range(n-1):
        if (i>>j)& 1 == 1:
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    e += s[-1]
    if eval(e) == 7:
        print(e+"=7")
        sys.exit()

Solution (Python):
def f(a,b,i):
  if i==4:
    if b==7:
      print(a+"=7")
      exit()
  else:
    return f(a+"+"+s[i],b+int(s[i]),i+1),f(a+"-"+s[i],b-int(s[i]),i+1)

s=input()
f(s[0],int(s[0]),1)

Solution (Python):
S=input()
l=len(S)-1
ans =0
for i in range(1 << l):
    s=S[0]
    for j in range(l):
        if (i >> j)&1:
            s+="+"
        else:
            s+="-"
        s+=S[j+1]
    if eval(s)==7:
        print(s+"=7")
        exit()

Solution (Python):
l = list(input())
if int(l[0]) + int(l[1]) + int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "+" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) + int(l[1]) + int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "+" +l[2]+ "-" +l[3]+ "=7");exit()
elif int(l[0]) + int(l[1]) - int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "-" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) + int(l[1]) - int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "-" +l[2]+ "-" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) + int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "+" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) + int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "+" +l[2]+ "-" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) - int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "-" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) - int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "-" +l[2]+ "-" +l[3]+ "=7");exit()

Solution (Python):
A,B,C,D =input()
E ="+-"

for i in E:
  for j in E:
    for k in E:
      s=A+i+B+j+C+k+D
      if eval(s)==7:
        print(s+"=7")
        exit()

Solution (Python):
N = int(input())

for i in range(2**3, 2**4):
    b = bin(i)
    cnt = N//10**3
    for j in range(3):
        if b[j+3] == "1":
            cnt += (N%10**(3-j))//10**(2-j)
        else:
            cnt -= (N%10**(3-j))//10**(2-j)
    if cnt == 7:
        B = b
        break
        
ans = ["0"]*9
ans[0] = str(N//10**3)
ans[2] = str((N%10**3)//10**2)
ans[4] = str((N%10**2)//10)
ans[6] = str(N%10)
for i in range(3):
    if B[i+3] == "1":
        ans[2*i+1] = "+"
    else:
        ans[2*i+1] = "-"
        
ans[7] = "="
ans[8] = "7"
print("".join(ans))

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

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

Solution (Python):
x = input()
n = len(x)-1

for bit in range(1 << n):
    f=x[0]
    for i in range(n):
        if bit & (1 << i):
            f+='+'
        else:
            f+='-'
        f += x[i + 1]
    if eval(f) == 7:
        print(f+"=7")
        break

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

tmp = list[0]+list[1]+list[2]+list[3]
if tmp == 7:
    print("%d+%d+%d+%d=7"%(list[0],list[1],list[2],list[3]))
else:
    tmp = tmp - 2*list[3]
    if tmp == 7:
        print("%d+%d+%d-%d=7"%(list[0],list[1],list[2],list[3]))
    else:
       tmp = tmp - 2*list[2]
       if tmp == 7:
            print("%d+%d-%d-%d=7"%(list[0],list[1],list[2],list[3]))
       else:
           tmp = tmp + 2*list[3]
           if tmp == 7:
                print("%d+%d-%d+%d=7"%(list[0],list[1],list[2],list[3]))
           else:
              tmp = tmp - 2*list[1]
              if tmp == 7:
                  print("%d-%d-%d+%d=7"%(list[0],list[1],list[2],list[3]))
              else:
                 tmp = tmp + 2*list[2]
                 if tmp == 7:
                     print("%d-%d+%d+%d=7"%(list[0],list[1],list[2],list[3]))
                 else:
                    tmp = tmp - 2*list[3]
                    if tmp == 7:
                        print("%d-%d+%d-%d=7"%(list[0],list[1],list[2],list[3]))
                    else:
                            print("%d-%d-%d-%d=7"%(list[0],list[1],list[2],list[3]))

Solution (Python):
nums = input()
for i in range(2**3):
  case = bin(i)[2:].zfill(3).replace('0', '+').replace('1','-')
  str_eq = nums[0] + case[0] + nums[1] + case[1] + nums[2] + case[2] + nums[3]
  if eval(str_eq) == 7:
    print(str_eq + '=7')
    exit()

Solution (Python):
import sys








def main():
    a, b, c, d = (int(x) for x in list(sys.stdin.readline().rstrip()))
    s = 7 - a
    if sum([b, c, d]) == s: res = '+++'
    elif sum([-b, c, d]) == s: res = '-++'
    elif sum([b, -c, d]) == s: res = '+-+'
    elif sum([b, c, -d]) == s: res = '++-'
    elif sum([-b, -c, d]) == s: res = '--+'
    elif sum([-b, c, -d]) == s: res = '-+-' 
    elif sum([b, -c, -d]) == s: res = '+--'
    if res[0] == '-': b = -b
    if res[1] == '-': c = -c
    if res[2] == '-': d = -d
    ans = [str(a)]
    for x in [b, c, d]:
        if x >= 0 : x = '+' + str(x)
        else: x = str(x)
        ans.append(x)
    print(''.join(ans) + '=7')


if __name__ == "__main__":
    
    main()

Solution (Python):
s = [int(x) for x in list(input())]

def answer(count, total, formula):
  if count == 3:
    if total==7:
      print(formula + '=7')
      exit()
    return
  answer(count+1, total + s[count+1], formula+'+'+str(s[count+1]))
  answer(count+1, total - s[count+1], formula+'-'+str(s[count+1]))
  return

answer(0, s[0], str(s[0]))

Solution (Python):
s = [int(x) for x in list(input())]

def answer(count, total, formula):
  if count == 3:
    if total==7:
      print(formula + '=7')
      exit()
    return
  answer(count+1, total + s[count+1], formula+'+'+str(s[count+1]))
  answer(count+1, total - s[count+1], formula+'-'+str(s[count+1]))
  return

answer(0, s[0], str(s[0]))

Solution (Python):
ABCD = input()

def bit_cal(n):
    return_list = [''] * (2**n)
    for i in range(2**n):
        for j in range(n):
            if ((i >> j) & 1):
                return_list[i] = return_list[i] + '1'
            else:
                return_list[i] = return_list[i] + '0'
    return return_list

ope_candidates = bit_cal(3)

flag = False
for ope in ope_candidates:
    tmp_ans = int(ABCD[0])
    tmp_str = ABCD[0]
    for i in range(3):
        if ope[i] == '0':
            tmp_ans += int(ABCD[i+1])
            tmp_str = tmp_str + '+' + str(ABCD[i+1])
        else:
            tmp_ans -= int(ABCD[i+1])
            tmp_str = tmp_str + '-' + str(ABCD[i+1])
    if tmp_ans == 7:
        break
print(tmp_str + '=7')

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

ans = 0

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

Solution (Python):
A=str(input())
if int(A[0])+int(A[1])+int(A[2])+int(A[3])==7:
  print('{}+{}+{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])+int(A[1])+int(A[2])-int(A[3])==7:
  print('{}+{}+{}-{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])+int(A[1])-int(A[2])+int(A[3])==7:
  print('{}+{}-{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])+int(A[1])-int(A[2])-int(A[3])==7:
  print('{}+{}-{}-{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])+int(A[2])+int(A[3])==7:
  print('{}-{}+{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])+int(A[2])-int(A[3])==7:
  print('{}-{}+{}-{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])-int(A[2])+int(A[3])==7:
  print('{}-{}-{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])-int(A[2])-int(A[3])==7:
  print('{}-{}-{}-{}=7'.format(A[0],A[1],A[2],A[3]))

Solution (Python):
A,B,C,D=list(input())
op=["+", "-"]
for op1 in op:
  for op2 in op:
    for op3 in op:
      s="{}{}{}{}{}{}{}".format(A,op1,B,op2,C,op3,D)
      if eval(s)==7:
        print("{}=7".format(s))
        exit()

Solution (Python):
abcd = input()
for i in range(2**3):
  s = ""
  for j in range(3):
    if (i >> j) & 1 == 1:
      s += abcd[j] + "+"
    else:
      s += abcd[j] + "-"
  s += abcd[3]
  if eval(s) == 7:
    print(s + "=7")
    break

Solution (Python):
s=input()
a,b,c,d=s[0],s[1],s[2],s[3]
e=int(a)
o=['+','-']
p=[1,int(-1)]
x,y,z='','',''
ans,f,g,h=0,0,0,0
for i in range(2):
  f=int(b)*((-1)**i)
  x=o[i]
  for j in range(2):
    g=int(c)*((-1)**j)
    y=o[j]
    for k in range(2):
      h=int(d)*((-1)**k)
      z=o[k]
      ans=e+f+g+h
      
      if ans==7:
        print(a+x+b+y+c+z+d+'=7')
        exit()
      ans=0

Solution (Python):
abcd = input()
s = 0
i = 0
for i in range(8):
    a = abcd[0]
    for j in range(3):
        if (i >> j) & 1:
            a += '+'
        else:
            a += '-'
        a += abcd[j+1]
    s = eval(a)
    if s == 7:
        ans = a + '=' + '7'
        break
print(ans)

Solution (Python):
abcd = input()


for i in range(2**3):
    t = ""
    for j in range(3):
        if((i>>j)&1):
            t += abcd[j]+"+"
        else:
            t += abcd[j]+"-"

    t += abcd[3]

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

Solution (Python):
from itertools import product

n = input()
ops = product('+-', repeat=3)

for op in ops:
    fm = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
    if eval(fm) == 7:
        print(fm + '=7')
        break

Solution (Python):
s=input()
for bit in range(2**3):
  c=s[0]
  for i in range(3):
    if (bit>>i)&1:c+='+'
    else:c+='-'
    c+=s[i+1]
  if eval(c)==7:
    print(c+'=7')
    exit()