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):
from sys import stdin
N=(stdin.readline().rstrip())
N=list(N)
ans=""
for j in ["+","-"]:
    for k in ["+","-"]:
        for l in ["+","-"]:
            equ = N[0] + j + N[1] + k + N[2] + l + N[3]
            if eval(equ) == 7:
                ans = equ
print(ans+"=7")

Solution (Python):
T = int(input())
a = T//1000
b = (T % 1000)//100
c = (T % 100)//10
d = T % 10
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):
n = input()

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

    f = ""
    for pn, po in zip(n, ops + [""]):
        f += (pn + po)
    if eval(f) == 7:
        print(f + "=7")
        break

Solution (Python):
n = input()

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

    f = ""
    for pn, po in zip(n, ops + [""]):
        f += (pn + po)
    if eval(f) == 7:
        print(f + "=7")
        break

Solution (Python):
ABCD = input()
op ="+-"
for i in range(pow(2, 3)):
  v = i
  f = str(ABCD[0])
  for j in range(1,4):
    f += op[v%2] + ABCD[j]
    v //= 2
  if eval(f) == 7:
    print("{}=7".format(f))
    break

Solution (Python):
from itertools import product
import bisect
import sys


def input():
    return sys.stdin.readline()[:-1]









S = input()
for p in product(range(2), repeat=len(S)-1):
    tmp = ''
    for i in range(len(S)-1):
        if p[i] == 1:
            tmp += S[i]+'+'
        else:
            tmp += S[i]+'-'
    if eval(tmp+S[-1]) == 7:
        print(tmp+S[-1]+'=7')
        break

Solution (Python):
abcd = input()
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            s = abcd[0]+op1+abcd[1]+op2+abcd[2]+op3+abcd[3]
            if eval(s)==7:
                print(s+"=7")
                exit()

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')
        break

Solution (Python):
S = input().rstrip()
plus_minus = [1, -1]
A = int(S[0])
for i in plus_minus:
    B = i*int(S[1])
    for j in plus_minus:
        C = j*int(S[2])
        for k in plus_minus:
            D = k*int(S[3])
            total = A+B+C+D
            if total == 7:
                if B >= 0:
                    B = "+" + str(B)
                if C >= 0:
                    C = "+" + str(C)
                if D >= 0:
                    D = "+" + str(D)
                answer = str(A) + str(B) + str(C) + str(D) + "=7"
                print(answer)
                exit()

Solution (Python):




def calcChar(in_abcd, in_sum, in_idx):
    if in_idx < len(in_abcd):
        wsum = in_sum + in_abcd[in_idx]
        fnans = calcChar(in_abcd, wsum, in_idx + 1)
        
        if fnans[0] == 7:
            wans = list()
            wans.append(7)
            wans.append("+" + str(in_abcd[in_idx]) + fnans[1])
            return wans
        else:
            wsum = in_sum + in_abcd[in_idx] * (-1)
            fnans = calcChar(in_abcd, wsum, in_idx + 1)
            if fnans[0] == 7:
                wans = list()
                wans.append(7)
                wans.append("-" + str(in_abcd[in_idx]) + fnans[1])
                return wans
            else:
                return [-1, ""]
    else:
        wans = list()
        wans.append(in_sum)
        wans.append("=7")
        return wans


str_abcd = input()
abcd = list()
for i in range(4):
    abcd.append(int(str_abcd[i]))


ansl = calcChar(abcd, abcd[0], 1)
ans = str(abcd[0]) + ansl[1]


print(ans)

Solution (Python):
import sys
a = b = c = d = ""
def f(ab, bc, cd):
    return str(a) + ab + str(b) + bc + str(c) + cd + str(d)
if __name__ == '__main__':
    s = list(input())
    a, b, c, d = s[0], s[1], s[2], s[3]
    lst = [f('+', '+', '+'), f('+', '+', '-'), f('+', '-', '+'), f('-', '+', '+'), f('+', '-', '-'), f('-', '+', '-'), f('-', '-', '+'), f('-', '-', '-')]
    for expr in lst:
        if eval(expr) == 7:
            print(expr + "=7")
            sys.exit(0)

Solution (Python):

ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
ans  = str(A)
for ab in range(2):
    for bc in range(2):
        for cd in range(2):
            sum = A
            if ab:
                sum +=B
            else:
                sum -=B
            if bc:
                sum +=C
            else:
                sum -=C
            if cd:
                sum +=D
            else:
                sum -=D
            if sum == 7:
                A_B_C_D = ABCD[0] + str(ab) +ABCD[1]+ str(bc) +ABCD[2]+ str(cd) +ABCD[3]
                for i in range(1,6,2):
                    if int(A_B_C_D[i]):
                        ans += "+"
                    else:
                        ans += "-"
                    ans += A_B_C_D[i+1]
                break
        else:
            continue
        break
    else:
        continue
    break
    
print(ans + "=7")

Solution (Python):
from itertools import product
s = input()
for ops in product('+-', repeat=3):
	t = ''.join([a+b for a, b in zip(s, ops)])
	t += s[-1]
	if eval(t) == 7:
		print(t+'=7');exit()

Solution (Python):
from itertools import product
s = input()
for ops in product("+-", repeat=3):
    t = ''.join([a + b for a, b in zip([''] + list(ops), s)])
    if eval(t) == 7:
        print(t+"=7")
        exit()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

opr = ["+++","++-","+--","---","+-+","-++","--+","-+-"]

ABCD = list(input())
for op in opr:
	ans = []
	ABCD_ = ABCD.copy()
	op = list(op)
	ans.append(ABCD_.pop(0))
	while ABCD_ != []:
		ans.append(op.pop(0))
		ans.append(ABCD_.pop(0))
	if eval("".join(ans)) == 7:
		print("".join(ans), "=7", sep="")
		sys.exit(0)

Solution (Python):
s=input()
ans=7
for i in range(8):
  func=""
  num=str(bin(i))[2:]
  num=num.zfill(3)
  for j in range(3):
    func+=s[j]
    if num[j]=='1':
      func+="+"
    else:
      func+="-"
  func+=s[-1]
  if eval(func)==7:
    print(func+"=7")
    exit()

Solution (Python):
import itertools
n=input()
op=list(itertools.product(['+','-'],repeat=3))
l=list(n)
for i in op:
	tmp=n[0]+i[0]+n[1]+i[1]+n[2]+i[2]+n[3]
	if eval(tmp)==7:
		print(tmp+'=7')
		break

Solution (Python):
array = [int(i) for i in list(input())]
flag = False
fugou = ['+', '-']

for i in fugou:
	if i == '+':
		tmp = array[0] + array[1]
	else:
		tmp = array[0] - array[1]
	for j in fugou:
		if j == '+':
			tmp2 = tmp + array[2]
		else:
			tmp2 = tmp - array[2]
		for k in fugou:
			if k == '+':
				if tmp2 + array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3])
							+ '=7')
					flag = True
					break
			else:
				if tmp2 - array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3])
							+ '=7')
					flag = True
					break
		if flag: break
	if flag: break

Solution (Python):
from itertools import product
s = input()
for p in product(range(2),repeat=3):
    tmp = ''
    for i in range(len(s)-1):
        if p[i] == 0:
            tmp += s[i]+'+'
        else:
            tmp += s[i]+'-'
    if eval(tmp+s[-1]) == 7:
        print(tmp+s[-1]+'=7')
        exit()

Solution (Python):
S=input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            a=int(S[0])
            if i==0:
                a+=int(S[1])
            else:
                a-=int(S[1])
            if j==0:
                a+=int(S[2])
            else:
                a-=int(S[2])
            if k==0:
                a+=int(S[3])
            else:
                a-=int(S[3])
            if a==7:
                b=[i,j,k]
                break
st=S[0]
for l in range(3):
    if b[l]==0:
        st+="+"+S[l+1]
    else:
        st+="-"+S[l+1]
print(st+"=7")

Solution (Python):
s = input()

if eval(s[0] + '+' + s[1] + '+' + s[2] + '+' + s[3]) == 7:
    print(s[0] + '+' + s[1] + '+' + s[2] + '+' + s[3] + '=7') 
elif eval(s[0] + '+' + s[1] + '+' + s[2] + '-' + s[3]) == 7:
    print(s[0] + '+' + s[1] + '+' + s[2] + '-' + s[3] + '=7')
elif eval(s[0] + '+' + s[1] + '-' + s[2] + '+' + s[3]) == 7:
    print(s[0] + '+' + s[1] + '-' + s[2] + '+' + s[3] + '=7')
elif eval(s[0] + '+' + s[1] + '-' + s[2] + '-' + s[3]) == 7:
    print(s[0] + '+' + s[1] + '-' + s[2] + '-' + s[3] + '=7')
elif eval(s[0] + '-' + s[1] + '+' + s[2] + '+' + s[3]) == 7:
    print(s[0] + '-' + s[1] + '+' + s[2] + '+' + s[3] + '=7')
elif eval(s[0] + '-' + s[1] + '+' + s[2] + '-' + s[3]) == 7:
    print(s[0] + '-' + s[1] + '+' + s[2] + '-' + s[3] + '=7')
elif eval(s[0] + '-' + s[1] + '-' + s[2] + '+' + s[3]) == 7:
    print(s[0] + '-' + s[1] + '-' + s[2] + '+' + s[3] + '=7')
else:
    print(s[0] + '-' + s[1] + '-' + s[2] + '-' + s[3] + '=7')

Solution (Python):


lst = [int(c) for c in input()]


if lst[0]+lst[1]+lst[2]+lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'+'+str(lst[2])+'+'+str(lst[3])
elif lst[0]+lst[1]+lst[2]-lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'+'+str(lst[2])+'-'+str(lst[3])
elif lst[0]+lst[1]-lst[2]+lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'-'+str(lst[2])+'+'+str(lst[3])
elif lst[0]+lst[1]-lst[2]-lst[3] == 7:
  ans = str(lst[0])+'+'+str(lst[1])+'-'+str(lst[2])+'-'+str(lst[3])
elif lst[0]-lst[1]+lst[2]+lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'+'+str(lst[2])+'+'+str(lst[3])
elif lst[0]-lst[1]+lst[2]-lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'+'+str(lst[2])+'-'+str(lst[3])
elif lst[0]-lst[1]-lst[2]+lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'-'+str(lst[2])+'+'+str(lst[3])
elif lst[0]-lst[1]-lst[2]-lst[3] == 7:
  ans = str(lst[0])+'-'+str(lst[1])+'-'+str(lst[2])+'-'+str(lst[3])
  
ans = ans + '=7'
print(ans)

Solution (Python):


def main():
    I = [e for e in input()]
    N = [int(I[0]), int(I[1]), int(I[2]), int(I[3])]

    for i in range(2):
        for j in range(2):
            for k in range(2):
                sum = N[0]

                if i == 0:
                    sum += N[1]
                else:
                    sum -= N[1]

                if j == 0:
                    sum += N[2]
                else:
                    sum -= N[2]

                if k == 0:
                    sum += N[3]
                else:
                    sum -= N[3]

                if sum == 7:
                    res = "{}{}{}{}{}{}{}=7".format(
                            N[0],
                            "+" if i == 0 else "-",
                            N[1],
                            "+" if j == 0 else "-",
                            N[2],
                            "+" if k == 0 else "-",
                            N[3],
                            )
                    print(res)
                    return

main()

Solution (Python):
import sys
a = input()
l = ['+', '-']
for i in l:
  for j in l:
     for k in l:
        eq = a[0] + i + a[1] + j + a[2] + k + a[3] 
        if eval(eq) == 7:
          print(eq, '=7', sep='')
          sys.exit()

Solution (Python):
hoge=input()
a=int(hoge[0])
b=int(hoge[1])
c=int(hoge[2])
d=int(hoge[3])
f=0
for i in [-1,1]:
  for j in [-1,1]:
    for k in [-1,1]:
      if(a+i*b+j*c+k*d==7):
        if(i==1):
          x="+"
        else:
          x="-"
        if(j==1):
          y="+"
        else:
          y="-"
        if(k==1):
          z="+"
        else:
          z="-"
        if(f==0):
          print(str(a)+x+str(b)+y+str(c)+z+str(d)+"=7")
          f+=1

Solution (Python):
a = int(input())
b = list(str(a))
if len(b) == 3:
    b = b[::-1]
    b.append("0")
    b = b[::-1]
if int(b[0])+int(b[1])+int(b[2])+int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"+"+b[2]+"+"+b[3]+"=7")
elif int(b[0])-int(b[1])+int(b[2])+int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"+"+b[2]+"+"+b[3]+"=7")
elif int(b[0])+int(b[1])-int(b[2])+int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"-"+b[2]+"+"+b[3]+"=7")
elif int(b[0])+int(b[1])+int(b[2])-int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"+"+b[2]+"-"+b[3]+"=7")
elif int(b[0])-int(b[1])-int(b[2])+int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"-"+b[2]+"+"+b[3]+"=7")
elif int(b[0])-int(b[1])-int(b[2])-int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"-"+b[2]+"-"+b[3]+"=7")
elif int(b[0])-int(b[1])+int(b[2])-int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"+"+b[2]+"-"+b[3]+"=7")
elif int(b[0])+int(b[1])-int(b[2])-int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"-"+b[2]+"-"+b[3]+"=7")

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

e = []
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:    
                e.append([i,j,k])
ans = []
for i in e[0]:
    if i == -1:
        ans.append("-")
    else:
        ans.append("+")
print(str(a[0]) + ans[0] + str(a[1]) + ans[1] + str(a[2]) + ans[2] + str(a[3]) + "=7")

Solution (Python):
s = input()
if int(s[0]) + int(s[1]) + int(s[2]) + int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) - int(s[1]) + int(s[2]) + int(s[3]) == 7:
	print(s[0] + "-" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) + int(s[1]) - int(s[2]) + int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) + int(s[1]) + int(s[2]) - int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif int(s[0]) - int(s[1]) - int(s[2]) + int(s[3]) == 7:
	print(s[0] + "-" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif int(s[0]) - int(s[1]) + int(s[2]) - int(s[3]) == 7:
	print(s[0] + "-" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif int(s[0]) + int(s[1]) - int(s[2]) - int(s[3]) == 7:
	print(s[0] + "+" + s[1] + "-" + s[2] + "-" + s[3] + "=7")
else:
	print(s[0] + "-" + s[1] + "-" + s[2] + "-" + s[3] + "=7")

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

for i in range(len(ll)-1):
    ll.insert(i*2+1,"")

for i in range(8):
    for j in range(3):
        ins = "+" if ((i>>j) &1) else "-"
        ll[j*2+1] = ins
    ans = "".join(ll)
    if eval("".join(ll))==7:
        print(ans+"=7")
        break

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

for i in range(2 ** 3):
    p = S[0]
    for j in range(3):
        if ((i >> j) & 1):
            p -= S[j+1]
        else:
            p += S[j+1]
    if p == 7:
        ans = str(S[0])
        for j in range(3):
            if ((i >> j) & 1):
                ans += '-'+str(S[j+1])
            else:
                ans += '+'+str(S[j+1])
        ans += '=7'
        print(ans)
        break

Solution (Python):
import itertools
S=list(input())
l=['-','+']
L=list(itertools.product(l,repeat=len(S)-1))
ans=0
for i in range(2**(len(S)-1)):
    a = S[0]
    for j in range(len(S)-1):
        a+=L[i][j]+S[j+1]
    if eval(a)==7:
        print(a+'=7')
        break

Solution (Python):
l = ["" for i in range(7)]
ll = list(input())

for i in range(4):
    l[i*2] = ll[i]

flag = False
for i in range(2):
    if i==0:
        l[1] = '+'
    else:
        l[1] = '-'
    for ii in range(2):
        if ii==0:
            l[3] = '+'
        else:
            l[3] = '-'
        for iii in range(2):
            if iii==0:
                l[5] = '+'
            else:
                l[5] = '-'
            t = "".join(l)
            ans = eval(t)
            if ans==7:
                print(t+'=7')
                flag = True
                break
        if flag:
            break
    if flag:
        break

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

def p_or_m(a,b,op):
    if op==0:
        return a+b
    else:
        return a-b
      
out_list=[]

for op1 in range(2):
    out_1=p_or_m(A,B,op1)
    for op2 in range(2):
        out_2=p_or_m(out_1,C,op2)
        for op3 in range(2):
            out_3=p_or_m(out_2,D,op3)
            if out_3==7:
                out_list.append([op1,op2,op3,out_3])
                
out=out_list[0]

L=[B,C,D]
out_str=str(A)
for i in range(len(out)-1):
    if out[i]==0:
        out_str+='+'
    elif out[i]==1:
        out_str+='-'
    out_str+=str(L[i])
        
out_str+='=7'

print(out_str)

Solution (Python):
import itertools
ticket=input()
op=['+','-']
for o1,o2,o3 in itertools.product(op,repeat=3):
  express=ticket[0]+o1+ticket[1]+o2+ticket[2]+o3+ticket[3]
  if eval(express)==7:
    print(express+"=7")
    exit()

Solution (Python):
num=input()
for i in range(2**3):
    total=int(num[0])
    ans_str=str(num[0])
    for k in range(0,3):
        if (i>>k)&1:
            total+=int(num[k+1])
            ans_str+='+'+num[k+1]
        else:
            total-=int(num[k+1])
            ans_str+='-'+num[k+1]
    
    
    if total==7:
        ans_str+='=7'
        print(ans_str)
        break

Solution (Python):
OP = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"]
N = input()
for operation in OP:
    formula = N[0] + operation[0] + N[1] + operation[1] + N[2] + operation[2] + N[3]
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
input_2 = input()
import itertools
n = list(itertools.product([0,1], repeat=3))
for comb in n:
    result = int(input_2[0])
    for i,x in enumerate(comb):
        if x==0:
            result += int(input_2[i+1])
        else:
            result -= int(input_2[i+1])
    if result==7:
        print(input_2[0],str(comb[0]).replace("0","+").replace("1","-"),
              input_2[1],str(comb[1]).replace("0","+").replace("1","-"),
              input_2[2],str(comb[2]).replace("0","+").replace("1","-"),
              input_2[3],"=7",sep="")
        break

Solution (Python):
S = input()
ans = False
for bit in range(2**(len(S)-1)):
  s = ""
  for i in range(len(S)):
    s += S[i]
    if i<len(S)-1:
      if (bit>>i) & 1:
        s += "+"
      else:
        s += "-"
  ans = eval(s) == 7
  if ans:
    break
print(s+"=7")

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

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):
S = input()
ans = False
for bit in range(2**(len(S)-1)):
    s = ""
    for i in range(len(S)):
        s += S[i]
        if i<len(S)-1:
            if (bit>>i) & 1:
                s += "+"
            else:
                s += "-"
    ans = eval(s)==7
    if ans:
        break
print(s+"=7")

Solution (Python):
a=list(input())
c=0
def abcd(n,i,s):
    global c
    if i==3:
        if n==7 and c==0:
            print(s+"=7")
            c=1
    else:
        for j in range(2):
            if j==0:
                abcd(n+int(a[i+1]),i+1,s+"+"+a[i+1])
            else:
                abcd(n-int(a[i+1]),i+1,s+"-"+a[i+1])
abcd(int(a[0]),0,a[0])

Solution (Python):
S = input()

for i in range(8):
	t = ""
	for j in range(3):
		t += S[j] + ["+", "-"][not (1 & i >> j)]
	t += S[-1]
	if 7 == eval(t):
		print(t + "=7")
		break

Solution (Python):

N = input()
n = list(N)
for i in range(len(n)):
    n[i] = int(n[i])

if n[0] + n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] + n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}-{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] + n[1] - n[2] - n[3] == 7:
    print("{}+{}-{}-{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] + n[1] - n[2] + n[3] == 7:
    print("{}+{}-{}+{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] - n[1] + n[2] + n[3] == 7:
    print("{}-{}+{}+{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] - n[1] + n[2] - n[3] == 7:
    print("{}-{}+{}-{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] - n[1] - n[2] - n[3] == 7:
    print("{}-{}-{}-{}=7".format(n[0], n[1], n[2], n[3]))
elif n[0] - n[1] - n[2] + n[3] == 7:
    print("{}-{}-{}+{}=7".format(n[0], n[1], n[2], n[3]))

Solution (Python):
S = input()

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

Solution (Python):
import itertools
a = list(map(int, list(input())))
for op in itertools.product(["+","-"], repeat=3):
  ans = a[0]
  for i in range(3):
    if op[i] == "+":
      ans += a[i+1]
    else:
      ans -= a[i+1]
  if ans == 7:
    print("{}{}{}{}{}{}{}=7".format(a[0],op[0],a[1],op[1],a[2],op[2],a[3]))
    break

Solution (Python):
n = input()

for i in range(2 ** 3):
    i2 = bin(i)[2:].zfill(3)
    i3 = n[0]
    total = int(n[0])
    for j in range(3):
        if i2[j] == '1':
            
            total += int(n[j+1])
            i3 += '+'
        else:
            
            total -= int(n[j+1])
            i3 += '-'
        i3 += n[j+1]

    if total == 7:
        break

print(i3 + '=7')

Solution (Python):
a,b,c,d=input()
def solve():
    for i in ["+","-"]:
        for j in ["+","-"]:
            for k in ["+","-"]:
                ans = a+i+b+j+c+k+d
                if eval(ans) == 7:
                    return ans
print(solve()+"=7")

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

ansStr = ""

for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            ansNum = ABCD[0]
            if i == "+":
                ansNum += ABCD[1]  
            else:
                ansNum -= ABCD[1]
            if j == "+":
                ansNum += ABCD[2]  
            else:
                ansNum -= ABCD[2]
            if k == "+":
                ansNum += ABCD[3]  
            else:
                ansNum -= ABCD[3]
                
            
            if ansNum == 7:
                ansStr = str(ABCD[0]) + i + str(ABCD[1]) + j + str(ABCD[2]) + k + str(ABCD[3]) + "=7"
                break
print(ansStr)

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

L = [int(v) for v in list(input().strip())]

for v in itertools.product(["+", "-"], repeat = 3):
    s = ""
    for i in range(len(L) - 1):
        s += "{}{}".format(L[i], v[i])
        
    s += str(L[-1])
    if eval(s) == 7:
        print(s + "=7")
        sys.exit()

Solution (Python):
A=list(input())
for i in range(8):
  key=str(bin(i))[2:].zfill(3)
  s=A[0]
  for j in range(3):
    if key[j]=="0":
      s+="+"
    else:
      s+="-"
    s+=A[j+1]
  if eval(s)==7:
    print(s+"=7")
    break

Solution (Python):
abcd = input()


def dfs(s, idx):
  
  if len(s) == 7:
    if eval(s) == 7:
      s += "=7"
      print(s)
      exit()
    return
    
  
  dfs(s + "+" + abcd[idx], idx+1)
  dfs(s + "-" + abcd[idx], idx+1)
  
  
dfs(abcd[0], 1)

Solution (Python):
A =input()
pm = "+-"
ans = 0
for i in range(8):
    x = int(A[0])
    for j in range(3):
        if bin(i)[-(1+j)] == "1":
            x+=int(A[j+1])
        else:
            x-=int(A[j+1])
    if x == 7:
        ans = i
seven=A[0]
for j in range(3):
    if bin(ans)[-(1+j)] == "1":
        seven += "+"+A[j+1]
    else:
        seven += "-"+A[j+1]
print(seven+"=7")

Solution (Python):
s=[i for i in input()]
t=len(s)-1
tmp=2**t
ans=0
for i in range(tmp):
    p=bin(i)[2:]
    p="0"*(t-len(p))+p
    x=""
    for j,k in enumerate(s):
        x+=k
        if j!=t and p[j]=="1":
            x+="+"
        if j!=t and p[j]=="0":
            x+="-"
    if eval(x)==7:
        print(x+"=7")
        break

Solution (Python):
abcd = input()
a,b,c,d = int(abcd[0]),int(abcd[1]),int(abcd[2]),int(abcd[3])
op = ["+","-"]
def calc(op1,op2,op3):
    if op1 == "+":
        tmp = a + b
    else:
        tmp = a - b
    if op2 == "+":
        tmp += c
    else:
        tmp -= c
    if op3 == "+":
        tmp += d
    else:
        tmp -= d
    return tmp
def solve():
    for op1 in op:
        for op2 in op:
            for op3 in op:
                if calc(op1,op2,op3) == 7:
                    print("%d%s%d%s%d%s%d=7"%(a,op1,b,op2,c,op3,d))
                    return
solve()

Solution (Python):
S=input()
size = len(S)
pmlist = [format(i,'0'+str(size-1)+'b').replace('0','+').replace('1', '-') for i in range(2**(size-1))]
for pm in pmlist:
    eq = ''.join([S[i]+pm[i] for i in range(size-1)]+[S[size-1]])
    if eval(eq) == 7:
        break
print(eq+'=7')

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

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

try:
	for op1 in "+-":
		for op2 in "+-":
			for op3 in "+-":
				f = A+op1+B+op2+C+op3+D
				if eval(f) == 7:
					raise f
except:
	print(f + "=7")

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

if A+B+C+D == 7:
    print(str(A)+ "+" + str(B)+ "+" + str(C)+ "+" + str(D) + "=" + str(7))
elif A+B+C-D == 7:
    print(str(A)+ "+" + str(B)+ "+" + str(C)+ "-" + str(D) + "=" + str(7))
elif A+B-C+D == 7:
    print(str(A)+ "+" + str(B)+ "-" + str(C)+ "+" + str(D) + "=" + str(7))
elif A-B+C+D == 7:
    print(str(A)+ "-" + str(B)+ "+" + str(C)+ "+" + str(D) + "=" + str(7))
elif A+B-C-D == 7:
    print(str(A)+ "+" + str(B)+ "-" + str(C)+ "-" + str(D) + "=" + str(7))
elif A-B-C+D == 7:
    print(str(A)+ "-" + str(B)+ "-" + str(C)+ "+" + str(D) + "=" + str(7))
elif A-B+C-D == 7:
    print(str(A)+ "-" + str(B)+ "+" + str(C)+ "-" + str(D) + "=" + str(7))
elif A-B-C-D == 7:
    print(str(A)+ "-" + str(B)+ "-" + str(C)+ "-" + str(D) + "=" + str(7))

Solution (Python):
Num_list = list(map(int,list(input())))
ops = 3
Anser = 7


for i in range(2 ** ops):
  sum0 = Num_list[0]
  str0 = str(Num_list[0])
  k = 1

  for j in range(ops-1,-1,-1):
    if((i >> j) & 1):
      sum0 = sum0 + Num_list[k]
      str0 = str0 + '+' + str(Num_list[k])
      k = k + 1
    else:
      sum0 = sum0 - Num_list[k]
      str0 = str0 + '-' + str(Num_list[k])
      k = k + 1
  



  
  if(sum0 == Anser):
    print(str0 + '=7')
    break;

Solution (Python):
S = input()
L = [int(c) for c in S]
O = [1,-1]
sum = 0
N = 0

for i in O:
    for j in O:
        for k in O:
            if L[0] + i*L[1] + j*L[2] + k*L[3] == 7:
                print('{:}{:+}{:+}{:+}=7'.format(L[0],i*L[1],j*L[2],k*L[3]))
                exit()

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

B = [b, -b]
C = [c, -c]
D = [d, -d]

is_7 = False

for i_b in B:
    for i_c in C:
        for i_d in D:
            if a+i_b+i_c+i_d == 7:
                is_7 = True
                break
        if is_7:
            break
    if is_7:
        break
        
signs = []
for i in [i_b,i_c,i_d]:
    if i>=0:
        signs.append('+')
    else:
        signs.append('-')
        
print(str(a)
      +signs[0]
      +str(abs(i_b))
      +signs[1]
      +str(abs(i_c))
      +signs[2]
      +str(abs(i_d))
      +'=7')

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s =input()

    for op1 in ['+', '-']:
        for op2 in ['+', '-']:
            for op3 in ['+', '-']:
                if eval(s[0]+op1+s[1]+op2+s[2]+op3+s[3]) == 7:
                    print(s[0]+op1+s[1]+op2+s[2]+op3+s[3] +'=7')
                    return


solve()

Solution (Python):
S = input()

   
ans = 0
for i in range(2 ** (len(S)-1)):
    oparr = []
    for j in range(len(S)-1):
        if (i >> j) & 1:
            oparr.insert(0,"+")
        else:
            oparr.insert(0,"-")
    oparr.append("")
    tmp = ""
    for k in range(len(S)):
        tmp += S[k] + oparr[k]
    if eval(tmp) == 7:
        print(tmp + "=7")
        exit()

Solution (Python):
import numpy as np
import itertools

abcd = input()
abcd = np.array([int(i) for i in abcd])

ops = np.array([
    [1, op1, op2, op3] for op1, op2, op3
    in itertools.product([1, -1], [1, -1], [1, -1])])

op_ans = []
for op in ops:
    if np.dot(abcd, op)==7:
        op_ans = op
        
ans = str(abcd[0])
for dig, op in zip(abcd[1:], op_ans[1:]):
    ans += '+' if op>0 else '-'
    ans += str(dig)
ans += '=7'

print(ans)

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


ans = []

def dfs(a, b, c):
  if c == len(n)-1:
    if b == 7:
      ans.append(a + '=7')
    return
  dfs(a + '+' + S[c+1], b + n[c+1], c+1)
  dfs(a + '-' + S[c+1], b - n[c+1], c+1)
  
dfs(S[0], n[0], 0)

print(ans[0])

Solution (Python):


import sys
import itertools as it
import operator

if __name__ == "__main__":
    xs = [int(c) for c in input().strip()]
    ops = it.product([-1, 1], repeat=3)
    res = next(op for op in ops if 7 == (xs[0] + sum(map(operator.mul, xs[1:], op))))
    symbols = ["+" if i == 1 else "-" for i in res]
    iterable = filter(
        lambda x: x is not None,
        it.chain.from_iterable(
            it.zip_longest(map(str, xs), symbols)
        )
    )
    res = "".join(iterable) + "=7"
    print(res)

Solution (Python):
A,B,C,D = map(int,input())
pm = {1:"+",-1:"-"}
breakFlg = False
for i in (1,-1):
    for j in (1,-1):
        for k in (1,-1):
            if A+B*i+C*j+D*k == 7:
                print(str(A)+pm[i]+str(B)+pm[j]+str(C)+pm[k]+str(D)+"=7")
                breakFlg = True
                break
        if breakFlg:
            break
    if breakFlg:
        break