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):
x = input()
x = [int(i) for i in x]
xCount = len(x)

aaa = 0
for i in range(2**(xCount -1)):
    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(xCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    for i in range(xCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+' 
        
        if binaryNumber[i] == 0 :
            binaryNumber[i] = '-'
            
    
    result = [None]*(len(x)+len(binaryNumber))
    result[::2] = x
    result[1::2] = binaryNumber
    
    result = map(str, result)
    resultStr = ''.join(result)
    a = eval(resultStr)    
    
    
    if (a == 7) :
        print(str(resultStr) + '=7')
        break

Solution (Python):
import itertools
op = ["+", "-"]
s = input()
for i in itertools.product(op, repeat=3):
    t = 0
    t += int(s[0])
    t += int(s[1]) * (1 if i[0] == "+" else -1)
    t += int(s[2]) * (1 if i[1] == "+" else -1)
    t += int(s[3]) * (1 if i[2] == "+" else -1)
    if t == 7:
        print(s[0] + i[0] + s[1] + i[1] + s[2] + i[2] + s[3] + "=7")
        exit()

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

for bit in range(1<<n-1):
    t = ""
    for i in range(n-1):
        if bit & (1<<i):
            t += "+"
        else:
            t += "-"
        t += abcd[i+1]
    t = abcd[0] + t

    ans = 0
    if t[1] == "+":
        ans = int(t[0]) + int(t[2])
    else:
        ans = int(t[0]) - int(t[2])
    for j in range(3,len(t),2):
        if t[j] == "+":
            ans += int(t[j+1])
        else:
            ans -= int(t[j+1])
    if ans == 7:
        print(t+"=7")
        exit()

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(str(a+i+b+j+c+k+d)+'=7') 
                exit()

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(str(a+i+b+j+c+k+d)+'=7')
                exit()

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

for i in range(2<<3):
    ans = a[0]
    st = str(a[0])
    for j in range(3):
        if (i>>j)&1 == 1:
            ans += a[j+1]
            st += "+"+str(a[j+1])
        else:
            ans += -a[j+1]
            st += "-"+str(a[j+1])
    if ans == 7:
        print(st+"=7")
        break

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

for i in range(2<<3):
    ans = a[0]
    st = str(a[0])
    for j in range(3):
        if (i>>j)&1 == 1:
            ans += a[j+1]
            st += "+"+str(a[j+1])
        else:
            ans += -a[j+1]
            st += "-"+str(a[j+1])
    if ans == 7:
        print(st+"=7")
        break

Solution (Python):


a,b,c,d = list(str(input()))

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

Solution (Python):
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
b2 = -b
c2 = -c
list_b = [b,b2]
list_c = [c,c2]
def op (n):
    if n >= 0:
        return '+'
    else:
        return '-'

for i in list_b:
    for j in list_c:
        d2 = 7 - a - i - j
        if a + i + j + d2 == 7 and abs(d2) == d:
            b_ans = i
            c_ans = j
            d_ans = d2
            print(str(a)+op(b_ans)+str(b)+op(c_ans)+str(c)+op(d_ans)+str(d)+'=7' )
            exit()

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((a+i+b+j+c+k+d)+'=7')
        exit()

Solution (Python):
def main():
    S = input()
    cur = [[int(S[0]), S[0]]]
    for i in range(1, len(S)):
        temp = []
        for v, s in cur:
            temp.append([v+int(S[i]), s+"+"+S[i]])
            temp.append([v-int(S[i]), s+"-"+S[i]])
        cur = temp
    for v, s in cur:
        if v == 7:
            return s + "=7"

if __name__ == '__main__':
    print(main())

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

def calc(n, op, m):
  if(type(n) is not int):
    return False
  if(op == "+"):
    return n + m
  elif(op == "-"):
    return n - m
  elif(op == "*"):
    return n * m
  elif(m != 0):
    return n / m
  else:
    return False

ops1 = ["/", "+", "-", "*"]
ops2 = ["/", "+", "-", "*" ]
ops3 = ["/", "+", "-", "*" ]
for op1 in ops1:
  for op2 in ops2:
    for op3 in ops3:
      if(calc(calc(calc(a,op1,b),op2,c),op3,d) == 7):
        print(a,op1,b,op2,c,op3,d,"=7", sep="")
        exit()

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[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

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

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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()
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('=',end=''),print(7)
  exit()

Solution (Python):
from itertools import product
l=input()
a,b,c,d=int(l[0]),int(l[1]),int(l[2]),int(l[3])
p=list(product(range(2),repeat=3))
for i in range(8):
    t=a
    if p[i][0]==1:
        t+=b
    else:
        t-=b
    if p[i][1]==1:
        t+=c
    else:
        t-=c
    if p[i][2]==1:
        t+=d
    else:
        t-=d
    if t==7:
        A=p[i]
        break
print("{}{}{}{}{}{}{}=7".format(a,"+" if A[0]==1 else "-",b,"+" if A[1]==1 else "-",c,"+" if A[2]==1 else "-",d))

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

for i in range(8):
    calc=a
    B=bin(i)[2:].zfill(3)
    calc=calc+b if B[0]=="0" else calc-b
    calc=calc+c if B[1]=="0" else calc-c
    calc=calc+d if B[2]=="0" else calc-d
    if calc==7:
        break

Operator=["+" if i=="0" else "-" for i in B]
Operator.append("=7")
ans=""
for num, op in zip(inp, Operator):
    ans+=num
    ans+=op
print(ans)

Solution (Python):
abcd = input()

def dfs(i, s, sum):
    if i == 3:
        if sum == 7:
            print(s + "=7")
            exit()

    else:
        dfs(i+1, s + "+" + abcd[i+1], sum + int(abcd[i+1]))
        dfs(i+1, s + "-" + abcd[i+1], sum - int(abcd[i+1]))

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

Solution (Python):
import itertools


def main():
    s = list(input())
    op = list(itertools.product(['+', '-'], repeat=3))
    for i in op:
        formula = s[0]
        for index, j in enumerate(i):
            formula += j
            formula += s[index + 1]
        if eval(formula) == 7:
            print(formula + "=7")
            return
    return


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
num = []
for c in s:
    num.append(int(c))

ans = ["","","","="]
for i in range(8):
    temp = format(i,"b").zfill(3)
    su = num[0]
    
    for j in range(3):
        if temp[j] == "1":
            su += num[j+1]
            ans[j] = "+"
        else:
            su-=num[j+1]
            ans[j] = "-"
    if su == 7:
        break

buf=str(num[0])
for i in range(3):
    buf+=ans[i]
    buf+=str(num[i+1])
buf+=ans[-1]
buf+="7"
print(buf)

Solution (Python):

A, B, C, D = list(input())
op = ['+', '-']

for i in op:
    for j in op:
        for k in op:
            str = A + i + B + j + C + k + D
            ans = eval(str)
            if ans == 7:
                print(str + '=7')
                exit()

Solution (Python):
x=input()
y=[[int(x[i]),-int(x[i])] for i in range(4)]
for a in range(2):
    for b in range(2):
        for c in range(2):
            if y[0][0]+y[1][a]+y[2][b]+y[3][c]==7:
                ans=[x[0],"-" if a else "+",x[1],"-" if b else "+",x[2],"-" if c else "+",x[3]]
                break
print("".join(ans)+"=7")

Solution (Python):



a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]


is_ok = False

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - d
            if work_3 == 7:
                is_ok = True
                op_list = [op1, op2, op3]
                break
        if is_ok:
            break
    if is_ok:
        break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)

Solution (Python):
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
  
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

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

Solution (Python):
li = input()
for bit in range(1 << 3):
    f = li[0]

    for i in range(3):
        if bit & (1 << i):
            f += "+"
        else:
            f += "-"
        f += li[i+1]

        if i == 2:
            ans = int(f[0])
            for i in range(6):
                if f[i] == "+":
                    ans += int(f[i+1])
                elif f[i] == "-":
                    ans -= int(f[i+1])
            if ans == 7:
                print(f + "=7")
                exit()

Solution (Python):
S = input().rstrip()
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            func = S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3]
            if eval(func) == 7:
                print(func + '=7')
                exit()

Solution (Python):
S = input().rstrip()
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            res = 0
            try:
                func = S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3]
                res = eval(func)
            except:
                pass
            if res == 7:
                print(func + '=7')
                exit()

Solution (Python):
def dfs(i,SUM):
	if i == 3:
		return SUM == 7
	if dfs(i+1,SUM+L[i+1]):
		ops[i] = "+"
		return True
	if dfs(i+1,SUM-L[i+1]):
		ops[i] = "-"
		return True

	return False

L = list(map(int, input()))
k = 7

ops= [0]*3

dfs(0,L[0])

ans = []
for i in range(4):
	if i <= 2:
		ans.append(str(L[i]))
		ans.append(ops[i])
	if i == 3:
		ans.append(str(L[i]))
		ans.append("=7")

print("".join(ans))

Solution (Python):
import sys
INPUT = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()
    l = len(S)

    for i in range(2 ** (l - 1)):
        tmp = S[0]
        for j in range(l - 1):
            if (i >> j) & 1: tmp += "+"
            else: tmp += "-"
            tmp += S[j + 1]

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


if __name__ == '__main__':
    main()

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):
a,b,c,d=input()
for i in "+-":
	for j in "+-":
		for k in "+-":
			s=a+i+b+j+c+k+d
			if eval(s)==7:
				print(s+"=7")
				exit()

Solution (Python):
s=input()
a=[]
count=0
minus=0
for i in range(len(s)):
  if(minus==1):
    minus=0
    continue

  if(s[i]=="-"):
    a.append(int("-"+s[i+1]))
    minus=1
  else:
    a.append(int(s[i]))

for i in [1,-1]:
  for j in [1,-1]:
    for k in [1,-1]:
      if(a[0] + a[1]*i + a[2]*j + a[3]*k == 7):
        if(i==1):
          i_2="+"
        else:
          i_2="-"
        if(j==1):
          j_2="+"
        else:
          j_2="-"
        if(k==1):
          k_2="+"
        else:
          k_2="-"

        print(str(a[0])+i_2+str(a[1])+j_2+str(a[2])+k_2+str(a[3])+"=7")
        exit()

Solution (Python):
import sys

s = input()

reslt_sum = 0

for bit in range(1<<len(s)-1):
    temp_sum = ''
    for i in range(len(s)):
        temp_sum += s[i]
        if bit & (1<<i):
            temp_sum += '-'
        elif i != len(s)-1:
            temp_sum += '+'
    if eval(temp_sum) == 7:
        print(temp_sum,'=7',sep='')
        sys.exit()

Solution (Python):
numbers =input()
total = 0
for i in range(2**3):
    total = int(numbers[0])
    string = '{0}'.format(numbers[0])
    for j in range(3):
        if i & 2**j:
            total += int(numbers[j+1])
            string += '+{0}'.format(numbers[j+1])
        else:
            total -= int(numbers[j+1])
            string += '-{0}'.format(numbers[j+1])
    if total == 7:
        string += '=7'
        print(string)
        exit(0)

Solution (Python):
import sys
a,b,c,d = map(int,input())
ans = 7 - a
li = ['+','-']
for i in li:
    for j in li:
        for k in li:
            bb = b if i=='+' else -b
            cc = c if j=='+' else -c
            dd = d if k=='+' else -d
            if bb+cc+dd == ans:
                print(str(a)+i+str(b)+j+str(c)+k+str(d)+'=7')
                sys.exit()

Solution (Python):
a,b,c,d=map(int,list(input()))
l=("+","-")
for q in range(2):
  for w in range(2):
    for e in range(2):
      if a+((-1)**q)*b+((-1)**w)*c+((-1)**e)*d==7:
        print(str(a)+l[q]+str(b)+l[w]+str(c)+l[e]+str(d)+"=7")
        exit()

Solution (Python):

from itertools import product


def main():
    a, b, c, d = input()
    for x, y, z in product(("+", "-"), repeat=3):
        eq = a + x + b + y + c + z + d
        if eval(eq) == 7:
            print(eq + "=7")
            break


if __name__ == "__main__":
    main()

Solution (Python):
S=input()
A=[]
B=[0]*4
for i in range(len(S)):
    A.append(int(S[i]))

122

for i in range(2):
    for j in range(2):
        for k in range(2):
            total=A[0]
            if i==0:
                total+=A[1]
                B[0]='+'
            if i==1:
                total-=A[1]
                B[0] = '-'
            if j==0:
                total+=A[2]
                B[1] = '+'
            if j==1:
                total-=A[2]
                B[1] = '-'
            if k==0:
                total+=A[3]
                B[2] = '+'
            if k==1:
                total-=A[3]
                B[2] = '-'
            if total==7:
                print(S[0]+B[0]+S[1]+B[1]+S[2]+B[2]+S[3]+'=7')
                exit(0)

Solution (Python):
def main():
    ary = [str(i) for i in input()]
    make(ary)



def make(ary):
    moto = ['+','-']

    for i in moto:
        for j in moto:
            for k in moto:
                    pat = ary[0] + i + ary[1] + j + ary[2] + k + ary[3]
                    result = eval(pat)
                    if result == 7:
                        print(pat + '=' + str(result))
                        return 



if __name__ == '__main__':
    main()

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


def s(sign):
    return "+" if sign == 1 else "-"


for i in (1, -1):
    for j in (1, -1):
        for k in (1, -1):
            if A + i * B + j * C + k * D == 7:
                print("{}{}{}{}{}{}{}=7".format(A, s(i), B, s(j), C, s(k), D))
                exit()

Solution (Python):
N = input()
n = list(map(int,list(N)))
for i in range(1<<3):
    cal = n[0]
    s = []
    for j in range(3):
        if i%2 == 0:
            cal += n[j+1]
            s.append("+")
        else:
            cal -= n[j+1]
            s.append("-")
        i = i//2
    if cal == 7:
        print(N[0]+s[0]+N[1]+s[1]+N[2]+s[2]+N[3]+"=7")
        break

Solution (Python):
ABCD = input()
result = 0

output=[]

for i in range(4):
    output += "+"
    output += ABCD[i]
output = ''.join(output)


for i in range(4**2): 
    result = output 
    for j in range (4):
        if( (i>>j) & 1 ):
            result = list(result)
            result[j*2] = "-"
            result = ''.join(result)
    
    
    if eval(result)==7:
        if(result[0]=="+"):
            print(result[1:]+"=7")
            exit()

Solution (Python):
ABCD=input()
A,B,C,D=int(ABCD[0]),int(ABCD[1]),int(ABCD[2]),int(ABCD[3])

l={'+++':A+B+C+D,
   '++-':A+B+C-D,
   '+--':A+B-C-D,
   '+-+':A+B-C+D,
   '-++':A-B+C+D,
   '-+-':A-B+C-D,
   '--+':A-B-C+D,
   '---':A-B-C-D}

for key,value in l.items():
    if value==7:
        print(str(A)+key[0]+str(B)+key[1]+str(C)+key[2]+str(D)+'=7')
        break

Solution (Python):
A = [int(v) for v in input()]

flag = False
for i in range(2):
  if flag:
    break
  total = A[0]
  if i == 0:
    total += A[1]
  else:
    total -= A[1]
  for j in range(2):
    if flag:
      break
    total2 = total
    if j == 0:
      total2 += A[2]
    else:
      total2 -= A[2]
    for k in range(2):
      total3 = total2
      if k == 0:
        total3 += A[3]
      else:
        total3 -= A[3]
      if total3 == 7:
        print(A[0], end='')
        if i == 0:
          print('+{}'.format(A[1]), end='')
        else:
          print('-{}'.format(A[1]), end='')
        if j == 0:
          print('+{}'.format(A[2]), end='')
        else:
          print('-{}'.format(A[2]), end='')
        if k == 0:
          print('+{}=7'.format(A[3]))
        else:
          print('-{}=7'.format(A[3]))
        flag = True
        break

Solution (Python):
ABCD = list(input())
p_m = []
for i in range(2 ** 3):
    tmp = bin(i)[2::]
    while len(tmp) < 3:
        tmp = "0" + tmp
    p_m.append(tmp)

for i in p_m:
    sum = int(ABCD[0])
    cnt = 1
    plusminus = []
    for j in i:
        
        if j == "1":
            sum += int(ABCD[cnt])
            plusminus.append("+")
        else:
            sum -= int(ABCD[cnt])
            plusminus.append("-")
        cnt += 1
    if sum == 7:
        for i in range(3):
            print(ABCD[i], end = "")
            print(plusminus[i], end = "")
        print(ABCD[3] + "=7")
        break

Solution (Python):
abcd = list(map(int, list(input())))

output = False

def calc_abcd(s):
    global output
    global abcd
    sum = abcd[0]
    for i in range(3):
        if s[i] == "+":
            sum += abcd[i+1]
        else:
            sum -= abcd[i+1]
    if sum == 7:
        result = str(abcd[0])+s[0]+str(abcd[1])+s[1]+str(abcd[2])+s[2]+str(abcd[3])+"=7"
        print(result)
        output = True


def dfs(s):
    global output
    if len(s) == 3:
        if not output:
            calc_abcd(s)
            return 0
        else:
            return 0
    dfs(s+"+")
    dfs(s+"-")
    return 0

dfs("")

Solution (Python):
def fnc(i, num):
    if i == 4:
        if num == 7:
            return True
        else:
            return False
    
    if fnc(i+1, num + n[i]):
        st.insert(1, "+" + str(n[i]))
        return True
    
    if fnc(i+1, num - n[i]):
        st.insert(1, "-" + str(n[i]))
        return True

n = list(map(int, input()))
st = [str(n[0]), "=7"]
fnc(1, n[0])
print(''.join(st))

Solution (Python):
import sys
s=input()
opt = ["+","-"]
for opt1 in opt:
    for opt2 in opt:
        for opt3 in opt:
            equation = s[0]+opt1+s[1]+opt2+s[2]+opt3+s[3]
            if  eval(equation) == 7:
                print(equation+"=7")
                sys.exit()

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

Solution (Python):
nums = list(input())
def dfs(res, depth, path, S):
    if depth >= len(S) - 1:
        res.append(path)
        return 
    for char in ['+', '-']:
        dfs(res, depth+1, path+[char], S)

res = []
dfs(res, 0, [], nums)

for comb in res:
    calc = int(nums[0]) 
    string = nums[0]
    for i, func in enumerate(comb):
        if func == '+':
            string += '+' + nums[i+1]
            calc += int(nums[i+1])
        elif func == '-':
            string += '-' + nums[i+1]
            calc -= int(nums[i+1])
    if calc == 7:
        break

print(string+'=7')

Solution (Python):
S = list(input())
A = S[0]
B = S[1]
C = S[2]
D = S[3]


for i in range(2):
  for j in range(2):
    for k in range(2):
      total = int(A) + (-1) ** i * int(B) + (-1) ** j * int(C) + (-1) ** k * int(D)
      if total == 7:
        op1 = "+" if i == 0 else "-"          
        op2 = "+" if j == 0 else "-"          
        op3 = "+" if k == 0 else "-"          

ans = A + op1 + B + op2 + C + op3 + D + "=7"

print(ans)

Solution (Python):
ABCD = input()

for i in range(1,2**3):
    X = ABCD[0]
    for j in range(3):
        if 1 << j & i:
            X += '+'
        else:
            X += '-'
        X += ABCD[j+1]
    
    if eval(X) == 7:
        print(X+'=7')
        break

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

op = ['-', '+']

for i in range(2 ** 3):
    s = A + op[i & 1] + B + op[(i >> 1) & 1] + C + op[(i >> 2) & 1] + D
    if eval(s) == 7:
        print(s+'=7')
        exit()

Solution (Python):

num=input()
for i in range(0,8):
    t=[]
    k=i
    for j in range(0,3):
        if k>=2**(2-j):
            k=k-2**(2-j)
            t.append("+")
        else:
            t.append("-")
    a=int(num[0])
    for j in range(0,3):
        if t[j]=="+":
            a+=int(num[j+1])
        else:
            a-=int(num[j+1])
    if a==7:
        print(num[0]+t[0]+num[1]+t[1]+num[2]+t[2]+num[3]+"=7")
        break

Solution (Python):
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
for i in range(8):
	if bin(i)[-1]=="1":
		x="+"
		p=a+b
	else: 
		x="-"
		p=a-b
	if bin(i)[-2]=="1":
		y="+"
		p+=c
	else:
		y="-"
		p-=c
	if bin(i)[-3]=="1":
		z="+"
		p+=d
	else:
		z="-"
		p-=d
	if p==7:
		print(str(a)+x+str(b)+y+\
			str(c)+z+str(d)+"="+str(7))
		break

Solution (Python):
import sys
input=sys.stdin.readline

s = input().strip()
op = ["+","-"]
for i in op:
    for j in op:
        for k in op:
            x = s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(x) == 7:
                print(x+"=7")
                exit()

Solution (Python):
S = input()

ans = ''
def dfs(i, s):
    val = sum([int(s[i*2:i*2+2]) for i in range(len(s)//2)])
    if (i == 4) and (val==7):
        global ans
        ans = s
        return True
    
    if (i==4) and (val!=7):
        return False
    
    if dfs(i+1, s + '+' + S[i]):
        return True
    
    if dfs(i+1, s + '-' + S[i]):
        return True

dfs(0, '')
print(ans[1:] + '=7')

Solution (Python):
ABCD = input()

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

o1 = '+'
o2 = '+'
o3 = '+'
flag = False
for j in range(2) :
    if j % 2 == 0 :
        B2 = -B
        o2 = '-'
    else :
        B2 = B
        o2 = '+'
    for k in range(2) :
        if k % 2 == 0 :
            C2 = -C
            o3 = '-'
        else :
            C2 = C
            o3 = '+'
        for l in range(2) :
            if l % 2 == 0 :
                D2 = -D
                o4 = '-'
            else :
                D2 = D
                o4 = '+'
            if A+B2+C2+D2 == 7 :
                
                flag = True
                break
        if flag :
            break
    if flag :
        break
ans = str(A) + o2 + str(B) + o3 + str(C) + o4 + str(D) + '=7'
print(ans)

Solution (Python):
L = list(raw_input())
for bit in range(1 << 3):
    P = [""] * 4
    for k in range(3):
        if bit & (1 << k):
            P[k] = "+"
        else:
            P[k] = "-"
    calc = ""
    for i in range(4):
        calc += L[i] + P[i]
    if eval(calc) == 7:
        ans = calc + "=7"
        break
print(ans)

Solution (Python):
import itertools
op = ["+", "-"]
s = input()
for i in itertools.product(op, repeat=3):
    sm = int(s[0])
    st = s[0]
    for j, v in enumerate(i):
        if v == "+":
            sm += int(s[j+1])
            st += v
            st += s[j+1]
        else:
            sm -= int(s[j+1])
            st += v
            st += s[j+1]
    if sm == 7:
        print(st + "=7")
        exit()

Solution (Python):
L = list(input())
for bit in range(1 << 3) :
    P = [""]*4
    for k in range(3) :
        if bit & (1 << k) :
            P[k] = "+"
        else :
            P[k] = "-"
    calc = ""
    for i in range(4) :
        calc += L[i] + P[i]
    if eval(calc) == 7 :
        ans = calc + "=7"
        break
print(ans)

Solution (Python):
n = list(raw_input())
operators = ["+", "-"]
total = None
for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            total = n[0] + op1 + n[1] + op2 + n[2] + op3 + n[3]
            if eval(total) == 7:
                total = total + "=7"
                print(total)
                exit(0)

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

count = a
for i in range(8):
    a = int(s[0])
    for j in range(3):
        if i>>j&1 == 1:
            a += int(s[j+1])
        else:
            a -= int(s[j+1])
    if a == 7:
        ans = (str(bin(i))[2:]).zfill(3)
        ans = ans.replace("0","-")
        ans = ans.replace("1","+")
        print(str(s[0])+ans[2]+str(b)+ans[1]+str(c)+ans[0]+str(d)+"=7")
        break

Solution (Python):
A = input()
for i in range(0,2**3):
	X = [0]*3
	for k in range(3):
		if (i>>k)&1:
			X[k] = "+"
		else:
			X[k] = "-"
	if eval(A[0]+X[0]+A[1]+X[1]+A[2]+X[2]+A[3]) == 7:
		print(A[0]+X[0]+A[1]+X[1]+A[2]+X[2]+A[3]+"=7")
		break

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

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()

Solution (Python):
n = list(map(int,input().rstrip()))
for i in range(2**3):
  ope = ["-"] * 3
  ans = n[0]
  for j in range(3):
    if (i >> j) & 1:
      ope[j] = "+"
      ans += n[j+1]
    else:
      ans -= n[j+1]
  if ans == 7:
    res = [ope[i]+str(n[1+i]) for i in range(3)]
    res = "".join(res)
    res = str(n[0]) + res + "=7"
    print(res)
    break

Solution (Python):
n = list(map(int,input().rstrip()))
for i in range(2**3):
  ope = []
  ans = n[0]
  for j in range(3):
    if (i >> j) & 1:
      ope.append("+")
      ans += n[j+1]
    else:
      ope.append("-")
      ans -= n[j+1]
  if ans == 7:
    res = [ope[i]+str(n[1+i]) for i in range(3)]
    res = "".join(res)
    res = str(n[0]) + res + "=7"
    print(res)
    break

Solution (Python):
n = list(map(int,input().rstrip()))
for i in range(2**3):
  ope = []
  ans = n[0]
  for j in range(3):
    if (i >> j) & 1:
      ope.append("+")
      ans += n[j+1]
    else:
      ope.append("-")
      ans -= n[j+1]
  if ans == 7:
    res = [ope[i]+str(n[1+i]) for i in range(3)]
    res = "".join(res)
    res = str(n[0]) + res + "=7"
    print(res)
    break

Solution (Python):
nums = input()
for i in range(2**3):
  binary=format(i, 'b').zfill(5)[2:]
  val = int(nums[0])
  val_str = nums[0]
  for j in range(1,len(nums)):
    if binary[j-1] == '1':
      val += int(nums[j])
      val_str += '+'+nums[j]
    else:
      val -= int(nums[j])
      val_str += '-'+nums[j]
  if val==7:
    print(val_str,'=7',sep='')
    break

Solution (Python):

m = [1,-1]
def solve():
    a,b,c,d = list(map(int,list(input())))
    for i in m:
        for j in m:
            for k in m:
                if a + b * i + c * j + d * k == 7:
                    a,b,c,d = list(map(str,(a,b,c,d)))
                    i,j,k = list(map(lambda x:"+" if x==1 else "-",(i,j,k)))
                    print(a+i+b+j+c+k+d+"=7")
                    return
solve()

Solution (Python):


S = input()
bin_list = [0, 0, 0]
for i in range(8):
    bin_list = [0, 0, 0]
    now = i
    
    for x in range(3):
        amari = now % 2
        now = now // 2
        if amari == 1:
            bin_list[x] = "+"
        else:
            bin_list[x] = "-"
    formula = S[0] + bin_list[0] + S[1] + bin_list[1] + S[2] + bin_list[2] + S[3]
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
s = input()
s8=[]

def cal(p,n):
	if n==0:
		s8.append(p)
	else:
		cal(p[:n] + '+' + p[n:],n-1)
		cal(p[:n] + '-' + p[n:],n-1)

cal(s,len(s)-1)
for ss in s8:
	if eval(ss)==7:
		print(ss+'=7')
		exit()

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

def ope(i):
    if i == 0:
        return "+"
    else:
        return "-"

for i in range(2):
    if output != "":
        break
    for j in range(2):
        if output != "":
            break
        for k in range(2):
            result = a
            if i == 0:
                result += b
            else:
                result -= b
            if j == 0:
                result += c
            else:
                result -= c
            if k == 0:
                result += d
            else:
                result -= d
            if result == 7:
                output = "{}{}{}{}{}{}{}=7".format(a, ope(i), b, ope(j), c, ope(k), d)
                break

print(output)

Solution (Python):
i = input()

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])
sa=i[0]
sb=i[1]
sc=i[2]
sd=i[3]

if(a+b+c+d==7):
    print(sa+"+"+sb+"+"+sc+"+"+sd+"=7")
elif (a+b+c-d==7):
    print(sa+"+"+sb+"+"+sc+"-"+sd+"=7")
elif (a+b-c+d==7):
    print(sa+"+"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c+d==7):
    print(sa+"-"+sb+"+"+sc+"+"+sd+"=7")
elif(a-b-c+d==7):
    print(sa+"-"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c-d==7):
    print(sa+"-"+sb+"+"+sc+"-"+sd+"=7")
elif(a+b-c-d==7):
    print(sa+"+"+sb+"-"+sc+"-"+sd+"=7")
elif(a-b-c-d==7):
    print(sa+"-"+sb+"-"+sc+"-"+sd+"=7")