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 itertools
status = [(0, 1) for _ in range(3)]
state = list(itertools.product(*status))
num = [int(i) for i in input()]
for ptn in state:
  ans = num[0]
  ans_str = str(num[0])
  for i,ope in enumerate(ptn):
    if ope == 0:
      ans += num[i+1]
      ans_str += ("+" + str(num[i+1]))
    else:
      ans -= num[i+1]
      ans_str += ("-" + str(num[i+1]))
  if ans == 7:
    break
print(ans_str+"=7")

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

for bit in range(2**3):
    ans = a[0]
    
    for i in range(3):
        if ((bit >> i) & 1):
            ans += "+"
        else:
            ans += "-"
        ans += a[i + 1]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Solution (Python):
N = input()

def dfs(string, value, i):
    if len(string) ==2*len(N) -1:
        if value == 7:
            print(string + "=7")
            exit()
        return
    else:
        dfs(string + "+" + N[i+1], value + int(N[i+1]), i+1), dfs(string + "-"+ N[i+1], value - int(N[i+1]), i+1)
dfs(N[0], int(N[0]), 0)

Solution (Python):
def dfs(num, string, place):
    if len(string) == 0:
        return dfs(num, num[0], place+1)
    
    if len(string) == 7:
        if eval(string) == 7:
            print(string + "=7")
            exit()
        return 
    else:
        return dfs(num, string + "+" + num[place], place + 1), dfs(num, string + "-" + num[place], place + 1)

ABCD = input()
dfs(ABCD, "", 0)

Solution (Python):


def main():
    S = input()

    for i in range(1 << 3):
        operator = ["-", "-", "-"] 
        for j in range(3):
            if ((i >> j) & 1):
                operator[j] = "+"
        formula = ""
        for s, op in zip(S, operator + [""]):
            formula += s + op
        if eval(formula) == 7:
            print(formula + "=7")
            break

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
def solve():
    S = list(input())
    products = itertools.product(('+','-'),repeat=3)

    ans = ""
    for p in products:
        equation = ""
        for i in range(3):
            equation += S[i] + p[i]
        equation += S[3]

        if eval(equation) == 7:
            ans = equation
            break
    
    print(equation + "=7")

if __name__ == '__main__':
    solve()

Solution (Python):
def solve():
    S = list(input())
    print(dfs(S,0,"")+ "=7")

def dfs(S,idx,res):
    res += S[idx]
    if idx == len(S) - 1:
        return res
    
    res1 = dfs(S,idx+1,res+'+')
    res2 = dfs(S,idx+1,res+'-')

    if eval(res1) == 7:
        return res1
    else:
        return res2
    
if __name__ == '__main__':
    solve()

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

def A(x):
    if x == 1:
        x = "+"
    else:
        x = "-"
    return x




for i in [1, -1]:
    for j in [1, -1]:
        for k in [1, -1]:
            if a + (i * b) + (j * c) + (k * d) == 7:
                print(str(a) + A(i) + str(b) + A(j) + str(c) + A(k) + str(d) + '=7')
                exit()

Solution (Python):


def main():
    S = input()
    for i in range(2**3):
        tmp = ""
        for n in range(len(S)-1):
            tmp += S[n]
            if (i >> n) & 1:
                tmp += "+"
            else:
                tmp += "-"
        tmp += S[-1]
        if eval(tmp) == 7:
            tmp += "=7"
            print(tmp)
            return

if __name__ == "__main__":
    main()

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



l=[str(a),'+',str(b),'+',str(c),'+',str(d)]
for i in range(1):
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='-'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='-'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break
    
    l[5]='-'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='+'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='+'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='-'
    l[5]='+'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='-'
    l[3]='+'
    l[5]='-'
    
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

Solution (Python):


def main():
    s = input()
    op_cnt = len(s) -1
    for i in range(1<<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(s, op+[""]):
            formula += (p_n + p_o)
        if eval(formula) == 7:
            print(formula + "=7")
            break

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = input()

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

    for i in range(2):
        tmp = 0
        if i % 2 == 0:
            tmp = a + b 
        else:
            tmp = a - b
        for j in range(2):
            if j % 2 == 0:
                hoge1 = tmp
                tmp += c
            else:
                tmp = hoge1
                tmp -= c
            for k in range(2):
                if k % 2 == 0:
                    hoge = tmp
                    tmp += d
                else:
                    tmp = hoge
                    tmp -= d
                if tmp == 7:
                    op1 = '+' if i % 2 == 0 else '-'
                    op2 = '+' if j % 2 == 0 else '-'
                    op3 = '+' if k % 2 == 0 else '-'
                    print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                    exit()
            

    

if __name__ == '__main__':
    main()

Solution (Python):
n=input()
L=len(n)-1
for i in range(2**L):
    tmp=["-"]*L
    for j in range(L):
        if((i>>j)&1):
            tmp[j]="+"
    F=""
    for num,sig in zip(n,tmp+[""]):
        F+=(num+sig)
    if eval(F)==7:
        print(F+"=7")
        break

Solution (Python):
x=input()
w,x,y,z=list(map(int, x))

if w+x+y+z==7:
	print(w,'+',x,'+',y,'+',z,'=7',sep=(''))
elif w+x+y-z==7:
	print(w,'+',x,'+',y,'-',z,'=7',sep=(''))
elif w+x-y+z==7:
	print(w,'+',x,'-',y,'+',z,'=7',sep=(''))
elif w-x+y+z==7:
	print(w,'-',x,'+',y,'+',z,'=7',sep=(''))
elif w+x-y-z==7:
	print(w,'+',x,'-',y,'-',z,'=7',sep=(''))
elif w-x+y-z==7:
	print(w,'-',x,'+',y,'-',z,'=7',sep=(''))
elif w-x-y+z==7:
	print(w,'-',x,'-',y,'+',z,'=7',sep=(''))
elif w-x-y-z==7:
	print(w,'-',x,'-',y,'-',z,'=7',sep=(''))

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

for i in range(len(li)): li[i] = int(li[i])
p = ('-','+')
tail = '=7'

if li[0] + li[1] + li[2] + li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '+' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] + li[1] - li[2] + li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '-' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] + li[1] - li[2] - li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '-' + str(li[2]) + '-' + str(li[3]) + tail)

elif li[0] + li[1] + li[2] - li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '+' + str(li[2]) + '-' + str(li[3]) + tail)

elif li[0] - li[1] + li[2] + li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '+' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] - li[1] - li[2] + li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '-' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] - li[1] - li[2] - li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '-' + str(li[2]) + '-' + str(li[3]) + tail)

elif li[0] - li[1] + li[2] - li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '+' + str(li[2]) + '-' + str(li[3]) + tail)

Solution (Python):
import sys
s = [int(x) for x in input()]
n = len(s)-1
for i in range(2**n):
    op = ["-"]*n
    for j in range(n):
        if (i>>j)&1 == 1:
            op[n-1-j] = "+"
    ans = s[0]
    for j in range(n):
        if op[j] == '-':
            ans -= s[j+1]
        else:
            ans += s[j+1]
    if ans == 7:
        ans2 = str(s[0])
        for j in range(n):
            ans2 += op[j]
            ans2 += str(s[j+1])
        print(ans2+"=7")
        sys.exit()

Solution (Python):
import sys, itertools

[a, b, c, d] = sys.stdin.readline().rstrip()

ops = ['+', '-']

for exp in ['%s%s%s%s%s%s%s' % (a, op1, b, op2, c, op3, d) for op1, op2, op3 in list(itertools.product(ops, ops, ops))]:
    if eval(exp) == 7:
        print '%s=7' % exp
        break

Solution (Python):
a,b,c,d = (str(x) for x in input())
list = [int(a),int(b),int(c),int(d)]

def calcurate(list,opn):
    ans = 0
    if opn[0]=="+":
        ans = list[0] + list[1]
    else:
        ans = list[0] - list[1]
    if opn[1]=="+":
        ans = ans + list[2]
    else:
        ans = ans - list[2]
    if opn[2]=="+":
        ans = ans + list[3]
    else:
        ans = ans - list[3]
    return ans


for i in range(8):
    opn = ["-","-","-"]
    for j in range(3):
        if ((i>>j)&1):
            opn[j] = "+"
    ans = calcurate(list,opn)
    if ans==7:
        print("".join([a,opn[0],b,opn[1],c,opn[2],d,"=7"]))
        break

Solution (Python):
s = str(input())
for b in range(1 << (len(s)-1)):
    ops = []
    for i in range(len(s)-1):
        op = "+" if b & 1 << i else "-"
        ops.append(op)
    siki = ""
    ls = list(s)
    ops.append("")
    for i in range(len(ops)):
        siki += ls[i]+ops[i]
    e = eval(siki)
    if e == 7:
        print("{}{}{}".format(siki, "=", e))
        exit()

Solution (Python):
s = input()
S = []
for i in s:
    S.append(int(i))

A = [S[0]]
B = [S[1], -S[1]]
C = [S[2], -S[2]]
D = [S[3], -S[3]]

E = []
for i in A:
    for j in B:
        for k in C:
            for l in D:
                if i + j + k + l == 7:
                    E = [i, j, k, l]
                    break
s = ""
for i in range(4):
    if i == 0:
        s += str(E[i])
    else:
        if E[i] < 0:
            s += str(E[i])
        else:
            s += "+" + str(E[i])
print(s + "=7")

Solution (Python):
import itertools
s=input()

moji = []
for i in s:
    moji.append(int(i))
ans = []
for j in itertools.product([1,-1], repeat=4):
    if moji[0]*j[0]+moji[1]*j[1]+moji[2]*j[2]+moji[3]*j[3] == 7:
        if j[0] == 1:
            ans.append(moji[0])
        else:
            ans.append('-')
            ans.append(moji[0])
        if j[1] == 1:
            ans.append('+')
            ans.append(moji[1])
        else:
            ans.append('-')
            ans.append(moji[1])
        if j[2] == 1:
            ans.append('+')
            ans.append(moji[2])
        else:
            ans.append('-')
            ans.append(moji[2])
        if j[3] == 1:
            ans.append('+')
            ans.append(moji[3])
        else:
            ans.append('-')
            ans.append(moji[3])
        ans.append('=7')
        print(''.join(map(str,ans)))
        exit()

Solution (Python):
n = input()
n1 = int(n[0])
n2 = int(n[1])
n3 = int(n[2])
n4 = int(n[3])
flag = False

for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            if op1 == '+':
                n12 = n1 + n2
            else:
                n12 = n1 - n2

            if op2 == '+':
                n23 = n12 + n3
            else:
                n23 = n12 - n3

            if op3 == '+':
                n34 = n23 + n4
            else:
                n34 = n23 - n4

            if n34 == 7:
                flag = True
                break
        if flag:
            break
    if flag:
        break

print(n1, op1, n2, op2, n3, op3, n4, '=7', sep='')

Solution (Python):
import itertools
N = input()

for i in list(itertools.product(["+","-"],repeat=3)):
    cnt = 0
    X = N[cnt]
    for j in i:
        X += j
        cnt += 1
        X += N[cnt]
        
    Y = eval(X)
    if Y == 7:
        X += "=7"
        print(X)
        quit()

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

for i in range(2**(l-1)):
    f = ""
    for j in range(l-1):
        f += s[j]
        if i & (1 << j):
            f += "+"
        else:
            f += "-"
        if j == l-2:
             f += s[l-1]
    if eval(f)==7:
        print(f+"=7")
        break

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

from itertools import product
t = list(product('+-', repeat=3))

for i in range(len(t)):
    temp = l[0]+t[i][0]+l[1]+t[i][1]+l[2]+t[i][2]+l[3]
    if eval(temp) == 7:
        print(temp + '=7')
        break

Solution (Python):
from itertools import product
S = input()
l = ["+", "-"]
for k in list(product(l, repeat=3)):
  ans = S[0] + k[0] + S[1] + k[1] + S[2] + k[2] + S[3]
  if eval(ans) == 7:
    print(ans+"=7")
    exit()

Solution (Python):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print(e[:-1]+'=7')
        break

Solution (Python):
from itertools import product
A = list(input())
for x in product(("+","-"),repeat=3):
    y = A[0]+x[0]+A[1]+x[1]+A[2]+x[2]+A[3]
    if eval(y)==7:
        print(y+"=7")
        break

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

for i in range(2 ** 3):
    ans = N[0]
    ans_final = list(Nset[0])
    for j in range(3):
        if (i >> j) & 1:
            ans += N[j + 1]
            ans_final.append('+')
            ans_final.append(Nset[j+1])
        else:
            ans -= N[j + 1]
            ans_final.append('-')
            ans_final.append(Nset[j+1])
    if ans == 7:
        ans_final.append('=7')
        print(''.join(ans_final))
        break

Solution (Python):
import itertools
n = list(input())

f = [1,1,1,-1,-1,-1]
def m(n):
    if n == -1:
        return "-"
    else:
        return "+"

for v in itertools.permutations(f,3):
    if int(n[0]) + (v[0] * int(n[1])) + (v[1] * int(n[2])) + (v[2] * int(n[3])) == 7:
        print(n[0],m(v[0]),n[1],m(v[1]),n[2],m(v[2]),n[3],"=7", sep="")
        break

Solution (Python):
import itertools
ABCD=list(input())
calc=["+","-"]*3
conb=set(itertools.permutations(calc, 3))

for c in conb:
    total=int(ABCD[0])
    for n,i in enumerate(c):
        if(i=='+'):
            total+= int(ABCD[n+1])
        else:
            total-=int(ABCD[n+1])
    if(total==7):
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(ABCD[0],c[0],ABCD[1],c[1],ABCD[2],c[2],ABCD[3]))
        break

Solution (Python):
def resolve():
    S = list(map(int, input()))
    a, b, c, d = S[0], S[1], S[2], S[3]
    op = ['+', '-']
    for i in op:
        moji_i = str(a)
        sum_i = a
        sum_i += b if i == '+' else -b
        moji_i += i + str(b)
        for j in op:
            sum_j = sum_i + c if j == '+' else sum_i-c
            moji_j = moji_i + j + str(c)
            for k in op:
                sum = sum_j + d if k == '+' else sum_j-d
                moji = moji_j + k + str(d)
                if sum == 7:
                    moji += '=7'
                    return print(moji)

if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
def saiki(s, siki, n):
  if n == 4 and eval(siki) == 7:
    print(siki+'=7')
    sys.exit(0)
  elif n == 4:
    return

  saiki(s, siki + '+' + s[n], n+1)
  saiki(s, siki + '-' + s[n], n+1)
  

  
s = input()

siki = s[0]

saiki(s, siki, 1)

Solution (Python):
ABCD = input()
n = len(ABCD)
for i in range(1<<(n-1)):
  s = int(ABCD[0])
  for j in range(n-1):
    if i>>j & 1:  
      s += int(ABCD[j+1])
    else:
      s -= int(ABCD[j+1])
  if s == 7:
    break
r = [ABCD[0]]
for k in range(n-1):
  if i>>k & 1:
    r.append('+')
  else:
    r.append('-')
  r.append(ABCD[k+1])
print('{}=7'.format(''.join(r)))

Solution (Python):
li = list(input())
pm = []
for i in range(8):
    l = []
    for j in range(3):
        if ((i>>j) & 1):
            l.append('+')
        else:
            l.append('-')
    pm.append(l)
lia = [0]*4
lisans =[0]
for i in range(4):
    lia[i] = int(li[i])
def search(lis):
    k = lia[0]
    for i in range(3):
        if lis[i] == '+':
            k += lia[i+1]
        if lis[i] == '-':
            k -=lia[i+1]
    return k
for i in range(8):
    lis = pm[i]
    ans = search(lis)
    if ans == 7:
        lisans = lis
        break
vic = [li[0]]
for i in range(3):
    vic.append(lisans[i])
    vic.append(li[i+1])
vic.append('=')
vic.append('7')
print(''.join(vic))

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

nums = list(map(int, list(input().rstrip('\r\n'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)

Solution (Python):
a,b,c,d = tuple(input())
import itertools
n = 3
for i in itertools.product(['-','+'], repeat=n):
    ans = a + i[0] + b + i[1] + c + i[2] + d
    if eval(ans) == 7:
        print(ans+'=7')
        exit()

Solution (Python):
a,b,c,d = [int(i) for i in input()]
if a+b+c+d == 7:
  ans = [str(a),'+',str(b),'+',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()
if a+b+c-d == 7:
  ans = [str(a),'+',str(b),'+',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a+b-c-d == 7:
  ans = [str(a),'+',str(b),'-',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b-c-d == 7:
  ans = [str(a),'-',str(b),'-',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b+c-d == 7:
  ans = [str(a),'-',str(b),'+',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a+b-c+d == 7:
  ans = [str(a),'+',str(b),'-',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b+c+d == 7:
  ans = [str(a),'-',str(b),'+',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b-c+d == 7:
  ans = [str(a),'-',str(b),'-',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()

Solution (Python):
A=input()
n=[int(a) for a in A]
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):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print(e[:-1]+'=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("{}+{}+{}+{}=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, b, c, d = map(int, list(input()))
for i in (-1,1):
  for j in (-1,1):
    for k in (-1,1):
      if a + i * b + j * c + k * d == 7:
        op1 = '+' * ((1+i)//2) + '-' * ((1-i)//2)
        op2 = '+' * ((1+j)//2) + '-' * ((1-j)//2)
        op3 = '+' * ((1+k)//2) + '-' * ((1-k)//2)
        print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
        exit()

Solution (Python):
a = [str(i) for i in input()]
op = ["+", "+", "+"]

for bit in range(2 ** len(op)):
	v = op.copy()
	for i in range(len(op)):
		if (bit >> i) & 1:
			v[i] = "-"
			
	if eval(a[0] + v[0] + a[1] + v[1] + a[2] + v[2] + a[3]) == 7:
		print(a[0] + v[0] + a[1] + v[1] + a[2] + v[2] + a[3] + "=7")
		exit()

Solution (Python):

s=input()


def dfs(i,num,ans):
    
    if i==3:
        if num==7:
            global memo
            memo=ans
        return 0
    dfs(i+1,num+int(s[i+1]),ans+"+"+str(s[i+1]))
    dfs(i+1,num-int(s[i+1]),ans+"-"+str(s[i+1]))
    return 0

memo=""
dfs(0,int(s[0]),s[0])
memo+="=7"
print(memo)

Solution (Python):
a,b,c,d = map(int,list(input()))
bb,cc,dd = '','',''
op = [1,-1]

for i in op:
	for j in op:
		for k in op:
			bb,cc,dd = i*b,j*c,k*d
			if a+bb+cc+dd == 7:
				if bb >= 0:
					bb = '+'+ str(b)
				if cc >= 0:
					cc = '+'+ str(c)
				if dd >= 0:
					dd = '+'+ str(d)
				ans = str(a)+str(bb)+str(cc)+str(dd)+'=7'

print(ans)

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from itertools import permutations

s = ns()

for op in range(2 ** 3):
    res = int(s[0])
    for i in range(3):
        if op >> i & 1:
            res += int(s[i + 1])
        else:
            res -= int(s[i + 1])
    if res == 7:
        print(s[0], end="")
        for i in range(3):
            print('+' if op >> i & 1 else '-', end="")
            print(s[i + 1], end="")
        print("=7")
        break

Solution (Python):
s = input()
l = len(s)
ans = ""

for bit in range(2**(l-1)):
  formula = ""
  for i in range(l):
    formula += s[i]
    if ((bit>>i) & 1) > 0:
      formula += "+"
    else:
      formula += "-"
  formula = formula[:len(formula)-1]
  if eval(formula) == 7:
    ans = formula+"=7"
    break
print(ans)

Solution (Python):
n = list(input())
for i in range(4):
    n[i] = int(n[i])

op1 = "+"
op2 = "+"
op3 = "+"

wa = sum(n)

if wa == 7:
    print(str(n[0])+op1+str(n[1])+op2+str(n[2])+op3+str(n[3])+"=7")
else:
    if wa - n[1]*2 == 7:
        op1 = "-"
    elif wa - n[2]*2 == 7:
        op2 = "-"
    elif wa -n[3]*2 == 7:
        op3 = "-"
    elif wa - n[1]*2 - n[2]*2 == 7:
        op1 = "-"
        op2 = "-"
    elif wa - n[1]*2 - n[3]*2 == 7:
        op1 = "-"
        op3 = "-"
    elif wa - n[2]*2 - n[3]*2 == 7:
        op2 = "-"
        op3 = "-"
    else:
        op1 = "-"
        op2 = "-"
        op3 = "-"

    print(str(n[0])+op1+str(n[1])+op2+str(n[2])+op3+str(n[3])+"=7")

Solution (Python):
s = list(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):
moji = list(input())
x = len(moji) -1
for i in range(2**x):
    ope = ['-'] * 3
    formula = ''
    for j in range(x):
        if (i>>j)&1:
            ope[j] = '+'
    for mo,op in zip(moji, ope+['']):
        formula += (mo+op)
    if eval(formula) == 7:
        print(formula, '=7', sep='')
        break

Solution (Python):
abcd = input()
l = len(abcd)

ans = ''
for i in range(2**(l-1)):
    s = int(abcd[0])
    tasi = abcd[0]
    for j in range(l-1):
        if i & 1<<j > 0:
            s += int(abcd[j+1])
            tasi += '+' + abcd[j+1]
        else:
            s -= int(abcd[j+1])
            tasi += '-' + abcd[j+1]
    if s == 7:
        ans = tasi + '=7'
print(ans)

Solution (Python):
n = input()

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

e = [1, -1]

ans = [0] * 3
for i in e:
  for j in e:
    for k in e:
      if a + b*i + c*j + d*k == 7:
        ans[0] = i
        ans[1] = j
        ans[2] = k

fugo = []
for i in ans:
  if i == 1:
    fugo.append("+")
  else:
    fugo.append("-")

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

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

for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            sum = A + (-1)**op1*B + (-1)**op2*C + (-1)**op3*D
            if sum == 7:
                ans = str(A)+oper[op1]+str(B)+oper[op2]+str(C)+oper[op3]+str(D)+'=7'
                break
print(ans)

Solution (Python):
s = list(map(int, input()))
ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0:
                c = s[0] + s[1]
            else:
                c = s[0] - s[1]
            if j == 0:
                c += s[2]
            else:
                c -= s[2]
            if k == 0:
                c += s[3]
            else:
                c -= s[3]    
            if c == 7:
                ans = [i, j, k]
                
for i in range(3):
    print(str(s[i]), end = "")
    if ans[i] == 0:
        print("+", end = "")
    else:
        print("-", end = "")
print(str(s[3]) + "=7")

Solution (Python):
import sys
abcd = input()
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            siki = a+sign[i]+b+sign[j]+c+sign[k]+d
            ans = eval(siki)
            if ans == 7 :
                print(siki + '=7')
                sys.exit()

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

Solution (Python):
str_input = list(input())
for i in range(2**3):
    ope = ['-'] * 3
    siki = ''
    for j in range(3):
        if(i>>j)&1:
            ope[j] = '+'
    for moji, op in zip(str_input, ope+['']):
        siki +=(moji+op)
    ans = eval(siki)
    if ans == 7:
        print(siki + '=7')
        break

Solution (Python):
a,b,c,d = list(input())
n = 2 ** 3
bit_pattern = []
for i in range(n):
    bit_flg = ["+"] * 3
    for j in range(n):
        if(i >> j & 1) == 1:
            bit_flg[j] = "-"
    bit_pattern.append(bit_flg)
for k in range(len(bit_pattern)):
    if eval(a + bit_pattern[k][0] + b + bit_pattern[k][1] + c + bit_pattern[k][2] + d) == 7:
        print(a+bit_pattern[k][0]+b+bit_pattern[k][1]+c+bit_pattern[k][2]+d+"=7")
        break

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False


def main():
    s = S()
    N = len(s)

    for i in range(2):
        for j in range(2):
            for k in range(2):
                A = int(s[0])
                B = int(s[1])
                C = int(s[2])
                D = int(s[3])
                ans = A
                op1 = '+' if i == 0 else '-'
                op2 = '+' if j == 0 else '-'
                op3 = '+' if k == 0 else '-'
                ans = ans + B if i == 0 else ans - B
                ans = ans + C if j == 0 else ans - C
                ans = ans + D if k == 0 else ans - D
                if ans == 7:
                    print(s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3] + '=7')
                    return

    print(-1)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools
L = list(input())
sm = ['+','-']
SM = list(itertools.product(sm,repeat=3))

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

Solution (Python):
n = input()
op_cnt = len(n)-1

for i in range(2**op_cnt):
    op = ['-'] * op_cnt
    siki = ''
    for j in range(op_cnt):
        if ((i>>j)&1):
            op[op_cnt-1-j] = '+'
    for moji, ope in zip(n, op+['']):
        siki += (moji+ope)
    if eval(siki) == 7:
        print(siki + '=7')
        break

Solution (Python):
a,b,c,d=input()
for i in range(2**3):
    ls=['+','+','+']
    for j in range(len(ls)):
        if (i>>j)&1:
            ls[j]='-'
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

Solution (Python):
a, b, c, d = [int(x) for x in input()]
ops = '+-'
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            tmp = a
            tmp = tmp + b if op1 == '+' else tmp - b
            tmp = tmp + c if op2 == '+' else tmp - c
            tmp = tmp + d if op3 == '+' else tmp - d
            if tmp == 7:
                print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + "=7")
                exit()

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