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):
p = str(input())

q =list(str(p))
r = []

for i in range(len(q)):
    r.append(int(q[i]))

a = r[0]
b = [-r[1],r[1]]
c = [-r[2],r[2]]
d = [-r[3],r[3]]

e = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a + b[i] + c[j] + d[k] == 7:
                e.append(a)
                e.append(b[i])
                e.append(c[j])
                e.append(d[k])

for i in range(len(e)):
    if e[i] < 0 or i == 0:
        e[i] = str(e[i])
    else:
        e[i] = '+' + str(e[i])
        
print(e[0] + e[1] + e[2] + e[3] + '=7')

Solution (Python):
import sys



def plus_or_minus(opr1, opr2, op):
    if op == '+':
        return opr1 + opr2
    else:
        return opr1 - opr2


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

op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            o2 = plus_or_minus(A, B, op[i])
            o3 = plus_or_minus(o2, C, op[j])
            o4 = plus_or_minus(o3, D, op[k])
            if o4 == 7:
                print('{}{}{}{}{}{}{}=7'.format(A, op[i], B, op[j], C, op[k], D))
                sys.exit()

Solution (Python):
S = input()
OPs =["+++","++-","+-+","+--","-++","-+-","--+","---"]
for op in OPs:
    if eval(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]) == 7:
        print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+"=7")
        break

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

Solution (Python):
from itertools import product

def solve(a, b, c, d):
    for ops in product('+-', repeat=3):
        op = a + ops[0] + b + ops[1] + c + ops[2] + d
        if eval(op) == 7:
            return op + '=7'


if __name__ == '__main__':
    a, b, c, d = input()
    print(solve(a, b, c, d))

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

Solution (Python):
flag = False
s = list(input())
candidate = []
op = '+-'
for i in op:
    for j in op:
        for k in op:
            candidate = s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(candidate)==7:
                print(candidate+'=7')
                flag = True
                break
        if flag:
            break
    if flag:
        break

Solution (Python):





if __name__ == '__main__':
    numbers = list(input())
    a = numbers[0]
    b = numbers[1]
    c = numbers[2]
    d = numbers[3]
    
    
    
    ops = ['+', '-']

    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                expression = a + op1 + b + op2 + c + op3 + d
                
                if eval(expression) == 7:
                    print(expression + '=7')
                    exit()

Solution (Python):





if __name__ == '__main__':
    numbers = list(map(int, list(input())))
    result = '=7'
    a = numbers[0]
    b = numbers[1]
    c = numbers[2]
    d = numbers[3]
    total = 7

    
    if a + b + c + d == total:
        print(str(a) + '+' + str(b) + '+' + str(c) + '+' + str(d) + result)
    elif a + b + c - d == total:
        print(str(a) + '+' + str(b) + '+' + str(c) + '-' + str(d) + result)
    elif a + b - c + d == total:
        print(str(a) + '+' + str(b) + '-' + str(c) + '+' + str(d) + result)
    elif a + b - c - d == total:
        print(str(a) + '+' + str(b) + '-' + str(c) + '-' + str(d) + result)
    elif a - b + c + d == total:
        print(str(a) + '-' + str(b) + '+' + str(c) + '+' + str(d) + result)
    elif a - b + c - d == total:
        print(str(a) + '-' + str(b) + '+' + str(c) + '-' + str(d) + result)
    elif a - b - c + d == total:
        print(str(a) + '-' + str(b) + '-' + str(c) + '+' + str(d) + result)
    elif a - b - c - d == total:
        print(str(a) + '-' + str(b) + '-' + str(c) + '-' + str(d) + result)

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


s = input()
bitlist = []
for i in range(2**(len(s)-1)):
    bitlist.append([int(x) for x in list(bin(i)[2::].zfill(len(s)-1))])
for bit in bitlist:
    formula = s[0]
    ans = int(s[0])
    for i, sign in enumerate(bit):
        if sign == 0:
            formula += '+'
            ans += int(s[i+1])
        else:
            formula += '-'
            ans -= int(s[i+1])
        formula += s[i+1]
    
    
    if ans == 7:
        print(formula + '=7')
        break

Solution (Python):
def c_train_ticket(N):
    A, B, C, D = map(int, N)
    
    
    operator = ['---', '--+', '-+-', '-++', '+--', '+-+', '++-', '+++']

    ans = ''
    for i, op in enumerate(operator):
        code = 'A {0} B {1} C {2} D'.format(op[0], op[1], op[2])
        if eval(code) == 7:
            ans = '{0}{1}{2}{3}{4}{5}{6}=7'.format(
                A, op[0], B, op[1], C, op[2], D)
            break  
    return ans

N = input()
print(c_train_ticket(N))

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

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

Solution (Python):
S = input()
ans = 0
for i in range(8):
    tmp = S[0]
    for j in range(3):
        if i & (1<<j):
            tmp += "-"
        else:
            tmp += "+"
        tmp += S[j+1]
    if eval(tmp) == 7:
        print(tmp+"=7")
        break

Solution (Python):
a, b, c, d = map(int, 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):
a=list(input())
for i in range(8):
    s=a[0]
    for j in range(3):
        if i&(1<<j):
            s+="+"
        else:
            s+="-"
        s+=a[j+1]
    if eval(s)==7:
        print(s+"=7")
        exit()

Solution (Python):
a, b, c, d = map(int, list(input()))
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            f = '{}{}{}{}{}{}{}'.format(a, op1, b, op2, c, op3, d)
            if eval(f) == 7:
                print('{}=7'.format(f))
                exit()

Solution (Python):
abcd = list(input())
for x in range(2):
    for y in range(2):
        for z in range(2):
            op1 = '+'
            if x == 0:
                op1 = '-'
            op2 = '+'
            if y == 0:
                op2 = '-'
            op3 = '+'
            if z == 0:
                op3 = '-'
            s = str(abcd[0]) + op1 + str(abcd[1]) + op2 + str(abcd[2]) + op3 + str(abcd[3])
            if eval(s) == 7:
                print(s + '=7')
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):


A, B, C, D = map(int, input())
for f in [('{}'*7).format(A, x, B, y, C, z, D)
          for x in '+-'
          for y in '+-'
          for z in '+-']:
    if eval(f) == 7:
        print('{}=7'.format(f))
        break

Solution (Python):
a,b,c,d=map(str,list(input()))
x,y,z=" "," "," "
cou=0
for i in range(1<<3):
    
    if i&1: x="+"
    else: x="-"
    if i&2: y="+"
    else: y="-"
    if i&4: z="+"
    else: z="-"
    
    if eval(a+x+b+y+c+z+d)==7:
        print(a+x+b+y+c+z+d+"=7")
        break
    cou+=1
if cou==8:
    print("No")

Solution (Python):
def f(x):
    if x == -1:
        return '-'
    else:
        return '+'
a, b, c, d = [int(i) for i in list(input())]
list = [-1, 1]
ans = []
for i in list:
    for j in list:
        for k in list:
                if a + i*b + j*c + k*d == 7:
                    print('{}{}{}{}{}{}{}=7'.format(a, f(i), b, f(j), c, f(k), d))
                    exit()

Solution (Python):
S=input()
a=int(S[0])
b=int(S[1])
c=int(S[2])
d=int(S[3])
def operation(a,b,t):    
    if t==0:return a+b
    else:return a-b
def converter(t):
    if t==0:return "+"
    else:return "-"
e=0
f=0
g=0
for x in range(2):
    for y in range(2):
        for z in range(2):
            e=operation(a,b,x)
            f=operation(e,c,y)
            g=operation(f,d,z)
            if g==7:
                print(str(a)+converter(x)+str(b)+converter(y)+str(c)+converter(z)+str(d)+"=7")
                exit()

Solution (Python):

import itertools


def find_combination(a):
    for indices in itertools.product(range(2), repeat=3):
        count = a[0]
        for i in range(3):
            if indices[i] == 0:
                count += a[i+1]
            else:
                count -= a[i+1]
            if count == 7:
                return indices
    return None


if __name__ == '__main__':
    a = [int(i) for i in input()]
    indices = find_combination(a)
    result = str(a[0])
    for i in range(3):
        if indices[i] == 0:
            result += '+'
        else:
            result += '-'
        result += str(a[i+1])
    print(result + '=7')

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a = list(ns())
s = []
for i in ["+", "-"]:
    for j in ["+", "-"]:
        for k in ["+", "-"]:
            s.append(a[0] + i + a[1] + j + a[2] + k + a[3])

ans = 0
for i in range(len(s)):
    if s[i][1] == "+" and s[i][3] == "+" and s[i][5] == "+":
        ans = int(s[i][0]) + int(s[i][2]) + int(s[i][4]) + int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "+" +str(s[i][2]) + "+" +str(s[i][4]) + "+" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "+" and s[i][3] == "+" and s[i][5] == "-":
        ans = int(s[i][0]) + int(s[i][2]) + int(s[i][4]) - int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "+" +str(s[i][2]) + "+" +str(s[i][4]) + "-" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "+" and s[i][3] == "-" and s[i][5] == "+":
        ans = int(s[i][0]) + int(s[i][2]) - int(s[i][4]) + int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "+" +str(s[i][2]) + "-" +str(s[i][4]) + "+" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "+" and s[i][3] == "-" and s[i][5] == "-":
        ans = int(s[i][0]) + int(s[i][2]) - int(s[i][4]) - int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "+" +str(s[i][2]) + "-" +str(s[i][4]) + "-" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "-" and s[i][3] == "+" and s[i][5] == "+":
        ans = int(s[i][0]) - int(s[i][2]) + int(s[i][4]) + int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "-" +str(s[i][2]) + "+" +str(s[i][4]) + "+" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "-" and s[i][3] == "+" and s[i][5] == "-":
        ans = int(s[i][0]) - int(s[i][2]) + int(s[i][4]) - int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "-" +str(s[i][2]) + "+" +str(s[i][4]) + "-" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "-" and s[i][3] == "-" and s[i][5] == "+":
        ans = int(s[i][0]) - int(s[i][2]) - int(s[i][4]) + int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "-" +str(s[i][2]) + "-" +str(s[i][4]) + "+" +str(s[i][6]) + "=7")
            break
    if s[i][1] == "-" and s[i][3] == "-" and s[i][5] == "-":
        ans = int(s[i][0]) - int(s[i][2]) - int(s[i][4]) - int(s[i][6])
        if ans == 7:
            print(str(s[i][0]) + "-" +str(s[i][2]) + "-" +str(s[i][4]) + "-" +str(s[i][6]) + "=7")
            break

Solution (Python):
import sys
S = list(input())
op = ['+', '-']
for i in range(1<<len(S)-1):
    f = S[0]
    for j in range(len(S)-1):
        if i&(1<<j):
            f += '+'
        else:
            f += '-'
        f += S[j+1]
    if eval(f)==7:
        break
print(f+'=7')

Solution (Python):
import itertools
n = input()
x, pm, a = [], [1,-1], 7-int(n[0])
for i in range(1,4):
	x.append(int(n[i]))
for j in itertools.product(pm,repeat=3):
	if x[0]*j[0]+x[1]*j[1]+x[2]*j[2]==a:
		y = list(j)
		break
for k in range(3):
	if y[k]==1:
		y[k] = "+"
	else:
		y[k] = "-"
print(n[0]+y[0]+n[1]+y[1]+n[2]+y[2]+n[3]+"=7")

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

s=input()
ss=""
for i in range(1<<3):
 x=s[0]
 y=int(s[0])
 for j in range(3):
   if i>>j&1:
      x+="+"+s[j+1]
      y+=int(s[j+1])
   else:
      x+="-"+s[j+1]
      y-=int(s[j+1])
 if y==7:ss=x+"=7"
print(ss)

Solution (Python):
A, B, C, D = map(int, list(input()))
op = ['+', '-']

for p in range(2):
    for q in range(2):
        for r in range(2):
            s = '{}{}{}{}{}{}{}'.format(A, op[p], B, op[q], C, op[r], D)
            if eval(s) == 7:
                print(s + '=7')
                exit()

Solution (Python):
n = list(raw_input())
op = ['+', '-']

for o1 in op:
	for o2 in op:
		for o3 in op:
			s = n[0] + o1 + n[1] + o2 + n[2] + o3 + n[3]
			if eval(s) == 7:
				print s + '=7'
				exit(0)

Solution (Python):
a=list(input())
for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            ans=a[0]+i+a[1]+j+a[2]+k+a[3]
            if eval(ans)==7:
                print(ans+"=7")
                exit()

Solution (Python):
S=input()
T=[0]*4
for i in range(4):
    T[i]=int(S[i])

if T[0]+T[1]+T[2]+T[3]==7: print(S[0]+"+"+S[1]+"+"+S[2]+"+"+S[3]+"=7")
elif T[0]+T[1]+T[2]-T[3]==7: print(S[0]+"+"+S[1]+"+"+S[2]+"-"+S[3]+"=7")
elif T[0]+T[1]-T[2]-T[3]==7: print(S[0]+"+"+S[1]+"-"+S[2]+"-"+S[3]+"=7")
elif T[0]+T[1]-T[2]+T[3]==7: print(S[0]+"+"+S[1]+"-"+S[2]+"+"+S[3]+"=7")
elif T[0]-T[1]-T[2]-T[3]==7: print(S[0]+"-"+S[1]+"-"+S[2]+"-"+S[3]+"=7")
elif T[0]-T[1]-T[2]+T[3]==7: print(S[0]+"-"+S[1]+"-"+S[2]+"+"+S[3]+"=7")
elif T[0]-T[1]+T[2]+T[3]==7: print(S[0]+"-"+S[1]+"+"+S[2]+"+"+S[3]+"=7")
elif T[0]-T[1]+T[2]-T[3]==7: print(S[0]+"-"+S[1]+"+"+S[2]+"-"+S[3]+"=7")

Solution (Python):
if __name__ == '__main__':
    S = input()
    recur_num = (len(S) - 1) ** 2

    for i in range(recur_num):
        ope = []
        for j in range(len(S) - 1):
            if i & (2 ** j):
                ope.append("+")
            else:
                ope.append("-")

        if eval(S[0] + ope[0] + S[1] + ope[1] + S[2] + ope[2] + S[3]) == 7:
            print(S[0] + ope[0] + S[1] + ope[1] + S[2] + ope[2] + S[3] + "=7")
            break

Solution (Python):
n = list(map(int,input()))
if(n[0]+n[1]+n[2]+n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]+n[1]+n[2]-n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
elif(n[0]+n[1]-n[2]+n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]+n[1]-n[2]-n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")
elif(n[0]-n[1]+n[2]+n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]-n[1]+n[2]-n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
elif(n[0]-n[1]-n[2]+n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]-n[1]-n[2]-n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")

Solution (Python):
ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
pattern = [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
ans = []
for i in pattern:
    if A + B*i[0] + C*i[1] + D*i[2] == 7:
        for j in range(3):
            if i[j] == 1:
                ans.append("+")
            else:
                ans.append("-")
        print(str(A)+ans[0]+str(B)+ans[1]+str(C)+ans[2]+str(D)+"=7")
        exit()

Solution (Python):
s = input()
t = ["+", "-"]

for i in t:
    for j in t:
        for k in t:
            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):
from itertools import permutations, chain
number = input()

for v in permutations("+++---", 3):
    string = "".join(chain(*zip(number, v))) + number[-1]
    if eval(string) == 7:
        print("{}=7".format(string))
        break

Solution (Python):
nums = [int(num) for num in input()]

target = 7

if sum(nums) == target:
    symbols = '+++'
elif nums[0] + nums[1] + nums[2] - nums[3] == target:
    symbols = '++-'
elif nums[0] + nums[1] - nums[2] + nums[3] == target:
    symbols = '+-+'
elif nums[0] + nums[1] - nums[2] - nums[3] == target:
    symbols = '+--'
elif nums[0] - nums[1] + nums[2] + nums[3] == target:
    symbols = '-++'
elif nums[0] - nums[1] + nums[2] - nums[3] == target:
    symbols = '-+-'
elif nums[0] - nums[1] - nums[2] + nums[3] == target:
    symbols = '--+'
elif nums[0] - nums[1] - nums[2] - nums[3] == target:
    symbols = '---'

result = ''
for i in range(len(symbols)):
    result += str(nums[i])
    result += symbols[i]
result += str(nums[-1])

print('{}=7'.format(result))

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

def myprint(c1,c2,c3):
    return print(str(a)+c1+str(b)+c2+str(c)+c3+str(d)+'=7')

if a+b+c+d==7:
    myprint('+','+','+')
elif a+b+c-d==7:
    myprint('+','+','-')
elif a+b-c+d==7:
    myprint('+','-','+')
elif a+b-c-d==7:
    myprint('+','-','-')
elif a-b+c+d==7:
    myprint('-','+','+')
elif a-b+c-d==7:
    myprint('-','+','-')
elif a-b-c+d==7:
    myprint('-','-','+')
elif a-b-c-d==7:
    myprint('-','-','-')

Solution (Python):
import itertools

A, B, C, D = [int(s) for s in list(input())]

symbols = ['+', '-']
for s1, s2, s3 in itertools.product(symbols, symbols, symbols):
    N = 0
    N = A + B if s1 == '+' else A - B
    N = N + C if s2 == '+' else N - C
    N = N + D if s3 == '+' else N - D
    if N == 7:
        print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N))
        break

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

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

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

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

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

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")
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(-1)

Solution (Python):
def dfs(N, ops, nums, Sum):
    if N == 3:
        if Sum == 7:
            print(str(nums[0])+ops[0]+str(nums[1])+ops[1]+str(nums[2])+ops[2]+str(nums[3])+"=7")
            return True
        else:
            return False
    else:
        ops[N]="+"
        if dfs(N+1, ops, nums, Sum+nums[N+1]):
            return True
        ops[N]="-"
        if dfs(N+1, ops, nums, Sum-nums[N+1]):
            return True

nums=[int(i) for i in input()]
ops=["" for i in range(3)]
dfs(0, ops, nums, nums[0])

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]


def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li



dp = None

def main():
    N = input()
    op = ["+", "-"]

    for op1 in op:
        for op2 in op:
            for op3 in op:
                if eval(N[0] + op1 + N[1] + op2 + N[2] + op3 + N[3]) == 7:
                    print(N[0] + op1 + N[1] + op2 + N[2] + op3 + N[3] + "=7")
                    return

main()

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("{0}+{1}+{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a + b + c - d == 7:
    print("{0}+{1}+{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a + b - c + d == 7:
    print("{0}+{1}-{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a + b - c - d == 7:
    print("{0}+{1}-{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b + c + d == 7:
    print("{0}-{1}+{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b + c - d == 7:
    print("{0}-{1}+{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b - c + d == 7:
    print("{0}-{1}-{2}+{3}=7".format(str(a), str(b), str(c), str(d)))
elif a - b - c - d == 7:
    print("{0}-{1}-{2}-{3}=7".format(str(a), str(b), str(c), str(d)))

Solution (Python):
li=list(map(int,list(input())))
for i in range(2**3):
  val=li[0]
  outp=str(val)
  for j in range(3):
    if((i>>j)&0b1):
      val+=li[j+1]
      outp+="+"+str(li[j+1])
    else:
      val-=li[j+1]
      outp+="-"+str(li[j+1])
  if(val==7):break
print(outp+"=7")

Solution (Python):
a=list(map(int,input()))
if a[0]+a[1]+a[2]+a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"+"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]+a[1]+a[2]-a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"+"+str(a[2])+"-"+str(a[3])+"=7")
    exit()
elif a[0]+a[1]-a[2]+a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"-"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]+a[1]-a[2]-a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"-"+str(a[2])+"-"+str(a[3])+"=7")
    exit()
elif  a[0]-a[1]+a[2]+a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"+"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]-a[1]+a[2]-a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"+"+str(a[2])+"-"+str(a[3])+"=7")
    exit()
elif a[0]-a[1]-a[2]+a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"-"+str(a[2])+"+"+str(a[3])+"=7")
    exit()
elif a[0]-a[1]-a[2]-a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"-"+str(a[2])+"-"+str(a[3])+"=7")
    exit()

Solution (Python):
S = str(input())
n = len(S)
ans = 0

for i in range(1 << n-1):
    ins = S[0]
    for j in range(n-1):
        if i & (1 << j):
            ins += "+" + S[j+1]
        else:
            ins += "-" + S[j+1]

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

Solution (Python):
n=input()
a=[c for c in n]
li=['+','-']

def ans(a,li):
    for p in li:
        for q in li:
            for r in li:
                ans=a[0]+p+a[1]+q+a[2]+r+a[3]
                if eval(ans)==7:
                    return ans+'=7'

print(ans(a,li))

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

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

print("{0}{1}{2}{3}{4}{5}{6}=7".format(a,op1,b,op2,c,op3,d))

Solution (Python):
from itertools import product

s = tuple(map(int, tuple(input())))

options = (-1, 1)

for op1, op2, op3 in product(options, repeat=3):
    if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
        _op1 = "+" if op1 == 1 else "-"
        _op2 = "+" if op2 == 1 else "-"
        _op3 = "+" if op3 == 1 else "-"
        print(s[0], _op1, s[1], _op2, s[2], _op3, s[3], "=7", sep="")
        exit()

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


pm=[1,-1]
hugou=["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+pm[i]*b+pm[j]*c+pm[k]*d==7:
                print(str(a)+hugou[i]+str(b)+hugou[j]+str(c)+hugou[k]+str(d)+"=7")
                exit()

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"
 
 
def main():
    print(find_eq(input()))
 
 
if __name__ == '__main__':
    main()

Solution (Python):
import itertools
b=[]
for a in itertools.product((0, 1), repeat=3):
    b.append(a)

A=input()
c=int(A[0])
for i in range(len(b)):
    c=int(A[0])
    for j in range(3):
        if b[i][j]==0:
                c=c+int(A[j+1])
        else:
                c=c-int(A[j+1])
    if c==7:
        print(A[0],end="")
        for j in range(3):
            if b[i][j]==0:
                print("+",end="")
            else:
                print("-",end="")
            print(A[j+1],end="")
        print("=7")
        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:
    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):
S = input()

for op1 in "+-":
    for op2 in "+-":
        for op3 in "+-":
            s = S[0] + op1
            s += S[1] + op2
            s += S[2] + op3
            s += S[3]

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

Solution (Python):

A,B,C,D = list(map(int, list(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):

def make_st(s, xs):
    if not s:
        return xs

    y = s[-1]
    ys = []
    for x in xs:
        ys.append(y + "+" + x)
        ys.append(y + "-" + x)
    return make_st(s[:-1], ys)

s = input()

for x in make_st(s[:-1], [s[-1]]):
    if eval(x) == 7:
        print(x+"=7")
        break

Solution (Python):


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

for op1 in "-+":
    for op2 in "-+":
        for op3 in "-+":
            e = 0
            e += a + b if op1 == '+' else a - b
            e += c if op2 == '+' else -c
            e += d if op3 == '+' else -d
            if e == 7:
                s = str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d)
                print(s + "=7")
                exit(0)

Solution (Python):

import itertools

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

pr = itertools.product([a], [b, -1 * b], [c, -1 * c], [d, -1 * d])

for li in pr:
    if sum(li) == 7:
        print('%d%+d%+d%+d=7' % li)
        break