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

A,B,C,D = input()
A = int(A)
B = int(B)
C = int(C)
D = int(D)
sum = 0
ope = ["", "",""]
for i in range(2):

    for j in range(2):

        for k in range(2):
            if (i == 0):
                sum += A + B
                ope[0] = "+"
            if (i == 1):
                sum += A - B
                ope[0] = "-"
            if (j == 0):
                sum += C
                ope[1] = "+"
            if (j == 1):
                sum -= C
                ope[1] = "-"
            if (k == 0):
                sum += D
                ope[2] = "+"
                if (sum == 7):
                    break
                else:
                    sum = 0
            if(k==1):
                sum -= D
                ope[2] = "-"
                if (sum == 7):
                    break
                else:
                    sum = 0
        if (sum == 7):
            break

    if (sum == 7):
        break
print("{}{}{}{}{}{}{}=7".format(A,ope[0],B,ope[1],C,ope[2],D))

Solution (Python):
from itertools import *

ABCD = input()

n = len(ABCD) - 1 

plumi_list = list(product(["+", "-"], repeat=n))

for bit in range(1 << n):
    formula = ABCD[0]
    for num, op in zip(ABCD[1:], plumi_list[bit]):
        formula += op + num
        ans = eval(formula)

    if ans == 7:
        print(formula + "=7")
        break

Solution (Python):
ABCD = input()
 
for i in range(2**3):
    ans = ABCD[0]
    num = int(ABCD[0])
    for j in range(3):
        if (i >>j & 1):
            ans = ans + '+' + ABCD[j+1]
            num = num + int(ABCD[j+1])
        else:
            ans = ans + '-' + ABCD[j+1]
            num = num - int(ABCD[j+1])
    if num == 7:
        print(ans + '=7')
        break

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

Solution (Python):
import itertools
a, b, c, d = input()
ops = ("+", "-")
for op1, op2, op3 in itertools.product(ops, repeat=3):
    eq = a + op1 + b + op2 + c + op3 + d
    if eval(eq) == 7:
        print(eq + "=7")
        break

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

nl = [a,b,c,d]

import itertools
op =["+","-"]
opl = list(itertools.product(op, repeat=3))

for i in range(8): 
    res = nl[0]
    opp = opl[i]
    for j in range(3):
        if opp[j]=="+":
            res += nl[j+1]
        else:
            res -= nl[j+1]
    if res ==7:
        print(str(nl[0])+opp[0]+str(nl[1])+opp[1]+str(nl[2])+opp[2]+str(nl[3])+"=7")
        exit()

Solution (Python):
import itertools

def f(bin, x):
    if bin == 0:
        return x
    else:
        return -x

def g(x):
    r = str(n[-1])
    for i in range(ketasu - 1):
        if x[i] == 0:
            r += "+"
        else:
            r += "-"
        r += str(n[-i - 2])
    r+="=7"
    return r

abcd = input()
ketasu = len(abcd)
abcd = int(abcd)
n = [None] * ketasu
for i in range(ketasu):
    n[i] = abcd % 10
    abcd //= 10

for i in itertools.product([0, 1], repeat=ketasu - 1):
    ans = n[-1]
    for j in range(ketasu-1):
        ans += f(i[j], n[-j-2])
    if ans == 7:
        ans = g(i)
        break
print(ans)

Solution (Python):

import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


a = instr()
res = ""
for i in range(8):
    s = '{0:03b}'.format(i)
    temp = a[0]
    total = int(a[0])
    j = 0
    for i in range(1, 4):

        if s[j] == '0':
            total += int(a[i])
            temp += "+" + a[i]
        else:
            total -= int(a[i])
            temp += "-" + a[i]

        j += 1

    if total == 7:
        res = temp
        break
print(res+"=7")

Solution (Python):
ABCD = input()

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

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

Solution (Python):
import copy
import numpy as np

s = input()
n = 3
ans = 0

for i in range(1,3 ** n):
    x = copy.deepcopy(s)
    y = str(np.base_repr(i,3)).rjust(3,'0') 
    if (y[0] == "0" and s[0] == "0") or (y[1] == "0" and s[1] == "0") or (y[2] == "0" and s[2] == "0"):
        continue
    z = 1
    for j in range(3):
        if y[j] == "1": 
            x = x[:j+z] + "+" + x[j+z:]
            z += 1
        if y[j] == "2": 
            x = x[:j+z] + "-" + x[j+z:]
            z += 1
    if eval(x) == 7:
        print(x +"=7")
        exit()

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

Solution (Python):
def main():
    (A,B,C,D) = map(int, input())
    operation = ['+','-']
    sumA = A
    for op1 in operation:
        sum = sumA
        if op1=='+':
            sum+=B
        else:
            sum-=B
        sumAB = sum
        for op2 in operation:
            sum = sumAB
            if op2=='+':
                sum+=C
            else:
                sum-=C
            if 7-sum==D:
                op3 = '+'
                print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
                return
            elif sum-7==D:
                op3 = '-'
                print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
                return

main()

Solution (Python):
n = input()
gap =len(n) -1
for i in range(2 ** gap):
  f = ""
  for j in range(gap):
    f += str(n[j])
    if ((i>>j)&1):
      f += "+"
    else:
      f += "-"
  f += n[-1]
  if eval(f) == 7 :
    print(f +"=7")
    break

Solution (Python):
n = list(str(x) for x in input())
l = len(n)
op_cnt = l - 1
for i in range(2 ** op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt-1 - j] = '+'

  formula = ''
  for j in range(op_cnt):
    formula += n[j] + op[j]
  formula += n[op_cnt]
  if eval(formula) == 7:
    print(formula + '=7')
    break

Solution (Python):
n = list(str(x) for x in input())
l = len(n)
op_cnt = l - 1
for i in range(2 ** op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt-1 - j] = '+'

  formula = ''
  for j in range(op_cnt):
    formula += n[j] + op[j]
  formula += n[op_cnt]
  if eval(formula) == 7:
    print(formula + '=7')
    break

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split(''))
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

a = ns()
for i in range(2**3):
    ans = '{}'.format(a[-1])
    for j in range(3):
        if (i >> j) & 1:
            ans = a[-1-(j+1)] + '+' + ans
        else:
            ans = a[-1-(j+1)] + '-' + ans
    if eval(ans) == 7:
        print(ans+'=7')
        break

Solution (Python):
In = [int(i) for i in input()]
flag = 0
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            if eval("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}".format(In[3]))==7:
                print("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}=7".format(In[3]))
                exit()

Solution (Python):
In = [int(i) for i in input()]
flag = 0
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            if eval("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}".format(In[3]))==7:
                print("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}=7".format(In[3]))
                flag = 1
                break
        if flag:
            break
    if flag:
        break

Solution (Python):
from itertools import product
def calc_appropriate_op(a, b, c, d):
  """
  calc op1, op2, op3 that satisfies 'a(op1)b(op2)c(op3)d = 7'
  Args:
    a, b, c, d (str)
  Returns:
    list (str) 
  """
  for pattern in product(['+', '-'], repeat=3):
    if eval(a+pattern[0]+b+pattern[1]+c+pattern[2]+d) == 7:
      return pattern
  



s = input()
a, b, c, d = s
op_list = calc_appropriate_op(a, b, c, d)
print("{}{}{}{}{}{}{}=7".format(a, op_list[0], b, op_list[1], c, op_list[2], d))

Solution (Python):
s=input()
n=len(s)
l=[]
for i in s:
  l.append(int(i))
for i in range(2 ** n):
    check = []
    for j in range(n):
      if ((i >> j) & 1):  
        check.append(l[j]) 
      else:
        check.append(-l[j])         
    if sum(check)==7:
      print(str(check[0]), end="")           
      for i in range(1, n):
        if check[i]>=0:
          print("+"+str(check[i]), end="")
        else:
          print(str(check[i]), end="")
      print("=7")
      exit()

Solution (Python):
s = input()
n = len(s) - 1
for i in range(2**n):
    tmp = []
    for j in range(n):
        tmp.append(s[j])
        if i >> j & 1:
            tmp.append("+")
        else:
            tmp.append("-")
    tmp.append(s[-1])
    if eval("".join(tmp)) == 7:
        print("".join(tmp) + "=7")
        exit()

Solution (Python):
s = input()
n = len(s)
for i in range(2**(n-1)):
    op = ["-"] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            op[n - 2 -j] = "+"
    
    chk = ""
    for p_n, p_o in zip(s, op + [""]):
        chk += (p_n + p_o)
    if eval(chk) == 7:
        print(chk + "=7")
        exit()

Solution (Python):
s = list(map(int,list(input())))
a = s.pop(0)

bit_n = 3
for i in range(2**bit_n):
    sign = ['+']*3
    tmp = a
    for j in range(bit_n):
        if ((i>>j)&1):
            tmp+=s[j]
        else:
            tmp-=s[j]
            sign[j]='-'
    if tmp==7:
        print("{0}{1[0]}{2[0]}{1[1]}{2[1]}{1[2]}{2[2]}=7".format(a,sign,s));exit()

Solution (Python):
s = input()
res_list = ['-', '-', '-']
for i in range(8):
    res = s[0]
    for j in range(3):
        if (i >> j) &1:
            res += '+'
        else:
            res += '-'
        res += s[j+1]
    if eval(res) == 7:
        print(res + '=7')
        exit()

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(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
elif A - B - C - D == 7:
  print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
elif A + B - C - D == 7:
  print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
elif A - B + C + D == 7:
  print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
elif A - B - C + D == 7:
  print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
elif A - B + C - D == 7:
  print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
elif A + B - C + D == 7:
  print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
elif A + B + C - D == 7:
  print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')

Solution (Python):
n = list(input())
op = ['+', '-']
for i in range(8):
    bin_i = bin(i).replace('0b', '').zfill(3)
    
    tmp = int(n[0])
    for j in range(3):
        if bin_i[j] == '0':
            tmp = tmp + int(n[j+1])
        else:
            tmp = tmp - int(n[j+1])
    if tmp == 7:
        ans = n[0] + op[int(bin_i[0])] + n[1] + op[int(bin_i[1])] + n[2] + op[int(bin_i[2])] + n[3]
        print(ans+'=7')
        break

Solution (Python):
c,*s=input()
n=len(s)
for b in range(1<<n):
    t = c + ""
    for i in range(n):
        t += ["-","+"][b>>i & 1] + s[i]
    if eval(t) == 7:
        print(t+"=7")
        exit()

Solution (Python):
A, B, C, D = list(map(int, list(input())))
ops = ['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      if A + ((-1)**i)*B + ((-1)**j)*C + ((-1)**k)*D == 7:
        ans = str(A) + ops[i] + str(B) + ops[j] + str(C) + ops[k] + str(D) + '=7'
        print(ans)
        quit()

Solution (Python):
def Ans(x, y, z, w):
  if(x+ y+ z+ w == 7):
    return "{}+{}+{}+{}=7".format(x, y, z, w)
  elif(x- y+ z+ w == 7):
    return "{}-{}+{}+{}=7".format(x, y, z, w)
  elif(x- y- z+ w == 7):
    return "{}-{}-{}+{}=7".format(x, y, z, w)
  elif(x- y+ z- w == 7):
    return "{}-{}+{}-{}=7".format(x, y, z, w)
  elif(x+ y- z- w == 7):
    return "{}+{}-{}-{}=7".format(x, y, z, w)
  elif(x+ y- z+ w == 7):
    return "{}+{}-{}+{}=7".format(x, y, z, w)
  elif(x+ y+ z- w == 7):
    return "{}+{}+{}-{}=7".format(x, y, z, w)
  elif(x- y- z- w == 7):
    return "{}-{}-{}-{}=7".format(x, y, z, w)


ABCD = input()
N = list(ABCD)

x = int(N.pop(0))
y = int(N.pop(0))
z = int(N.pop(0))
w = int(N.pop(0))

ans = Ans(x, y, z, w)
print(ans)

Solution (Python):
lst = list(input())
n = len(lst)

for i in range(2 ** (n - 1)):
    l = [lst[0]]
    for j in range(n - 1):
        if i >> j & 1:
            l.append("+")
        else:
            l.append("-")
        l.append(lst[j + 1])

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

Solution (Python):

ns=input()

for i in range(2**(len(ns))):
    ops=["+"]*(len(ns)-1)
    for j in range(len(ops)):
        if((i>>j)&1):
            ops[j]="-"
            
    siki=""
    for x,y in zip(ns,ops+[""]):
        siki+=x+y
        
    if eval(siki)==7:
        print(siki+"=7")
        break

Solution (Python):
nums = list(input())
a, b, c, d = map(int, nums)
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))
else:
    print('{}-{}-{}-{}=7'.format(a,b,c,d))

Solution (Python):

inp = int(input())


a = int(inp / 1000)
b = int((inp % 1000)/100)
c = int((inp % 100)/10)
d = int((inp % 10))
'''

d = inp % 10
inp //= 10

c = inp % 10
inp //= 10

b = inp % 10
inp //= 10

a = inp % 10
inp //= 10
'''

pm = 8
total = a


for i in range(8):
    total = a
    siki = str(a)
    if(i & 1):
        total += b
        siki += '+' +str(b)
    elif((i&1) != 1):
        total -= b
        siki += '-' +str(b)

    if((i>>1) &1 ):
        total += c
        siki += '+' +str(c)
    else:
        total -= c
        siki += '-' +str(c)

    if((i>>2) &1):
        total += d
        siki += '+' +str(d)
    else:
        total -= d
        siki += '-' +str(d)

    if (total == 7):
        siki += "=7"
        print(siki)
        quit()

Solution (Python):
n = input()

for i in range(2 ** 3):
    l = n[0]
    for j in range(3):
        if (i >> j) & 1 == 1:
            l += '+'
        else:
            l += '-'
        l += n[j + 1]
    if eval(l) == 7:
        print(l, '=7', sep = '')
        exit()

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

Solution (Python):
a, b, c, d = input()
s = ['+', '-']

for i in s:
    for j in s:
        for k in s:
            f = a + i + b + j + c + k + d
            if eval(f) == 7:
                print(f + '=7')
                exit()

Solution (Python):
a, b, c, d = list(input())
pm = ['+', '-']

for i in pm:
    for j in pm:
        for k in pm:
            f = a + i + b + j + c + k + d
            if eval(f) == 7:
                print(f + '=7')
                exit()

Solution (Python):
a, b, c, d = list(input())
pm = ['+', '-']
s = []
for i in pm:
    for j in pm:
        for k in pm:
            s.append(a + i + b + j + c + k + d)

for i in s:
  if eval(i) == 7:
    print(i + '=7')
    exit()

Solution (Python):
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
A,B,C,D = [x for x in S()]
for op1,op2,op3 in itertools.product(['+','-'],repeat=3):
    ans = A+op1+B+op2+C+op3+D
    if eval(ans)==7:
        print(ans+'=7')
        break

Solution (Python):
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
A,B,C,D = [x for x in S()]
for op1,op2,op3 in itertools.product(['+','-'],repeat=3):
    ans = A+op1+B+op2+C+op3+D
    if eval(ans)==7:
        print(*[ans,'=7'],sep='')
        break

Solution (Python):
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
A,B,C,D = [x for x in S()]
for op1,op2,op3 in itertools.product(['+','-'],repeat=3):
    if eval('{}{}{}{}{}{}{}'.format(A,op1,B,op2,C,op3,D))==7:
        print(*[A,op1,B,op2,C,op3,D,'=7'],sep='')
        break

Solution (Python):
N = list(int(i) for i in input())
A = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            x = N[0]
            if i == 0:
                x += N[1]
            else:
                x -= N[1]

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

            if k == 0:
                x += N[3]
            else:
                x -= N[3]
            if x == 7:
                A.append(i)
                A.append(j)
                A.append(k)
                break
ans = str(N[0])
for l in range(3):
    if A[l] == 0:
        ans += "+"
    else:
        ans += "-"
    ans += str(N[l+1])
ans += "=7"
print(ans)

Solution (Python):
s = input()
abcd = []
op = []
for i in range(2**3):
  tmp = ['-'] * 3
  for j in range(3):
    if i >> j & 1:
      tmp[j] = "+"
  op.append(tmp)

s_ = []
for i in range(4):
  if(i == 3):
    s_.append(s[i])
    break
  s_.append(s[i])
  s_.append(" ")

for i in range(len(op)):
  tmp = s_
  tmp[1::2] = op[i]
  temp = ''.join(tmp)
  ans = eval(temp)
  
  if(ans == 7):
    ss = temp + "=7"
    print(ss)
    break

Solution (Python):
a,b,c,d=map(int,list(input()))
 
lis=[[i,-i] for i in [b,c,d]]

for i in range(8):
    sam=[a]
    
    for j in range(3):
        boolen=((i>>j)&1)
        sam.append(lis[j][int(boolen)])
    
    if sum(sam)==7:
        
        dis=[str(sam[0])]
        for num in sam[1:]:
            if num>=0:
                dis.append('+'+str(num))
            else:
                dis.append(str(num))
        print('%s%s%s%s=7'%(dis[0],dis[1],dis[2],dis[3]))
        break

Solution (Python):
a, b, c, d = input()
for x in "+-":
	for y in "+-":
		for z in "+-":
			f = a + x + b + y + c + z + d
			if eval(f) == 7:
				print(f + "=7")
				exit()

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

for i in range(2):
	for j in range(2):
		for k in range(2):
			x = a + b*(-1)**i + c*(-1)**j + d*(-1)**k
			if x == 7:
				print(a, end='')
				print('-' if i else '+', end='')
				print(b, end='')
				print('-' if j else '+', end='')
				print(c, end='')
				print('-' if k else '+', end='')
				print(d, end='')
				print("=7")
				exit()

Solution (Python):
n=list(input())
for i in range(1<<3):
    cnt=int(n[0])
    l=[n[0]]
    for j in range(3):
        if (i>>j)%2==1:
            cnt+=int(n[j+1])
            l+="+"+n[j+1]
        else:
            cnt-=int(n[j+1])
            l+="-"+n[j+1]
    if cnt==7:
        print("".join(l)+"=7")
        break

Solution (Python):
from itertools import product
 
S = input()
 
patterns = list(product(["-","+"],repeat=len(S)-1))
 
ans = []

for pattern in patterns:
    cnt = 0
    num = ""
    for i in range(len(pattern)+1):
        if i == 0:
            cnt += int(S[i])
            num = num + S[i]
        else:
            if pattern[i-1] == "+":
                cnt += int(S[i])
                num = num + pattern[i-1] + S[i]
            else:
                cnt -= int(S[i])
                num = num + pattern[i-1] + S[i]
    if cnt == 7:
        print(num+"=7")
        break;

Solution (Python):
s=input()
s=list(s)
for i in range(2**3):
  temp=[0]*3
  for j in range(3):
    if ((i >> j) & 1):
      temp[j]="+"
    else:
      temp[j]="-"
  a=[s[0],temp[0],s[1],temp[1],s[2],temp[2],s[3]]
  if eval("".join(a))==7:
    print("".join(a)+"=7")
    break

Solution (Python):
n = input()
op_cnt = len(n) - 1  
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt 
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  
    formula = ""
    for p_n, p_o in zip(n, op + [""]): 
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):


num = list(input())

for i in range(2 ** 3):
    t = int(num[0])
    op = []
    for j in range(3):
        if (i >> j) & 1:
            t += int(num[j + 1])
            op.append('+')
        else:
            t -= int(num[j + 1])
            op.append('-')
    op.append('=')
    if t == 7:
        ans = []
        for i, j in zip(num, op):
            ans.append(i)
            ans.append(j)
        print(''.join(ans) + '7')
        break

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

n = 3
pt = []
for i in range(2 ** n):
  tmp = ["+"] * n
  for j in range(n):
    if i >> j & 1:
      tmp[j] = "-"
  pt.append(tmp)
for x in pt:
  fr = a + x[0] + b + x[1] + c+ x[2] + d 
  if eval(fr) == 7 :
    print(fr+"=7")
    exit()

Solution (Python):
import sys
s = input()
def bfs(exp,idx):
    if idx == 3:
        ev = eval(exp+s[idx])
        if ev == 7:
            print(exp+s[idx]+"=7")
            sys.exit(0)
        return False
    exp += s[idx]
    for op in ["+", "-"]:
        bfs(exp+op, idx+1)
bfs("",0)

Solution (Python):
def main():
    from itertools import product

    a, b, c, d = input()

    for prd in product('+-', repeat=3):
        op1, op2, op3 = prd
        f = a + op1 + b + op2 + c + op3 + d
        if eval(f) == 7:
            print('{}=7'.format(f))
            return


if __name__ == '__main__':
    main()

Solution (Python):
S=str(input())
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
PM=['+','-']

for op1 in PM:
  if op1 == '-':
    b = -B
  else:b = B
  for op2 in PM:
    if op2 == '-':
      c = -C
    else:c = C
    for op3 in PM:
      if op3 == '-':
        d = -D
      else:d = D
      if A+b+c+d==7:
        print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+'=7')
        exit()

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
op = ["+", "-"]

def exec():
    for a in op:
        for b in op:
            for c in op:
                exp = S[0:1] + a + S[1:2] + b + S[2:3] + c + S[3:4]
                if eval(exp) == 7:
                    return exp + "=7"

print(exec())

Solution (Python):
import sys
s = input()
for bit in range(1 << len(s)-1):
  res = s[0]
  for i in range(len(s)-1):
    if bit & (1<<i):
      res += '+'
    else:
      res += '-'
    res += s[i+1]
  if eval(res) == 7:
    print(res+'=7')
    sys.exit()

Solution (Python):
n = input()

op_cnt = len(n) -1
for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt -1 -j] = "+"
    
            
    formula = ""
    for p_n,p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        s = formula+"=7"
        print(s)
        break

Solution (Python):
S = input()

for n in range(1 << 3):
    s = S
    for i in range(3):
        if (n >> i) & 1 == 1:
            op = "+"
        else:
            op = "-"
        s = s[:2*i+1] + op + s[2*i+1:]
    if eval(s) == 7:
        ans = s + "=7"
        break

print(ans)

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

m = ["+","-"]

for i in m:
    for j in m:
        for k in m:
            a = eval(A+i+B+j+C+k+D)
            if a == 7:
                print(A+i+B+j+C+k+D+"=7")
                exit()

print()

Solution (Python):
A=input()
n=3

for i in range(2**n):
    result=A[0]
    result_sum=int(A[0])
    for j in range(n):
        if (i>>j)&1:
            result=result+"-"+A[j+1]
            result_sum-=int(A[j+1])
        else:
            result=result+"+"+A[j+1]
            result_sum+=int(A[j+1])
    if result_sum==7:
        print(result+"=7")
        exit()

Solution (Python):
s = list(input())
l = len(s)

for bit in range((l-1)**2):
    ans_sum = int(s[0])
    ans_str = s[0]
    for i in range(l-1):
        if (bit >> i) & 1:
            ans_sum += int(s[i+1])
            ans_str += '+'
        else:
            ans_sum -= int(s[i+1])
            ans_str += '-'
        ans_str += s[i+1]
    if ans_sum == 7:
        print(ans_str+'=7')
        exit(0)

Solution (Python):
S=input()
for i in range(8):
  formula=S[0]
  q="{:0>4b}".format(i)[::-1]
  for j in range(1,4):
    if int(q[j-1])&1:
      formula+="+"
    else:
      formula+="-"
    formula+=S[j]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Solution (Python):
_ = '_'

arr = []

def solve(s):
    if _ in s:
        solve(s.replace(_, "+", 1))
        solve(s.replace(_, "-", 1))

    else:
        if eval(s) == 7:
            print(s + '=7')
            exit()


solve(_.join(list(input())))

Solution (Python):
n = input()
op_cnt = len(n) - 1  
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  
    for j in range(op_cnt):
        if (i >> j) & 1:  
            op[op_cnt - 1 - j] = "+"  
    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
n = [i for i in input()]
length = len(n) -1

for i in range(2 ** length):
    ops = ['-'] * length
    for j in range(length):
        if (i >> j) & 1:
            ops[length - 1 - j] = '+'
    
    formula = str()
    for num , op in zip(n, ops + ['']):
        formula += (num + op)
    
    if eval(formula) == 7:
        print(formula+'=7')
        break

Solution (Python):

from itertools import product
S = input()
n = len(S)-1
total =0
for i in list(product(["-","+"],repeat=n)):
    bag=""
    for ind,val in enumerate(S):
        if ind ==0:
            bag+=val
        else:
            bag+=i[ind-1]+val
    if eval(bag)==7:
        print(bag+"=7")
        exit()

Solution (Python):
s = input()
num = 2 ** (len(s) - 1)
for i in range(num):
  x = ''
  for index, value in enumerate(s):
    x += value
    if index == (len(s) - 1):
      break
    if (i>>index) & 1:
      x += '+'
    elif ~((i>>index) & 1):
      x += '-'
      
  if eval(x) == 7:
    break
x += '=7'
print(x)

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

def main():
    abcd = input()
    a = abcd[0]
    b = abcd[1]
    c = abcd[2]
    d = abcd[3]

    p = product(('+','-'), repeat = 3)
    for ep in p:
        siki = "".join([a,ep[0],b,ep[1],c,ep[2],d])
        if eval(siki) == 7:
            r = siki + "=7"
            print(r)
            sys.exit()

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
for i in range(1 << 3):
    ans = ''
    for j in range(3):
        ans += s[j]
        if i>>j & 1:
            ans += '+'
        else: ans += '-'
    ans += s[-1]
    if eval(ans+'==7'):
        print(ans+'=7')
        break

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



ans = ''

for i in range(2**3):

  x = format(i,'b').zfill(3)
  c = n[0]

  for j in range(1,4):
    if x[j-1] == '0':
      c += n[j]
    else :
      c -= n[j]
 
  if c == 7:
    ans = x
    break

ans = ans.replace('0','+')
ans = ans.replace('1','-')

out = ABCD[0]+ans[0]+ABCD[1]+ans[1]+ABCD[2]+ans[2]+ABCD[3]+'=7'
print(out)

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

r = A + B + C + D
if r == 7:
    print('{}+{}+{}+{}=7'.format(A, B, C, D))
    exit()
while True:
    if A + B + C - D == 7:
        print('{}+{}+{}-{}=7'.format(A, B, C, D))
        exit()
    elif A + B - C - D == 7:
        print('{}+{}-{}-{}=7'.format(A, B, C, D))
        exit()
    elif A - B - C - D == 7:
        print('{}-{}-{}-{}=7'.format(A, B, C, D))
        exit()
    elif A - B + C - D == 7:
        print('{}-{}+{}-{}=7'.format(A, B, C, D))
        exit()
    elif A - B - C + D == 7:
        print('{}-{}-{}+{}=7'.format(A, B, C, D))
        exit()
    elif A + B - C + D == 7:
        print('{}+{}-{}+{}=7'.format(A, B, C, D))
        exit()
    elif A - B + C + D == 7:
        print('{}-{}+{}+{}=7'.format(A, B, C, D))
        exit()
    exit()

Solution (Python):
num = list(input())
n = len(num) - 1

for i in range(2**n):
    temp = [0]*(len(num)+n)
    lst = ["-"]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    temp[::2] = num
    temp[1::2] = lst
    wa = eval("".join(temp[:]))
    if wa == 7:
        print("".join(temp[:]) + "=7")
        exit()

Solution (Python):
num = list(input())
n = len(num) - 1

for i in range(2**n):
    temp = [0]*(len(num)+n)
    lst = ["-"]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    temp[::2] = num
    temp[1::2] = lst
    wa = eval("".join(temp[:]))
    if wa == 7:
        print("".join(temp[:]) + "=7")
        exit()