Problem:
 Score : 300 points    Problem Statement Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A , B , C and D in this order, each between 0 and 9 (inclusive).  In the formula A  op1  B  op2  C  op3  D  =  7 , replace each of the symbols op1 , op2 and op3 with + or - so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.      Constraints  0≤A,B,C,D≤9  All input values are integers.  It is guaranteed that there is a solution.         Input Input is given from Standard Input in the following format:  ABCD       Output Print the formula you made, including the part =7 .  Use the signs + and - .  Do not print a space between a digit and a sign.        Sample Input 1 1222      Sample Output 1 1+2+2+2=7  This is the only valid solution.       Sample Input 2 0290      Sample Output 2 0-2+9+0=7  0 - 2 + 9 - 0 = 7 is also a valid solution.       Sample Input 3 3242      Sample Output 3 3+2+4-2=7

Solution (Python):
import sys
def search(ans, i=0):
    if i == 3:
        if ans == 7:
            print('{0[0]}{1[0]}{0[1]}{1[1]}{0[2]}{1[2]}{0[3]}=7'.format(value,opr))
            sys.exit()
        return
    for j in range(3):
        ans -= int(value[i+1])
        opr.append('-')
        search(ans, i+1)
        ans += int(value[i+1])
        opr.pop(i)

        opr.append('+')
        ans += int(value[i+1])
        search(ans, i+1)
        ans -= int(value[i+1])
        opr.pop(i)
    return

value = input()
ans = int(value[0])
opr = []
search(ans)

Solution (Python):
s = list(raw_input())
n = len(s) - 1
for i in range(2**n):
    cmd = s[0]
    for j in range(n):
        if (i & (2**j)):
            cmd += "+"
        else:
            cmd += "-"
        cmd += s[j+1]
    if eval(cmd) == 7:
        print(cmd+"=7")
        break

Solution (Python):
mum = input()
a = int(mum[0])
b = int(mum[1])
c = int(mum[2])
d = int(mum[3])
ans = []
ans.append(a+b+c+d)
ans.append(a-b+c+d)
ans.append(a+b-c+d)
ans.append(a-b-c+d)
ans.append(a+b+c-d)
ans.append(a-b+c-d)
ans.append(a+b-c-d)
ans.append(a-b-c-d)

if ans[0] == 7:
	print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif ans[1] == 7:
	print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif ans[2] == 7:
	print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif ans[3] == 7:
	print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif ans[4] == 7:
	print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif ans[5] == 7:
	print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif ans[6] == 7:
	print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif ans[7] == 7:
	print('{}-{}-{}-{}=7'.format(a,b,c,d))

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

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

Solution (Python):
import sys
s = input()
for op1 in '+-':
    for op2 in '+-':
        for op3 in '+-':
            e = s[0]+op1+s[1]+op2+s[2]+op3+s[3]
            tmp = eval(e)
            if tmp == 7:
                print('%s=7'%e)
                sys.exit(0)

Solution (Python):
s=input()
for a in ['+','-']:
    for b in ['+','-']:
        for c in ['+','-']:
            str = s[0]+a+s[1]+b+s[2]+c+s[3]
            if eval(str)==7:
                ans = str
print(ans+'=7')

Solution (Python):
S = input()

for i in range(8):
    ops = list(format(i, "03b"))
    ret = int(S[0])
    ans = S[0]
    for j, op in enumerate(ops):
        if op == "0":
            ret += int(S[j + 1])
            ans += "+" + S[j + 1]
        else:
            ret -= int(S[j + 1])
            ans += "-" + S[j + 1]
    

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

Solution (Python):
import sys

ABCD = raw_input()

for op1 in "+-":
    for op2 in "+-":
        for op3 in "+-":
            e = ABCD[0] + op1 + ABCD[1] + op2 + ABCD[2] + op3 + ABCD[3]
            if eval(e) == 7:
                print e + "=7"
                sys.exit(0)

Solution (Python):



import numpy as np
li=np.array(list(map(int,list(input()))))
wa=[
   [1,1,1,1],
   [1,1,1,-1],
   [1,1,-1,1],
   [1,1,-1,-1],
   [1,-1,1,1],
   [1,-1,1,-1],
   [1,-1,-1,1],
   [1,-1,-1,-1],
   [-1,1,1,1],
   [-1,1,1,-1],
   [-1,1,-1,1],
   [-1,1,-1,-1],
   [-1,-1,1,1],
   [-1,-1,1,-1],
   [-1,-1,-1,1],
   [-1,-1,-1,-1],
  ]
wa=np.array(wa)
for w in wa:
  if np.dot(w,li)==7:
    isfirst=True
    for p,i in zip(w,range(4)):
        if isfirst:
            print(li[0],end='')
            isfirst=False
            continue
        if p >0:
            print('+',end=str(li[i]))
        else:
            print('-',end=str(li[i]))
    print('=7')
    quit()

Solution (Python):
op = ['+', '-']
s = input()

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

Solution (Python):
def solve():
    _ABCD = input()
    ABCD = []
    for i in _ABCD:
        ABCD.append(int(i))
    if ABCD[0] + ABCD[1] + ABCD[2] + ABCD[3] == 7:
        print(_ABCD[0]+"+"+_ABCD[1]+"+"+_ABCD[2]+"+"+_ABCD[3]+"=7")
    elif ABCD[0] + ABCD[1] + ABCD[2] - ABCD[3] == 7:
        print(_ABCD[0]+"+"+_ABCD[1]+"+"+_ABCD[2]+"-"+_ABCD[3]+"=7")
    elif ABCD[0] + ABCD[1] - ABCD[2] + ABCD[3] == 7:
        print(_ABCD[0]+"+"+_ABCD[1]+"-"+_ABCD[2]+"+"+_ABCD[3]+"=7")
    elif ABCD[0] + ABCD[1] - ABCD[2] - ABCD[3] == 7:
        print(_ABCD[0]+"+"+_ABCD[1]+"-"+_ABCD[2]+"-"+_ABCD[3]+"=7")
    elif ABCD[0] - ABCD[1] + ABCD[2] + ABCD[3] == 7:
        print(_ABCD[0]+"-"+_ABCD[1]+"+"+_ABCD[2]+"+"+_ABCD[3]+"=7")
    elif ABCD[0] - ABCD[1] + ABCD[2] - ABCD[3] == 7:
        print(_ABCD[0]+"-"+_ABCD[1]+"+"+_ABCD[2]+"-"+_ABCD[3]+"=7")
    elif ABCD[0] - ABCD[1] - ABCD[2] + ABCD[3] == 7:
        print(_ABCD[0]+"-"+_ABCD[1]+"-"+_ABCD[2]+"+"+_ABCD[3]+"=7")
    elif ABCD[0] - ABCD[1] - ABCD[2] - ABCD[3] == 7:
        print(_ABCD[0]+"-"+_ABCD[1]+"-"+_ABCD[2]+"-"+_ABCD[3]+"=7")

solve()

Solution (Python):


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

if a+b+c+d == 7:
    s = "{}+{}+{}+{}=7"
elif a+b+c-d == 7:
    s = "{}+{}+{}-{}=7"
elif a+b-c+d == 7:
    s = "{}+{}-{}+{}=7"
elif a+b-c-d == 7:
    s = "{}+{}-{}-{}=7"
elif a-b+c+d == 7:
    s = "{}-{}+{}+{}=7"
elif a-b+c-d == 7:
    s = "{}-{}+{}-{}=7"
elif a-b-c+d == 7:
    s = "{}-{}-{}+{}=7"
elif a-b-c-d == 7:
    s = "{}-{}-{}-{}=7"

print(s.format(a, b, c, d))

Solution (Python):
import itertools
N=[int(x) for x in input()]
op=['+','-']
for op1 in op:
  for op2 in op:
    for op3 in op:
      if op1=='+': ans=N[0]+N[1]
      else: ans=N[0]-N[1]
      if op2=='+': ans+=N[2]
      else: ans-=N[2]
      if op3=='+': ans+=N[3]
      else: ans-=N[3]
      if ans==7:
        print(N[0],end="")
        print(op1,end="")
        print(N[1],end="")
        print(op2,end="")
        print(N[2],end="")
        print(op3,end="")
        print(N[3],end="")
        print("=7")
        exit()

Solution (Python):

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

result = None

for i in [0,1]:
    tmp = A + B if i == 0 else A - B
    for j in [0,1]:
        tmp2 = tmp + C if j == 0 else tmp - C
        for k in [0,1]:
            tmp3 = tmp2 + D if k == 0 else tmp2 - D
            if tmp3 == 7:
                result = [i, j, k]



def f(i):
    if i == 0:
        return '+'
    else:
        return '-'


result = [f(x) for x in result]

print(str(A) + result[0] + str(B) + result[1] + str(C) + result[2] + str(D) + '=7')

Solution (Python):
import sys

x = input()

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

work = A
op1,op2,op3 = "","",""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 1:
                op1 = "+"
                work += B
            else:
                op1 = "-"
                work -= B
            if j == 1:
                op2 = "+"
                work += C
            else:
                op2 = "-"
                work -= C
            if k == 1:
                op3 = "+"
                work += D
            else:
                op3 = "-"
                work -= D
            if work ==7:
                print(x[0]+op1+x[1]+op2+x[2]+op3+x[3]+"=7")
                sys.exit()
            else:
                work = A

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

if int(A)+int(B)+int(C)+int(D) == 7:
	ans=A+'+'+B+'+'+C+'+'+D+'=7'
	print(ans)

elif int(A)+int(B)+int(C)-int(D) == 7:
	ans=A+'+'+B+'+'+C+'-'+D+'=7'
	print(ans)
	
elif int(A)+int(B)-int(C)+int(D) == 7:
	ans=A+'+'+B+'-'+C+'+'+D+'=7'
	print(ans)

elif int(A)+int(B)-int(C)-int(D) == 7:
	ans=A+'+'+B+'-'+C+'-'+D+'=7'
	print(ans)

elif int(A)-int(B)+int(C)+int(D) == 7:
	ans=A+'-'+B+'+'+C+'+'+D+'=7'
	print(ans)
	
elif int(A)-int(B)+int(C)-int(D) == 7:
	ans=A+'-'+B+'+'+C+'-'+D+'=7'
	print(ans)
	
elif int(A)-int(B)-int(C)+int(D) == 7:
	ans=A+'-'+B+'-'+C+'+'+D+'=7'
	print(ans)
	
elif int(A)-int(B)-int(C)-int(D) == 7:
	ans=A+'-'+B+'-'+C+'-'+D+'=7'
	print(ans)

Solution (Python):


import itertools

A,B,C,D = [int(i) for i in input()]
for ops in range(8):
    ops2 = []
    val = 0
    if ops%2 == 0:
        val = A+B
        ops2.append('+')
    else:
        val = A-B
        ops2.append('-')

    if (ops//2)%2 == 0:
        val += C
        ops2.append('+')
    else:
        val -= C
        ops2.append('-')

    if (ops//4)%2 == 0:
        val += D
        ops2.append('+')
    else:
        val -= D
        ops2.append('-')
    if val == 7:
        print(str(A)+ops2[0]+str(B)+ops2[1]+str(C)+ops2[2]+str(D)+'='+str(7))
        break

Solution (Python):
in_data = input().rstrip()
dic = {0:int(in_data[0])}
for i in range(3):
    n_dic = {}
    for item in dic.items():
        n_dic[item[0] + 2**i] = item[1] + int(in_data[i+1])
        n_dic[item[0]] = item[1] - int(in_data[i+1])
    dic = n_dic
    
for item in dic.items():
    if item[1] == 7:
        print(in_data[0], end='')
        num = item[0]
        for i in in_data[1:]:
            num, sign = num // 2, num % 2
            print("%s%s" % ("+" if sign==1 else "-", i), end="")
        break
print("=7")

Solution (Python):
p = input()
a = int(p[0])
b = int(p[1])
c = int(p[2])
d = int(p[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):


inp = list(raw_input())

a = int(inp[0])
b = int(inp[1])
c = int(inp[2])
d = int(inp[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):
from itertools import chain
op_list = ["+","-"]
s = input()

res=""
for i in range(8):
	op1 = op_list[i%2]
	op2 = op_list[i // 2 % 2]
	op3 = op_list[i // 4]
	expr = "".join(chain.from_iterable(zip(s,[op1, op2, op3, ""])))
	if eval(expr) == 7:
		res = expr + "=7"
		break

print(res)

Solution (Python):
S = input()
S_list=list(S)
A,B,C,D = int(S_list[0]),int(S_list[1]),int(S_list[2]),int(S_list[3])
res = ""

for i in range(8):
	ans = str(A)
	val = A
	if i & 1 == 1:
		ans += '+'
		val += B
	else:
		ans += '-'
		val -= B
	ans += str(B)
	if i & 2 == 2:
		ans += '+'
		val += C
	else:
		ans += '-'
		val -= C
	ans += str(C)
	if i & 4 == 4:
		ans += '+'
		val += D
	else:
		ans += '-'
		val -= D
	ans += str(D)
	ans += "=7"
	if val == 7:
		res = ans
		break;

print(res)

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

Solution (Python):
from itertools import chain
op_list = ["+", "-"]
s = input()
for i in range(8):
	op1 = op_list[i % 2]
	op2 = op_list[i // 2 % 2]
	op3 = op_list[i // 4]
	expr = "".join(chain.from_iterable(zip(s, [op1, op2, op3, ""])))
	if eval(expr) == 7:
		print(expr + "=7")
		quit()

Solution (Python):
n = input()

for i in range(0, 0b1000):
    num = int(n[0])
    op = []
    for j in range(3):
        if (i & 1 << j):
            num += int(n[j+1])
            op.append("+")
        else:
            num -= int(n[j+1])
            op.append("-")
    if num == 7:
        for k in range(3):
            print("{0}{1}".format(n[k], op[k]), end="")
        print("{0}=7".format(n[3]))
        break

Solution (Python):


N=int(input())
Num=[0]*4
A=N//1000
B=N//100%10
C=N//10%10
D=N%10

'''
for i in range(0, len(Num)):
    print(Num[i])
'''

Num.sort()
mul=[-1,1]

def ope(sym):
    if(sym==-1):
        return "-" 
    elif(sym==1):
        return "+"

def cal():
    for j in mul:
        for k in mul:
            for m in mul:
                if( A + B*j + C*k + D*m == 7 ):
                    
                    print(str(A)+ope(j)+str(B)+ope(k)+str(C)+ope(m)+str(D)+"=7")
                    return

cal()

Solution (Python):
N = input()

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

OP = ['+', '-']

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

Solution (Python):
inp = raw_input()
for i in xrange(8):
    ans = int(inp[0])
    ansStr = inp[0]
    a = bin(i)[2:].zfill(3)
    for j in xrange(3):
        buff = int(inp[j + 1]) * (-1 if(a[j] == "1")else 1)
        ans += buff
        ansStr += ("-"if(buff < 0)else "+") + inp[j + 1]
    
    if(ans == 7):
        print ansStr+"=7"
        break

Solution (Python):
A,B,C,D=map(int,list(input()))
o=["+","-"]
if A+B+C+D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[0],o[0])
elif A+B+C-D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[0],o[1])
elif A+B-C+D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[1],o[0])
elif A+B-C-D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[1],o[1])
elif A-B+C+D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[0],o[0])
elif A-B+C-D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[0],o[1])
elif A-B-C+D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[1],o[0])
elif A-B-C-D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[1],o[1])
strings=list(strings)
strings[0]=str(A)
strings[2]=str(B)
strings[4]=str(C)
strings[6]=str(D)
print("".join(strings))

Solution (Python):

def main():
    el = list(input())
    oplist = ["+", "-"]

    for op1 in oplist:
        for op2 in oplist:
            for op3 in oplist:
                q = "{}".join(el)
                q = q.format(op1, op2, op3)
                if eval(q) == 7:
                    print(q + "=7")
                    return 0

if __name__ == '__main__':
    main()

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



c1 = {'op1':'+', 'op2':'+', 'op3':'+'}
c2 = {'op1':'+', 'op2':'+', 'op3':'-'}
c3 = {'op1':'+', 'op2':'-', 'op3':'+'}
c4 = {'op1':'+', 'op2':'-', 'op3':'-'}
c5 = {'op1':'-', 'op2':'+', 'op3':'+'}
c6 = {'op1':'-', 'op2':'+', 'op3':'-'}
c7 = {'op1':'-', 'op2':'-', 'op3':'+'}
c8 = {'op1':'-', 'op2':'+', 'op3':'+'}

if A+B+C+D == 7:
    print(str(A) + c1['op1'] + str(B) + c1['op2'] + str(C) + c1['op3'] + str(D) + '=7')
elif A+B+C-D == 7:
    print(str(A) + c2['op1'] + str(B) + c2['op2'] + str(C) + c2['op3'] + str(D) + '=7')
elif A+B-C+D == 7:
    print(str(A) + c3['op1'] + str(B) + c3['op2'] + str(C) + c3['op3'] + str(D) + '=7')
elif A+B-C-D == 7:
    print(str(A) + c4['op1'] + str(B) + c4['op2'] + str(C) + c4['op3'] + str(D) + '=7')
elif A-B+C+D == 7:
    print(str(A) + c5['op1'] + str(B) + c5['op2'] + str(C) + c5['op3'] + str(D) + '=7')
elif A-B+C-D == 7:
    print(str(A) + c6['op1'] + str(B) + c6['op2'] + str(C) + c6['op3'] + str(D) + '=7')
elif A-B-C+D == 7:
    print(str(A) + c7['op1'] + str(B) + c7['op2'] + str(C) + c7['op3'] + str(D) + '=7')
elif A-B-C-D == 7:
    print(str(A) + c8['op1'] + str(B) + c8['op2'] + str(C) + c8['op3'] + str(D) + '=7')

Solution (Python):
lis = map(int,list(raw_input()))
outop = []
out = ""
for i in xrange(8):
	n2 = format(i,"03b")
	oplis = map(int,list(str(n2)))
	sum = lis[0]
	for num in xrange(3):
		if oplis[num] == 1:
			sum += lis[num+1]
		else:
			sum -= lis[num+1]
	if sum == 7:
		for op in oplis:
			if op == 1:
				outop.append("+")
			else:
				outop.append("-")
		print  "{0[0]}{1[0]}{0[1]}{1[1]}{0[2]}{1[2]}{0[3]}=7".format(lis,outop)
		break

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

Solution (Python):
def main():
    s=input()
    a=int(s[0])
    b=int(s[1])
    c=int(s[2])
    d=int(s[3])
    ansst=""
    def rec3(ans):
        if ans+d==7:
            ansst="+"+str(d)+"=7"
            return ansst
        if ans-d==7:
            ansst="-"+str(d)+"=7"
            return ansst
        return ""
    def rec2(ans):
        ansst=rec3(ans+c)
        if ansst:
            ansst="+"+str(c)+ansst
            return ansst
        ansst=rec3(ans-c)
        if ansst:
            ansst="-"+str(c)+ansst
            return ansst
        return ""

    def rec(ans):
        ansst=rec2(ans+b)
        if ansst:
            ansst=str(a)+"+"+str(b)+ansst
            return ansst
        ansst=rec2(ans-b)
        if rec2(ans-b):
            ansst=str(a)+"-"+str(b)+ansst
            return ansst
        return False
    print(rec(a))
    
if __name__=='__main__':
    main()

Solution (Python):

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

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)

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

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):
ABCD = input()
ABCD_list = [int(num_str) for num_str in str(ABCD)]

pm_pairs = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"]

for pm in pm_pairs:
    sum = ABCD_list[0]
    if pm[0] == "+":
        sum += ABCD_list[1]
    else:
        sum -= ABCD_list[1]

    if pm[1] == "+":
        sum += ABCD_list[2]
    else:
        sum -= ABCD_list[2]

    if pm[2] == "+":
        sum += ABCD_list[3]
    else:
        sum -= ABCD_list[3]

    if sum == 7:
        print(str(ABCD_list[0]) + pm[0] + str(ABCD_list[1]) + pm[1] +
              str(ABCD_list[2]) + pm[2] + str(ABCD_list[3]) + "=7")
        exit()

Solution (Python):
N=int(input())
a=N//1000
b=N//100 - 10*a
c=N//10 - 100*a -10*b
d=N%10
dic={0:"+",1:"-"}

s=a+b+c+d
for i in range(2):
    for j in range(2):
        for k in range(2):
            l=i*b+j*c+k*d
            if(s-2*l==7):
                ans=str(a)+dic[i]+str(b)+dic[j]+str(c)+dic[k]+str(d)+"=7"
print(ans)

Solution (Python):


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

if a+b+c+d == 7:
    s = "{}+{}+{}+{}=7"
elif a+b+c-d == 7:
    s = "{}+{}+{}-{}=7"
elif a+b-c+d == 7:
    s = "{}+{}-{}+{}=7"
elif a+b-c-d == 7:
    s = "{}+{}-{}-{}=7"
elif a-b+c+d == 7:
    s = "{}-{}+{}+{}=7"
elif a-b+c-d == 7:
    s = "{}-{}+{}-{}=7"
elif a-b-c+d == 7:
    s = "{}-{}-{}+{}=7"
elif a-b-c-d == 7:
    s = "{}-{}-{}-{}=7"

print(s.format(a, b, c, d))

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

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

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

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

o = [1, 1, 1]
o2 = []

for i in range(2):
    o[0] *= -1
    for j in range(2):
        o[1] *= -1
        for k in range(3):
            o[2] *= -1
            ans = int(abcd[0]) + int(abcd[1])*o[0] + int(abcd[2])*o[1] + int(abcd[3])*o[2]
            
            if ans == 7:
                for l in o:
                    if l > 0:
                        o2.append('+')
                    else:
                        o2.append('-')
                print(abcd[0] + o2[0] + abcd[1] + o2[1] + abcd[2] + o2[2] + abcd[3] + '=7')
                quit()

Solution (Python):
x = int(input())
a=b=c=0

for i in range(1,5):
    if i==1:
        d=x%10
    elif i==2:
        c=x%10
    elif i==3:
        b=x%10
    else:
        a=x%10

    x/=10
    x = int(x)




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):
x = int(input())
a=b=c=0

for i in range(1,5):
    if i==1:
        d=x%10
    elif i==2:
        c=x%10
    elif i==3:
        b=x%10
    else:
        a=x%10

    x/=10
    x = int(x)




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):

"""
https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

"""
import sys
from sys import stdin
from itertools import product
input = stdin.readline


def main(args):
    temp = input().strip()
    A = int(temp[0])
    B = int(temp[1])
    C = int(temp[2])
    D = int(temp[3])

    op1, op2, op3 = None, None, None
    exp = None
    for op1, op2, op3 in product('+-', repeat=3):
        exp = '{}{}{}{}{}{}{}'.format(A, op1, B, op2, C, op3, D)
        if eval(exp) == 7:
            break
    print(exp + '=7')


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
p = int(input())
a = p // 1000
b = (p // 100) % 10
c = (p // 10) % 10
d = p % 10


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()
listA=[0,0,0,0]
i=0
for x in s:
    listA[i]=int(x)
    i+=1
a=listA[0]
b=listA[1]
c=listA[2]
d=listA[3]
if(a+b+c+d==7):
    print("%d+%d+%d+%d=7"% (a,b,c,d))
elif(a+b+c-d==7):
    print("%d+%d+%d-%d=7"% (a,b,c,d))
elif(a+b-c+d==7):
    print("%d+%d-%d+%d=7" % (a, b, c, d))
elif(a+b-c-d==7):
    print("%d+%d-%d-%d=7" % (a, b, c, d))
elif(a-b+c+d==7):
    print("%d-%d+%d+%d=7" % (a, b, c, d))
elif(a-b-c+d==7):
    print("%d-%d-%d+%d=7" % (a, b, c, d))
elif(a-b-c-d==7):
    print("%d-%d-%d-%d=7" % (a, b, c, d))
elif(a-b+c-d==7):
    print("%d-%d+%d-%d=7" % (a, b, c, d))

Solution (Python):


Num =list(input())
ope = ["+", "-"]

for i in range(8):
    key = list(str(("{0:03b}".format(i,'b'))))
    formula = Num[0] + ope[int(key[0])] + Num[1] + ope[int(key[1])] + Num[2] + ope[int(key[2])] + Num[3]
    result = eval(formula)
    if(result == 7):
        print("".join([formula,"=7"]))
        break

Solution (Python):
ABCD = list(input())
 
def Calc(a,b,op):
    if op == "+":
        return int(a) + int(b)
    else:
        return int(a) - int(b)
 
ops = [["+","+","+"], ["+","+","-"], ["+","-","+"], ["-","+","+"],
       ["-","-","+"], ["-","+","-"], ["+","-","-"], ["-","-","-"]]
 
for op1, op2, op3 in ops:
    AB = Calc(ABCD[0],ABCD[1],op1)
    ABC = Calc(AB, ABCD[2], op2)
    ans = Calc(ABC, ABCD[3], op3)
 
    if ans == 7:
        print(ABCD[0]+op1+ABCD[1]+op2+ABCD[2]+op3+ABCD[3] + "=7")
        break

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:
                print("{0}{4}{1}{5}{2}{6}{3}=7".format(s[0],s[1],s[2],s[3],"-" if i else "+","-" if j else "+","-" if k else "+"))
                exit()

Solution (Python):
ABCD = input()


ABCD = list(map(int, list(ABCD)))

from operator import add, sub
import sys


def f(x):
    return "+" if x == add else "-"




for op1 in [add, sub]:
    for op2 in [add, sub]:
        for op3 in [add, sub]:
            s = op3(op2(op1(ABCD[0], ABCD[1]), ABCD[2]), ABCD[3])
            if s == 7:
                print("{}{}{}{}{}{}{}=7".format(
                    ABCD[0], f(op1), ABCD[1], f(op2), ABCD[2], f(op3), ABCD[3]))
                sys.exit(0)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = [int(c) for c in S()]
    for i in range(8):
        c = a[0]
        r = [a[0]]
        for j in range(3):
            if i&(2**j):
                c += a[j+1]
                r.append('+')
            else:
                c -= a[j+1]
                r.append('-')
            r.append(a[j+1])
        if c == 7:
            return ''.join(map(str,r)) + '=7'

    return -1



print(main())

Solution (Python):
import itertools

def find_eq(abcd):
    a,b,c,d = abcd
    ops = ['+', '-']
    for op1, op2, op3 in itertools.product(ops, repeat=3):
        eq = a + op1 + b + op2 + c + op3 + d
        if eval(eq) == 7:
            return eq + '=7'

print(find_eq(input()))

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