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):
N = list(input())
op = ['+','-']

for i in range(2):
    for j in range(2):
        for k in range(2):
                ans = 0
                if (op[i] == '+'):
                    ans = int(N[0]) + int(N[1])
                else:
                    ans = int(N[0]) - int(N[1])
                if (op[j] == '+'):
                    ans += int(N[2])
                else:
                    ans -= int(N[2])
                if (op[k] == '+'):
                    ans += int(N[3])
                else:
                    ans -= int(N[3])
                if (ans == 7):
                    print(N[0]+op[i]+N[1]+op[j]+N[2]+op[k]+N[3]+"=7")
                    quit()

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

for x in "+-":
	for y in "+-":
		for z in "+-":
			formula = a +x+ b +y+ c +z+ d
			if eval(formula) == 7:
				print(formula + "=7")
				exit()

Solution (Python):
inp = input()

for i in range(1<<4):
    ans = ''
    for j in range(len(inp)-1):
        if i & (1<<j):
            ans = ans+inp[j]+'+'
        else:
            ans = ans+inp[j]+'-'
    ans = ans+inp[-1]

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

Solution (Python):

S=input()
list1=[]
for i in range(4):
    list1.append(int(S[i]))


list2=[]
for j in range(8):
    k=j
    list2.append(int(k/4))
    k=j%4
    list2.append(int(k/2))
    k=j%2
    list2.append(int(k/1))
    
    
    if list2[0]==1:
        A=list1[0]+list1[1]
    else:
        A=list1[0]-list1[1]
    if list2[1]==1:
        A=A+list1[2]
    else:
        A=A-list1[2]
    if list2[2]==1:
        A=A+list1[3]
    else:
        A=A-list1[3]
    if A==7:
        list3=[]
        for a in range(3):
            if list2[a]==0:
                list3.append("-")
            else:
                list3.append("+")
        print(str(list1[0])+list3[0]+str(list1[1])+list3[1]+str(list1[2])+list3[2]+str(list1[3])+"=7")
        ans=1
        break
    list2=[]

Solution (Python):
def main():
    s=input()
    for i in ["+","-"]:
        for j in ["+","-"]:
            for k in ["+","-"]:
                b=s[0]+i+s[1]+j+s[2]+k+s[3]
                if eval(b)==7:
                    print(b+"=7")
                    return

main()

Solution (Python):

N = input()
A, B, C, D = N[0], N[1], N[2], N[3]

def fn(op1, op2, op3):
    msg = A + op1 + B + op2 + C + op3 + D
    if eval(msg) == 7:
        print(msg + "=7")
        exit()


for op1 in ("+","-"):
    for op2 in ("+","-"):
        for op3 in ("+","-"):
            fn(op1, op2, op3)

Solution (Python):
s = [int(x) for x in input()]
 
def f(c, n):
    if n == 4:
        if eval(c) == 7:
            return c + "=7"
        else:
            return None
    v = s[n]
    for o in ['+', '-']:
        ret = f('%s%s%d' % (c,o,v), n + 1)
        if ret:
            return ret
print(f(str(s[0]), 1))

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

s = sum(N)
op = ["+", "+", "+"]
def print_result(numbers, ops):
    print("{}{}{}{}{}{}{}=7".format(numbers[0], ops[0],
                                 numbers[1], ops[1],
                                 numbers[2], ops[2],
                                 numbers[3]))
        
if s == 7:
    print_result(N, op)
elif (N[0] - N[1] - N[2] - N[3]) == 7:
    print_result(N, ["-", "-", "-"])
else:
    d = (s - 7) / 2
    indexes = [i for i, x in enumerate(N) if x == d]
    if len(indexes) > 1:
        op[indexes[-1] - 1] = "-"
        print_result(N, op)
        exit()
    elif len(indexes) > 0 and (not indexes[0] == 0):
        op[indexes[0] - 1] = "-"
        print_result(N, op)
    else:
        if (N[0] - N[1] - N[2] + N[3]) == 7:
            print_result(N, ["-", "-", "+"])
        elif (N[0] - N[1] +  N[2] - N[3]) == 7:
            print_result(N, ["-", "+", "-"])
        else:
            print_result(N, ["+", "-", "-"])

Solution (Python):
N = input()
A, B, C, D = N[0], N[1], N[2], N[3]
def fn(op1, op2, op3):
    msg = A + op1 + B + op2 + C + op3 + D
    if eval(msg) == 7:
        print(msg + "=7")
        exit()

for op1 in ('+', '-'):
    for op2 in ('+', '-'):
        for op3 in ('+', '-'):
            fn(op1, op2, op3)

Solution (Python):
N = input()
A, B, C, D = N[0], N[1], N[2], N[3]
def fn(op1, op2, op3):
    msg = A + op1 + B + op2 + C + op3 + D
    if eval(msg) == 7:
        print(msg + "=7")
        exit()

for op1 in ('+', '-'):
    for op2 in ('+', '-'):
        for op3 in ('+', '-'):
            fn(op1, op2, op3)

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

import functools
@functools.lru_cache(maxsize=None)
def f(c, n):
    if n == 4:
        if c == 7:
            return []
        else:
            return None
    v = s[n]
    for o in ['+', '-']:
        ret = f(eval('%d%s%d'% (c,o,v)), n + 1)
        if ret is not None:
            return [o, v] + ret
print(''.join([str(x) for x in ([s[0]] + f(s[0], 1))]) + '=7')

Solution (Python):
a, b, c, d = [int(s) for s in input()]
ans = [str(a), '+', str(b), '+', str(c), '+', str(d), '=7']
for i in range(-1, 2, 2):
  for j in range(-1, 2, 2):
    for k in range(-1, 2, 2):
      if a + b * i + c * j + d * k == 7:
        ans[1] = '+' if i > 0 else '-'
        ans[3] = '+' if j > 0 else '-'
        ans[5] = '+' if k > 0 else '-'
print(''.join(ans))

Solution (Python):


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

    for i in range(2 ** 3):
        s = a
        ops = list('{:03b}'.format(i))
        for op, j in zip(ops, lists):
            if op == '0':
                s += j
            else:
                s -= j
        if s == 7:
            sen = str(a)
            for j, k in zip(lists, ops):
                if k == '0':
                    op1 = '+'
                else:
                    op1 = '-'
                sen = sen + op1 + str(j)
            print(sen + '=7')
            break

if __name__ == '__main__':
    main()

Solution (Python):
S = input()

def do_eval(s) :
    res = 0
    am_flg = 1
    
    for i in list(s): 
        if i == '+' :
            am_flg = 1
        elif i == '-' :
            am_flg = -1
        else :
            res += int(i) * am_flg
            
    return res    

A, B, C, D = list(S)[0], list(S)[1], list(S)[2], list(S)[3]
evaled = False 

for i in list('+-') :
    for j in list('+-') :
        for k in list('+-') :
            toeval = A + i + B + j + C + k + D
            
            if do_eval(toeval) == 7 :
                print(toeval + "=7")
                evaled = True
                break
        if evaled == True :
            break
    if evaled == True :
        break

Solution (Python):
from itertools import product
S = list(input())
S = [int(x) for x in S]
z = [0 for _ in range(3)]
for x in product(range(2), repeat = 3):
    y = S[0]
    for i in range(1,4):
        if x[i-1] == 0:
            y += S[i]
        else:
            y -= S[i]
    if y == 7:
        z = x
        break
ans = str(S[0])
for i in range(1,4):
    if z[i-1] == 0:
        ans += '+'
    else:
        ans += '-'
    ans += str(S[i])
ans += '=7'
print(ans)

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


for i in range(1 << 3):
    tmp = ary[0]
    ans = str(ary[0])
    for j in range(3):
        if i & (1 << j):
            tmp += ary[j + 1]
            ans += "+" + str(ary[j + 1])
        else:
            tmp -= ary[j + 1]
            ans += "-" + str(ary[j + 1])

    if tmp == 7:
        print(ans + '=7')
        break

Solution (Python):
abcd = input()
hugou = ["+","-"]
a,b,c,d = list(abcd)
for i in hugou:
    for j in hugou:
        for k in hugou:
            wa = a + i + b + j + c + k + d
            if eval(wa) == 7:
                print(str(wa)+'=7')
                exit()

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

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



if A+B+C+D ==7:
    ans = str(A),'+',str(B),'+',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A+B-C+D ==7:
    ans = str(A),'+',str(B),'-',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A+B+C-D ==7:
    ans = str(A),'+',str(B),'+',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B+C+D ==7:
    ans = str(A),'-',str(B),'+',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B-C+D ==7:
    ans = str(A),'-',str(B),'-',str(C),'+',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B+C-D ==7:
    ans = str(A),'-',str(B),'+',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
elif A+B-C-D ==7:
    ans = str(A),'+',str(B),'-',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))
elif A-B-C-D ==7:
    ans = str(A),'-',str(B),'-',str(C),'-',str(D),'=7'
    print(''.join(map(str, ans)))

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

tot=A
S=''
for bits in range(1<<3):
    if bits & 1:
        tot += B
        S += '+'
    else:
        tot -= B
        S += '-'
    if bits & 1<<1:
        tot += C
        S += '+'
    else:
        tot -= C
        S += '-'
    if bits & 1<<2:
        tot += D
        S += '+'
    else:
        tot -= D
        S += '-'
    if tot==7:
        print(str(A)+S[0]+str(B)+S[1]+str(C)+S[2]+str(D)+'=7')
        quit()
    else:
        S=''
        tot=A
        pass

Solution (Python):
flag = 1

def search(num, digit, res, op):
    global flag
    if digit == 4:
        if res == 7:
            op += "="
            ans = "".join(n+o for n,o in zip(num, op))
            if flag:
                print(ans + "7")
                flag = 0

    else:
        search(num, digit+1, res+int(num[digit]), op+"+")
        search(num, digit+1, res-int(num[digit]), op+"-")
        
num = input()
search(num,1,int(num)//1000,"")

Solution (Python):
e = input()
op = ("+", "-")
for i in range(8):
  t = ""
  for j in range(4):
    k = i>>j&1
    t += e[j]+op[k]
  t = t[:-1:]
  if eval(t)==7:
    print(t+"=7")
    break

Solution (Python):
o=["+","-"]
a,b,c,d=list(input())
for i in o:
    for j in o:
        for k in o:
            t=a+i+b+j+c+k+d
            if eval(t)==7:
                print(t+"=7")
                exit()

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

op1 = '+'
op2 = '+'
op3 = '+'

if a+b+c-d==7:
    op3 = '-'
elif a+b-c+d==7:
    op2 = '-'
elif a-b+c+d==7:
    op1 = '-'
elif a+b-c-d==7:
    op3 = '-'
    op2 = '-'
elif a-b+c-d==7:
    op3 = '-'
    op1 = '-'
elif a-b-c+d==7:
    op1 = '-'
    op2 = '-'
elif a-b-c-d==7:
    op3 = '-'
    op2 = '-'
    op1 = '-'

print(a,op1,b,op2,c,op3,d,"=7",sep='')

Solution (Python):
s = input()

n = 4

for i in range(2 ** (n-1)):
    formula = s[0]
    for j in range(n-1):
        if i >> j & 1 == 1:
            formula += '+{}'.format(s[j+1])
        else:
            formula += '-{}'.format(s[j+1])

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

Solution (Python):
A, B, C, D = map(int, input())
for i in range(8):
    sum = 0
    op1 = "+" if i // 4 % 2 == 0 else "-"
    op2 = "+" if i // 2 % 2 == 0 else "-"
    op3 = "+" if i % 2 == 0 else "-"
    if op1 == "+":
        sum = A + B
    else:
        sum = A - B
    if op2 == "+":
        sum += C
    else:
        sum -= C
    if op3 == "+":
        sum += D
    else:
        sum -= D
    if sum == 7:
        print(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7")
        break

Solution (Python):
s = input()

max = 2 ** 3

for i in range(max):
    b = bin(i)[2:].zfill(3)
    op = []
    test = int(s[0])
    for j, flag in enumerate(b):
        if flag == '1':
            test += int(s[j+1])
            op.append('+')
        else:
            test -= int(s[j+1])
            op.append('-')
    if test == 7:
        break

print(s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]+'=7')

Solution (Python):
S=input()
for i in range(8):
    s=S[0]+''.join('+-'[i>>j&1]+c for j,c in enumerate(S[1:]))
    if eval(s)==7:
        print(s+'=7')
        break

Solution (Python):
S=input()
for i in range(8):
    s=S[0:1]+''.join('+-'[i>>j&1]+c for j,c in enumerate(S[1:]))
    if eval(s)==7:
        print(s+'=7')
        break

Solution (Python):
S = input()

op = [0]*3
tmp = [0]*4
for i in range(2):
    tmp[0] = int(S[0])
    if i == 0:
        tmp[1] = int(S[1])
        op[0] = '+'
    else:
        tmp[1] = -int(S[1])
        op[0] = '-'
    for j in range(2):
        if j == 0:
            tmp[2] = int(S[2])
            op[1] = '+'
        else:
            tmp[2] = -int(S[2])
            op[1] = '-'
        for k in range(2):
            if k == 0:
                tmp[3] = int(S[3])
                op[2] = '+'
            else:
                tmp[3] = -int(S[3])
                op[2] = '-'
            if sum(tmp) == 7:
                print(S[0] + op[0] + S[1] + op[1] + S[2] + op[2] + S[3] + '=7')

                exit()

Solution (Python):
import itertools as it
s = input()
for p in it.product('+-',repeat=3):
    formula = ''.join([a+(b if b else '') for a,b in it.zip_longest(s,p)])
    if eval(formula) == 7:
        print(formula + '=7')
        exit()

Solution (Python):
import itertools
s = input()
for p in itertools.product('+-',repeat=3):
    formula = s[0]+p[0]+s[1]+p[1]+s[2]+p[2]+s[3]
    if eval(formula) == 7:
        print(formula + '=7')
        exit()

Solution (Python):
n = input()

a = ['+','-']
b = ''
for i in a:
    for j in a:
        for k in a:
            if eval(n[0]+i+n[1]+j+n[2]+k+n[3]) == 7:
                b =n[0]+i+n[1]+j+n[2]+k+n[3]+'=7'
                break
print(b)

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

ans = []

for i in range(8):
        isseven = 0
        ans = []
        if i < 4:
            isseven += (s[0] + s[1])
            ans.append('+')
        else:
            isseven += (s[0] - s[1])
            ans.append('-')
        if i % 4 == 0 or i % 4 == 1:
            isseven += s[2]
            ans.append('+')
        else:
            isseven -= s[2]
            ans.append('-')
        if i % 2 == 0:
            isseven += s[3]
            ans.append('+')
        else:
            isseven -= s[3]
            ans.append('-')
        if isseven == 7:
            break

for i in range(3):
    print(str(s[i]) + ans[i], end = '')

print(str(s[3]) + "=7")

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

def ope(i,a,b):
    if i == 0:
        return a + b
    elif i == 1:
        return a - b

def convert(i):
    if i == 0:
        return "+"
    elif i == 1:
        return "-"


def search(a,b,c,d):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                if ope(k,ope(j,ope(i,a,b),c),d) == 7:
                    return str(a) + convert(i) + str(b) + convert(j) + str(c) + convert(k) + str(d)

print(search(a,b,c,d)+"=7")

Solution (Python):
if __name__ == '__main__':
    num = input()
    num_list = [int(i) for i in str(num)]

    A = num_list[0]
    B = num_list[1]
    C = num_list[2]
    D = num_list[3]

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

Solution (Python):
def main():
	s = input()
	ans = ''
	ans = solve(s[0], s[1:])
	print(ans)

def solve(left, right):
	if len(right) == 0:
		if eval(left) == 7:
			print(left + '=7')
			exit()
	else:
		solve(left + '-' + right[0], right[1:])
		solve(left + '+' + right[0], right[1:])

if __name__ == '__main__':
	main()

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

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

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d-%d-%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)

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

A = X//1000
X%=1000
B= X//100
X%=100
C = X//10
X%=10
D = X
a=str(A)
b=str(B)
c=str(C)
d=str(D)

if A+B+C+D == 7:
    print(a+"+"+b+"+"+c+"+"+d+"=7")
elif A+B+C-D == 7:
    print(a+"+"+b+"+"+c+"-"+d+"=7")
elif A+B-C+D == 7:
    print(a+"+"+b+"-"+c+"+"+d+"=7")
elif A+B-C-D == 7:
    print(a+"+"+b+"-"+c+"-"+d+"=7")
elif A-B+C+D == 7:
    print(a+"-"+b+"+"+c+"+"+d+"=7")
elif A-B+C-D == 7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")
elif A-B-C+D == 7:
    print(a+"-"+b+"-"+c+"+"+d+"=7")
elif A-B-C-D == 7:
    print(a+"-"+b+"-"+c+"-"+d+"=7")

Solution (Python):
ABCD = input()

a = int(ABCD[0])
b = int(ABCD[1])
c = int(ABCD[2])
d = int(ABCD[3])

ans = ""
if (a + b + c + d) == 7:
    ans = "+++"
elif (a - b + c + d) == 7:
    ans = "-++"
elif (a + b - c + d) == 7:
    ans = "+-+"
elif (a + b + c - d) == 7:
    ans = "++-"
elif (a + b - c - d) == 7:
    ans = "+--"
elif (a - b + c - d) == 7:
    ans = "-+-"
elif (a - b - c + d) == 7:
    ans = "--+"
elif (a - b - c - d) == 7:
    ans = "---"

print(str(a)+ans[0]+str(b)+ans[1]+str(c)+ans[2]+str(d)+"=7")

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

a=N//1000
b=(N%1000)//100
c=(N%100)//10
d=N%10

ope=[-1,1]

for i in ope:
    for j in ope:
        for k in ope:
            if a+i*b+j*c+k*d==7:
                ans=[i,j,k]

l=[0]*3

for i in range(3):
    if ans[i]>0:
        l[i]="+"
    else:
        l[i]="-"

   


all_ans=str(a)+l[0]+str(b)+l[1]+str(c)+l[2]+str(d)+"=7"
print(all_ans)

Solution (Python):
S = input()

def calcfunc(s) :
    total = 0
    cond = 1

    for c in s :
        if c == "+" :
            cond = 1
        elif c == "-" :
            cond = -1
        else :
            total += cond * int(c)
            
    return total

res = "Nil"
def addinput(s, i) :
    global res
    
    if len(s) == 7 : 
        if calcfunc(s) == 7:
            res = s

    else :
        str_plus = s[:i] + "+" + s[i:]
        str_minus = s[:i] + "-" + s[i:]

        addinput(str_plus, i + 2)
        addinput(str_minus, i + 2)
    
addinput(S, 1)
print(res + "=7")

Solution (Python):
from itertools import product

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


def sign(x):
    if x == -1:
        return '-'
    else:
        return '+'


for i, j, k in product([-1, 1], [-1, 1], [-1, 1]):
    x = A + i * B + j * C + k * D
    if x == 7:
        print('{}{}{}{}{}{}{}=7'.format(A, sign(i), B, sign(j), C, sign(k), D))
        break

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

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

print(line)

Solution (Python):
I = input()
N = len(I)
ans = ""
for n in range(1 << (N-1)):
  A = I[0]
  for i in range(N-1):
    if n & (1 << i):
      A += "+" + I[i+1]
    else:
      A += "-" + I[i+1]
  if eval(A) == 7:
    ans = A + "=7"

print(ans)

Solution (Python):
s = input()

n = 4

for i in range(2 ** (n-1)):
    formula = s[0]
    for j in range(n-1):
        if i >> j & 1 == 1:
            formula += '+{}'.format(s[j+1])
        else:
            formula += '-{}'.format(s[j+1])

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

Solution (Python):
s = input()

n = 4

for i in range(2 ** (n-1)):
    formula = s[0]
    for j in range(n-1):
        if i >> j & 1 == 1:
            formula += '+{}'.format(s[j+1])
        else:
            formula += '-{}'.format(s[j+1])

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

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

Solution (Python):
i=int(input())
d=i%10
c=(i//10)%10
b=(i//100)%10
a=i//1000
if a+b+c+d==7:
    print(a,"+",b,"+",c,"+",d,"=7",sep="")
elif a+b+c-d==7:
    print(a,"+",b,"+",c,"-",d,"=7",sep="")
elif a+b-c+d==7:
    print(a,"+",b,"-",c,"+",d,"=7",sep="")
elif a+b-c-d==7:
    print(a,"+",b,"-",c,"-",d,"=7",sep="")
elif a-b+c+d==7:
    print(a,"-",b,"+",c,"+",d,"=7",sep="")
elif a-b+c-d==7:
    print(a,"-",b,"+",c,"-",d,"=7",sep="")
elif a-b-c+d==7:
    print(a,"-",b,"-",c,"+",d,"=7",sep="")
else:
    print(a,"-",b,"-",c,"-",d,"=7",sep="")

Solution (Python):
x=int(input())
dig=[]
for i in range(1,4):
  dig.append(x%(10))
  x=x//10
dig.append(x)

d,c,b,a=dig

if (a+b+c+d)==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a+b+c-d)==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a+b-c+d)==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a+b-c-d)==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif (a-b+c+d)==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a-b-c+d)==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a-b+c-d)==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a-b-c-d)==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

Solution (Python):
import time
import random
import math

def dfs(i, s):
    if (i == 4):
        if (eval(s) == 7): return s
        else: return ""
    
    b = dfs(i + 1, s + "+" + str(a[i]))
    c = dfs(i + 1, s + "-" + str(a[i]))
    if (b != ""): return b
    else: return c

a = input()
print(dfs(1, str(a[0])) + "=7")

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

Solution (Python):
ticket = input()


for i in range(1 << 3):
    s = ticket[0]
    for j in range(3):
        if (i>>j) & 1:
            s += '+' + ticket[j+1]
        else:
            s += '-' + ticket[j+1]
    if eval(s) == 7:
        print(s+'=7')
        exit()

Solution (Python):
num = raw_input()
numarray = list(num)
A = int(numarray[0])
B = int(numarray[1])
C = int(numarray[2])
D = int(numarray[3])
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = 0
            if i == 0:
                ans += A - B
                if j == 0:
                    ans -= C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
                else:
                    ans += C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
            else:
                ans += A + B
                if j == 0:
                    ans -= C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
                else:
                    ans += C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
            if ans == 7:
                if i == 0:
                    Si = "-"
                else:
                    Si = "+"
                if j == 0:
                    Sj = "-"
                else:
                    Sj = "+"
                if k == 0:
                    Sk = "-"
                else:
                    Sk = "+"
                print str(A) + Si +str(B) + Sj + str(C) + Sk + str(D) + "=7"
                break
        if ans == 7:
            break
    if ans == 7:
            break

Solution (Python):


import itertools

A, B, C, D = map(str, list(input()))


op_list = list(itertools.product(["+", "-"], repeat=3))

for op in op_list:
    
    if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
        print(A + op[0] + B + op[1] + C + op[2] + D + "=7")
        exit()

Solution (Python):


num_list = list(input())

if int(num_list[0]) + int(num_list[1]) + int(num_list[2]) + int(num_list[3]) == 7:
    print(num_list[0] + "+" + num_list[1] + "+" \
            + num_list[2] + "+" + num_list[3] + "=7")
elif int(num_list[0]) + int(num_list[1]) + int(num_list[2]) - int(num_list[3]) == 7:
    print(num_list[0] + "+" + num_list[1] + "+" \
            + num_list[2] + "-" + num_list[3] + "=7")
elif int(num_list[0]) + int(num_list[1]) - int(num_list[2]) + int(num_list[3]) == 7:
    print(num_list[0] + "+" + num_list[1] + "-" \
            + num_list[2] + "+" + num_list[3] + "=7")
elif int(num_list[0]) + int(num_list[1]) - int(num_list[2]) - int(num_list[3]) == 7:
    print(num_list[0] + "+" + num_list[1] + "-" \
            + num_list[2] + "-" + num_list[3] + "=7")
elif int(num_list[0]) - int(num_list[1]) + int(num_list[2]) + int(num_list[3]) == 7:
    print(num_list[0] + "-" + num_list[1] + "+" \
            + num_list[2] + "+" + num_list[3] + "=7")
elif int(num_list[0]) - int(num_list[1]) + int(num_list[2]) - int(num_list[3]) == 7:
    print(num_list[0] + "-" + num_list[1] + "+" \
            + num_list[2] + "-" + num_list[3] + "=7")
elif int(num_list[0]) - int(num_list[1]) - int(num_list[2]) + int(num_list[3]) == 7:
    print(num_list[0] + "-" + num_list[1] + "-" \
            + num_list[2] + "+" + num_list[3] + "=7")
elif int(num_list[0]) - int(num_list[1]) - int(num_list[2]) - int(num_list[3]) == 7:
    print(num_list[0] + "-" + num_list[1] + "-" \
            + num_list[2] + "-" + num_list[3] + "=7")

Solution (Python):
from itertools import product
A,B,C,D=input().strip()
ops="+-"
for op1,op2,op3 in product(ops,ops,ops):
    if eval(A+op1+B+op2+C+op3+D)==7:
        break
print(A+op1+B+op2+C+op3+D+'=7')

Solution (Python):
from itertools import product

s = input()
s2 = '{}'.join(s)

opss = product('+-', repeat=3)
lhss = (s2.format(*ops) for ops in opss)
eqs = (lhs+'=7' for lhs in lhss if eval(lhs)==7)
print(next(eqs))

Solution (Python):
import itertools

s = input()

for ops in itertools.product('+-', repeat=3):
    stmt = ''.join([s[0]] + [ops[i] + s[i+1] for i in range(3)])
    if eval(stmt) == 7:
        print(stmt+'=7')
        exit()

Solution (Python):
abcd = input()
ans = 0
ok = False
for i in range(2 ** 3):
	if not ok:
		p = "0" * (3 - len(bin(i)[2:])) + bin(i)[2:]
		equals = ""
		for index, num in enumerate(abcd):
			equals += num
			if index != (len(abcd) - 1) and p[index] == "1":
				equals += "+"
			if index != (len(abcd) - 1) and p[index] == "0":
				equals += "-"
		if eval(equals) == 7:
			ok = True
			print(equals + "=7")

Solution (Python):
s = input()

op = ['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            e = s[0] + op[i] + s[1] + op[j] + s[2] + op[k] + s[3]
            if eval(e) == 7:
                print(e + '=7')
                exit()

Solution (Python):
arr = map(int,list(raw_input()))

printed = False

def comb(strs,sums,i):
		global printed
		if i == 3 and sums == 7 and not printed: 
			print str(arr[0]) + strs[0] + str(arr[1]) + strs[1] + str(arr[2]) + strs[2] + str(arr[3]) + "=7"
			printed = True

		elif i < 3:
			comb(strs+'+',sums+arr[i+1],i+1)
			comb(strs+'-',sums-arr[i+1],i+1)



comb('',arr[0],0)

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

if A+B+C+D == 7:
    print("%s+%s+%s+%s=7" %(A,B,C,D))
elif A-B+C+D == 7:
    print("%s-%s+%s+%s=7" %(A,B,C,D))
elif A+B-C+D == 7:
    print("%s+%s-%s+%s=7" %(A,B,C,D))
elif A+B+C-D == 7:
    print("%s+%s+%s-%s=7" %(A,B,C,D))
elif A-B-C+D == 7:
    print("%s-%s-%s+%s=7" %(A,B,C,D))
elif A-B+C-D == 7:
    print("%s-%s+%s-%s=7" %(A,B,C,D))
elif A+B-C-D == 7:
    print("%s+%s-%s-%s=7" %(A,B,C,D))
elif A-B-C-D == 7:
    print("%s-%s-%s-%s=7" %(A,B,C,D))
else:
    print("No solution found.")

Solution (Python):
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	"""
	ビットマスクを用いた解法
	"""
	abcd = input()
	ans = 0
	for i in range(2 ** (len(abcd) - 1)):
		p = "0" * (len(abcd) - 1 - len(bin(i)[2:])) + bin(i)[2:]
		equals = ""
		for index, num in enumerate(abcd):
			equals += num
			if index != (len(abcd) - 1) and p[index] == "1": equals += "+"
			if index != (len(abcd) - 1) and p[index] == "0": equals += "-"
		if eval(equals) == 7:
			print(equals + "=7")
			exit()

if __name__ == '__main__':
	main()

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

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

fs = [add, sub]

for i in range(2):
    for j in range(2):
        for k in range(2):
            if fs[k](fs[j](fs[i](A, B), C), D) == 7:
                print(A, '+' if i == 0 else '-',
                      B, '+' if j == 0 else '-',
                      C, '+' if k == 0 else '-',
                      D, '=7', sep='')
                exit()

Solution (Python):
Nums = list(map(int, input()[:]))
op = ['+', '-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if Nums[0] + Nums[1] * (-1) ** i\
                    + Nums[2] * (-1) ** j + Nums[3] * (-1) ** k == 7:
                print('%d%s%d%s%d%s%d=7' % (Nums[0], op[i], Nums[1], op[j], Nums[2], op[k], Nums[3]))
                exit()