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

a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

for i in range(2**(4-1)):
    f = "{a}".format(a=a)
    if i>>0 & 1 == 1:
        f += "+{b}".format(b=b)
    else:
        f += "-{b}".format(b=b)
    
    if i>>1 & 1 == 1:
        f += "+{c}".format(c=c)
    else:
        f += "-{c}".format(c=c)

    if i>>2 & 1 == 1:
        f += "+{d}".format(d=d)
    else:
        f += "-{d}".format(d=d)

    result = eval(f)
    if result == 7:
        print(f + "=7")
        break

Solution (Python):
A = input()

for i in range(1 << len(A) - 1):
    ans_number = int(A[0])
    ans_sentense = A[0]
    for j in range(len(A) - 1):
        if ((i >> j)& 1) == 1:
            ans_number += int(A[j + 1])
            ans_sentense += "+" + A[j + 1]
        else:
            ans_number -= int(A[j + 1])
            ans_sentense += "-" + A[j + 1]
    if ans_number == 7:
        break
print(ans_sentense + "=7")

Solution (Python):
n = int(input())
a = []
for i in range(4):
    a.append(n%10)
    n //= 10
a.reverse()

OP = [['+', '-'] for i in range(3)]
PM = ['+', '-']
OP = []
for op1 in PM:
    for op2 in PM:
        for op3 in PM:
            OP.append([op1,op2,op3])

for op in OP:
    
    result = a[0]
    for i in range(len(op)):
        if op[i]=='+': result += a[i+1]
        else: result -= a[i+1]
    if result==7: break
        
print(a[0],end='')
for n in range(3):
    print('%s%d' % (op[n], a[n+1]), end='')
print('=7')

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

for op1 in O:
    for op2 in O:
        for op3 in O:
            f = a + op1 + b + op2 + c + op3 + d
            if eval(f) == 7:
                ans = f + '=7'
                break

print(ans)

Solution (Python):
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.append('-')
        flag = 1
        break
        
if flag == 1:
    print(A[0]+B[0]+A[1]+B[1]+A[2]+B[2]+A[3]+'=7')

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

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

Solution (Python):
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.append('-')
        flag = 1
        break
        
if flag == 1:
    print('{}{}{}{}{}{}{}{}'.format(A[0], B[0], A[1], B[1], A[2], B[2], A[3], '=7'))

Solution (Python):
import itertools
S=input()
TT=itertools.product(["+","-"],repeat=3)
for T in TT:
    A=S[0]+T[0]+S[1]+T[1]+S[2]+T[2]+S[3]
    if eval(A)==7:
        print(A+"=7")
        exit()

Solution (Python):
a = input()
ar = []
for i in range(len(a)):
    ar.append(a[i])
n = len(ar)
ret = 0
for i in range(2**(n-1)):
    p = "+"
    m = "-"
    tmp = ""
    flag = -1
    ret = int(ar[0])
    for j in range(n):
        if flag == 0:
            ret += int(ar[j])
        if flag == 1:
            ret -= int(ar[j])
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += p
            flag = 0
        else:
            tmp += ar[j]
            tmp += m
            flag = 1
    tmp = tmp[:-1]
    if ret == 7:
        break
print(tmp + "=7")

Solution (Python):
import itertools
import commands
num=raw_input()
num=list(num)

a=["+","-"]

for i in itertools.product(a,a,a):
    a=commands.getoutput("echo $(("+num[0]+i[0]+num[1]+i[1]+num[2]+i[2]+num[3]+"))")
    if(a=="7"):
        print(num[0]+i[0]+num[1]+i[1]+num[2]+i[2]+num[3]+"=7")
        break

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

A = int(A)
B = int(B)
C = int(C)
D = int(D)

def calc(a, b, c, d, s):
  for _b in [b, -b]:
    for _c in [c, -c]:
      for _d in [d, -d]:
        if a + _b + _c + _d == s:
          return a, _b, _c, _d
  return False


print('{}{:=+}{:=+}{:=+}=7'.format(*calc(A, B, C, D, 7)))

Solution (Python):
abcd = input()

a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

for i in range(2**(4-1)):
    f = "{a}".format(a=a)
    if i>>0 & 1 == 1:
        f += "+{b}".format(b=b)
    else:
        f += "-{b}".format(b=b)
    
    if i>>1 & 1 == 1:
        f += "+{c}".format(c=c)
    else:
        f += "-{c}".format(c=c)

    if i>>2 & 1 == 1:
        f += "+{d}".format(d=d)
    else:
        f += "-{d}".format(d=d)

    result = eval(f)
    if result == 7:
        print(f + "=7")
        break

Solution (Python):
s = str(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 = list(input())

oplist = ['+', '-']

for op1 in oplist:
    for op2 in oplist:
        for op3 in oplist:
            f = A + op1 + B + op2 + C + op3 + D
            ans = eval(f)
            if ans == 7:
                print(f + "=7")
                quit()

Solution (Python):
S = input()
op = ["+","-"]
for bit in range(1 << 3) :
    L = []
    for k in range(3) :
        if bit & (1 << k) :
            L.append(op[0])
        else :
            L.append(op[1])
    f = S[0]+L[0]+S[1]+L[1]+S[2]+L[2]+S[3]
    if eval(f) == 7 :
        ans = f + "=7"
        break
print(ans)

Solution (Python):
num = input()
ssa = [int(x) for x in num]
if ssa[0]+ssa[1]+ssa[2]+ssa[3] == 7:print('{}+{}+{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]+ssa[3] == 7:print('{}-{}+{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]+ssa[3] == 7:print('{}-{}-{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]-ssa[3] == 7:print('{}-{}-{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]+ssa[3] == 7:print('{}+{}-{}+{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]-ssa[3] == 7:print('{}+{}-{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]-ssa[3] == 7:print('{}-{}+{}-{}=7'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]+ssa[2]-ssa[3] == 7:print('{}+{}+{}-{}=7'.format(num[0],num[1],num[2],num[3]))

Solution (Python):
import sys

a = list(input())
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i % 2 == 0:
                sym1 = '+'
            else:
                sym1 = '-'
            if j % 2 == 0:
                sym2 = '+'
            else:
                sym2 = '-'
            if k % 2 == 0:
                sym3 = '+'
            else:
                sym3 = '-'
            word = a[0] + sym1 + a[1] + sym2 + a[2] + sym3 + a[3]

            ans = eval(word)
            if ans == 7:
                print(word+'=7')
                sys.exit()

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

patarn = -1

for i in range(1 << 3):
    summation = int(S[0])
    for j in range(3):
        if (i >> j) % 2 == 1:
            summation += int(S[j+1])
        else:
            summation -= int(S[j+1])
    if summation == 7:
        patarn = i

ans_equ = S[0]

for i in range(3):
    if (patarn >> i) % 2 == 1:
        ans_equ += '+' + S[i+1]
    else:
        ans_equ += '-' + S[i+1]

ans_equ += '=7'
print(ans_equ)

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

Solution (Python):
a  = input()
x = int(a[0])
y = int(a[1])
z = int(a[2])
w = int(a[3])
o = ["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0 and j == 0 and k == 0:
                if x + y + z + w == 7: p = [i,j,k]
            elif i == 0 and j == 0 and k == 1:
                if x + y + z - w == 7: p = [i,j,k]
            elif i == 0 and j == 1 and k == 0:
                if x + y - z + w == 7: p = [i,j,k]
            elif i == 1 and j == 0 and k == 0:
                if x - y + z + w == 7: p = [i,j,k]
            elif i == 1 and j == 1 and k == 0:
                if x - y - z + w == 7: p = [i,j,k]
            elif i == 0 and j == 1 and k == 1:
                if x + y - z - w == 7: p = [i,j,k]
            elif i == 1 and j == 0 and k == 1:
                if x - y + z - w == 7: p = [i,j,k]
            elif i == 1 and j == 1 and k == 1:
                if x - y - z - w == 7: p = [i,j,k]
print(str(x)+o[p[0]]+str(y)+o[p[1]]+str(z)+str(o[p[2]])+str(w)+"=7")

Solution (Python):
def func(i):
    S = format(i, "b")
    S = (3-len(S)) * "0" + S
    ret = [""] * 3
    for i in range(3):
        ret[i] = "+" if S[i] == "1" else "-"
    return ret


def calc(n, op):
    ret = int(n[0])
    for i in range(3):
        if op[i] == "+":
            ret += int(n[i+1])
        else:
            ret -= int(n[i+1])
    return ret


n = list(input())


for i in range(8):
    op = func(i)
    if calc(n, op) == 7:
        print(n[0]+op[0]+n[1]+op[1]+n[2]+op[2]+n[3]+"=7")
        break

Solution (Python):
import sys

def p(x, y):
    return x + y

def m(x, y):
    return x - y

A, B, C, D = map(int, raw_input())
for f1, c1 in ([p, '+'], [m, '-']):
    for f2, c2 in ([p, '+'], [m, '-']):
        for f3, c3 in ([p, '+'], [m, '-']):
            if f3(f2(f1(A, B), C), D) == 7:
                print "%d%s%d%s%d%s%d=7" % (A, c1, B, c2, C, c3, D)
                sys.exit()

Solution (Python):
a = list(map(int, input()))
for bs in range(8):
    sm = a[0]
    ret = str(a[0])
    for i in range(3):
        num = a[i + 1]
        if bs & 1 << i:
            sm += num
            ret += str("+")
        else:
            sm -= num
            ret += str("-")
        ret += str(num)
    if sm == 7:
        ret += "=7"
        break
print(ret)

Solution (Python):
a, b, c, d = list(map(int, input()))
flag = False
als = a + b + c + d
ret = ""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if als - (2 * i * b + 2 * j * c + 2 * k * d) == 7:
                ret += str(a)
                if i:
                    ret += "-"
                else:
                    ret += "+"
                ret += str(b)
                if j:
                    ret += "-"
                else:
                    ret += "+"
                ret += str(c)
                if k:
                    ret += "-"
                else:
                    ret += "+"
                ret += str(d)
                ret += "=7"
                flag = True
                break
        if flag:
            break
    if flag:
        break
print(ret)

Solution (Python):
import itertools


S = list(input())
signs = [',+'] * 3 + [',-'] * 3
three_signs = list(itertools.permutations(signs, 3))
for i in three_signs:
    tmp = [_ for _ in S]
    for j in range(len(i)):
        tmp.insert(3-j, i[j])
    tmp = ''.join(tmp)
    tmp = tmp.split(',')
    temp = ''.join(tmp)
    tmp = map(int, tmp)
    ans = sum(tmp)
    if ans == 7:
        print(temp+'=7')
        exit()

Solution (Python):
s = input()
flag = False
ans = ""
def f(temp, index):
  global ans
  if ans:
    return
  
  if len(temp) == 7:
    if eval(temp) == 7:
      ans = temp+"=7"
    return 
  
  f(temp + "+" + s[index], index+1)
  f(temp + "-" + s[index], index+1)

f(s[0], 1)

print(ans)

Solution (Python):
s = list(map(int,list(input())))
def search(i,current,signs):
    if i == 4:
        if current == 7:
            return signs
        else: return []
    return search(i+1,current+s[i],signs+['+']) + search(i+1,current-s[i],signs+['-'])
signs = search(1,s[0],[])
for i in range(4):
    if i == 3:
        print(s[i], end='')
    else:
        print(s[i], end='')
        print(signs[i], end='')
print('=7')

Solution (Python):
A = input()
a,b,c,d = A[0],A[1],A[2],A[3]
e1 = a+'+'+b+'+'+c+'+'+d
e2 = a+'+'+b+'+'+c+'-'+d
e3 = a+'+'+b+'-'+c+'+'+d
e4 = a+'+'+b+'-'+c+'-'+d
e5 = a+'-'+b+'+'+c+'+'+d
e6 = a+'-'+b+'+'+c+'-'+d
e7 = a+'-'+b+'-'+c+'+'+d
e8 = a+'-'+b+'+'+c+'-'+d
if eval(e1) == 7:
    print(e1+'=7')
elif eval(e2) == 7:
    print(e2+'=7')
elif eval(e3) == 7:
    print(e3+'=7')
elif eval(e4) == 7:
    print(e4+'=7')
elif eval(e5) == 7:
    print(e5+'=7')
elif eval(e6) == 7:
    print(e6+'=7')
elif eval(e7) == 7:
    print(e7+'=7')
elif eval(e8) == 7:
    print(e8+'=7')

Solution (Python):
ops = ["+", "-"]

def calc(op, a, b):
    if op == "+":
        return a + b
    else:
        return a - b

def solve(a, b, c, d):
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                if calc(op3, calc(op2, calc(op1, a, b), c), d) == 7:
                    print("{}{}{}{}{}{}{}=7".format(a,op1,b,op2,c,op3,d))
                    return

a, b, c, d = map(int, list(input()))
solve(a, b, c, d)

Solution (Python):
S = input()

for i in range(1 << (len(S)-1)):
    temp = int(S[0])
    ans = str(S[0])
    for j in range(len(S)-1):
        if ((i >> j) & 1) == 1:
            temp -= int(S[j+1])
            ans = ans + '-' + str(S[j+1])
        else:
            temp += int(S[j+1])
            ans = ans + '+' + str(S[j+1])
    if temp == 7:
        break
print(ans+'=7')

Solution (Python):
S = input()

for i in range(1<<(4-1)+1):
    eq = S[0:1]
    for j in range(1,len(S)):
        if i & 1 << j:
            eq += '+' + S[j:j+1]
        else:
            eq += '-' + S[j:j+1]
    if eval(eq) == 7:
        print(eq+'=7')
        break

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

def digitSum(s):
    x1 = s//10**4
    x2 = (s-x1*10**4)//10**3
    x3 = (s-x2*10**3-x1*10**4)//10**2
    x4 = (s-x3*10**2-x2*10**3-x1*10**4)//10
    x5 = (s-x4*10-x3*10**2-x2*10**3-x1*10**4)
    
    return x2,x3,x4,x5

a,b,c,d=digitSum(N)

suzi=[b,c,d]

puramai=[0,0,0]
i=0
answer=[0,0,0]
def tansaku(i,puramai,sum,answer):
    if i==3:
        if sum+a==7:
            answer[0]=puramai[0]
            answer[1]=puramai[1]
            answer[2]=puramai[2]
            return 
        else:
            return            
    sum+=suzi[i]
    puramai[i]='+'
    tansaku(i+1,puramai,sum,answer)

    sum=sum-2*suzi[i]
    puramai[i]='-'
    tansaku(i+1,puramai,sum,answer)
    

tansaku(0,puramai,0,answer)  

    
m=str(a)+answer[0]+str(b)+answer[1]+str(c)+answer[2]+str(d)+'=7'
print(m)

Solution (Python):
s = input()
a = []
for i in range(4):
    a.append(int(s[i]))
ans= 7- a[0]
for op in range(1<<3):
    sans = [str(a[0])]
    tmp = ans
    for i in range(3):
        if (op//2**i)%2 == 0:
            tmp -= a[i+1]
            sans.append('+')
            sans.append(str(a[i+1]))
        else:
            tmp += a[i+1]
            sans.append('-')
            sans.append(str(a[i+1]))
    if tmp == 0:
        break
for i in range(len(sans)):
    print(sans[i],end="")
print('=7')

Solution (Python):
def create_equ(eq, index):
    global L
    if index == 4:
        L.append(eq)
    else:
        create_equ(eq + "+" + S[index], index + 1)
        create_equ(eq + "-" + S[index], index + 1)


if __name__ == "__main__":
    S = list(input())
    index = 1
    eq = S[0]
    L = []
    create_equ(eq, index)
    for l in L:
        if eval(l) == 7:
            print(l + '=7')
            break

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

op = ['+','-']

for op1,op2,op3 in itertools.product(op,op,op):
  x = A + op1 + B + op2 + C + op3 + D
  if(eval(x) == 7):
    print(x + "=7")
    break

Solution (Python):
def abc079_c():
    n = list(map(int, input()))
    a = n[0]
    for b in [n[1], -n[1]]:
        for c in [n[2], -n[2]]:
            for d in [n[3], -n[3]]:
                if a + b + c + d == 7:
                    op1 = ["+", "-"][b < 0]
                    op2 = ["+", "-"][c < 0]
                    op3 = ["+", "-"][d < 0]
                    print(a, op1, abs(b), op2, abs(c), op3, abs(d), "=7", sep="")
                    return 0


abc079_c()

Solution (Python):
s = list(input())
d = 3
def operate1(string):
  string += "-"
  return string
def operate2(string):
  string += "+"
  return string
def bfs(list_hoge = [s[0]],depth = 0,deepest = d):
    queue = []
    for e in list_hoge:
        for b in [0,1]:
            if b == 0:
                operated = operate1(e)
                operated += s[depth + 1]
                queue.append(operated)
            elif b == 1:
                operated = operate2(e)
                operated += s[depth + 1]
                queue.append(operated)
    list_hoge = queue[:]
    depth += 1
    if depth == deepest:
        return list_hoge
    else:
        return bfs(list_hoge,depth)
for e in bfs():
  if eval(e) == 7:
    print(e + "=7")
    break

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

ops = ['+', '-']

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

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


for i in range(1 << 3):
    output = l[0]
    res = '{}'.format(l[0])
    for j in range(3):
        if ((i >> j) & 1) == 1:
            output += l[j+1]
            res += '+{}'.format(l[j+1])
        else:
            output -= l[j+1]
            res += '-{}'.format(l[j+1])
    if output ==7:
        res += '=7'
        print(res)
        exit()

Solution (Python):
def main():
    a, b, c, d = list(input())
    ops = ['+', '-']
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                s = a + op1 + b + op2 + c + op3 + d
                if eval(s) == 7:
                    print(s + '=7')
                    return


if __name__ == '__main__':
    main()

Solution (Python):
abcd = str(input())
n = 3
for bits in range(1 << n):
    x1 = '+'
    x2 = '+'
    x3 = '+'
    for i in range(n):
        if (bits >> i & 1) == 1:
            if i == 0:
                x1 = '-'
            if i == 1:
                x2 = '-'
            if i == 2:
                x3 = '-'
    check1 = abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3]
    check2 = eval(abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3])
    if check2 == 7:
        ans = check1
print(ans+'=7')

Solution (Python):
import itertools
L = input()
s = ['+','-']
for a, b, c in itertools.product(s, s, s):
   f = L[0] + a + L[1] + b + L[2] + c + L[3] 
   if eval(f) == 7:
       print(f+'=7')
       exit(0)

Solution (Python):
import itertools
L = input()
s = ['+','-']
t = ['+','-']
u = ['+','-']
for a, b, c in itertools.product(s, t, u):
   f = L[0] + a + L[1] + b + L[2] + c + L[3] 
   if eval(f) == 7:
       print(f+'=7')
       exit(0)

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

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')
    exit()
if a+b+c-d == 7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
    exit()
if a+b-c+d == 7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
    exit()
if a+b-c-d == 7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
    exit()
if a-b+c+d == 7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
    exit()
if a-b+c-d == 7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
    exit()
if a-b-c+d == 7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
    exit()
if a-b-c-d == 7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
    exit()

Solution (Python):
n = input()
sign = ["+", "-"]
for op1 in sign:
    for op2 in sign:
        for op3 in sign:
            f = n[0]+op1+n[1]+op2+n[2]+op3+n[3]
            if eval(n[0]+op1+n[1]+op2+n[2]+op3+n[3]) == 7:
                print(f + "=7")
                exit()

Solution (Python):
A, B, C, D = map(int, input())
for i in range(2):
	for j in range(2):
		for k in range(2):
			if A + B * (i * 2 - 1) + C * (j * 2 - 1) + D * (k * 2 - 1) == 7:
				print (A, "-+"[i], B, "-+"[j], C, "-+"[k], D, "=7", sep='')
				break
		else:
			continue
		break
	else:
		continue
	break

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


def operation(x):
    pattern = 2 ** len(x)
    for i in range(pattern):
        ops = '{:04b}'.format(i)
        s = 0
        for t, op in zip(x, ops):
            if op == '0':
                s += t
            else:
                s -= t
        if s == 7:
            return ops


ops = operation(x).replace('0', '+').replace('1', '-')
print(''.join([ops[i] + str(x[i]) for i in range(len(x))])[1:] + '=7')

Solution (Python):
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print('{0}{1}{2}{3}{4}{5}{6}=7'.format(A, sgn[0], B, sgn[1], C, sgn[2], D))
        exit()

Solution (Python):
L = input()
N = [int(i) for i in list(L)]
def check(n):
  if n == -1:
    return '-'
  else:
    return '+'
for i in range(2):
  for j in range(2):
    for k in range(2):
      if N[0] + N[1] * pow(-1, i) + N[2] * pow(-1, j) + N[3] * pow(-1, k) == 7:
        ii = check(pow(-1, i))
        jj = check(pow(-1, j))
        kk = check(pow(-1, k))
        print(str(N[0]) + ii + str(N[1]) + jj + str(N[2]) + kk + str(N[3]) + "=7")
        exit(0)

Solution (Python):
n = list(map(int,list(input())))
limit = 7
d = [ [] for i in range(len(n))]
op = [ [] for i in range(len(n))]

for i,val in enumerate(n):
	if i == 0:
		d[0].append(n[0])
		op[0].append("")
	else:
		for j in d[i-1]:
			d[i].append(j+val)
			d[i].append(j-val)
		for j in op[i-1]:
			op[i].append(j + "+")
			op[i].append(j + "-")


_op = op[len(n)-1][d[len(n)-1].index(limit)]

s = ""
for i,val in enumerate(n):
	s += str(val)
	if i == len(n)-1:
		break
	else:
		s += _op[i]
s += "="+str(limit)
print(s)

Solution (Python):
a = list(map(int, list(input())))
size = len(a)

for i in range(2**(size-1)):
    op = [(i >> j) & 1 for j in range(size)][::-1]
    tmp = [k * (-1)**j for j, k in zip(op, a)]
    if sum(tmp) == 7:
        s = ''.join([('-' if j == 1 else '+') + str(k) for j, k in zip(op, a)])
        print(s[1:] + '=7')
        break

Solution (Python):
def add(x, y, op):
    if op == '+':
        return x + y
    else:
        return x - y



def main():
    ops = ('+', '-')
    A, B, C, D = [int(i) for i in input()]

    for i in ops:
        for j in ops:
            for k in ops:
                s = 0
                s = add(A, B, i)
                s = add(s, C, j)
                s = add(s, D, k)
                if s == 7:
                    print('{}{}{}{}{}{}{}=7'.format(A, i, B, j, C, k, D))
                    return 0

if __name__ == "__main__":
    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("%d+%d+%d+%d=7"%(a,b,c,d))
elif a+b+c-d==7:
    print("%d+%d+%d-%d=7"%(a,b,c,d))
elif a+b-c+d==7:
    print("%d+%d-%d+%d=7"%(a,b,c,d))
elif a-b+c+d==7:
    print("%d-%d+%d+%d=7"%(a,b,c,d))
elif a-b+c-d==7:
    print("%d-%d+%d-%d=7"%(a,b,c,d))
elif a+b-c-d==7:
    print("%d+%d-%d-%d=7"%(a,b,c,d))
elif a-b-c+d==7:
    print("%d-%d-%d+%d=7"%(a,b,c,d))
elif a-b-c-d==7:
    print("%d-%d-%d-%d=7"%(a,b,c,d))

Solution (Python):
num_text = list(input())
a = int(num_text[3])
b = int(num_text[2])
c = int(num_text[1])
d = int(num_text[0])
sum = 0
flg = 0
sum = d + c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'-'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1

Solution (Python):
import math
import sys

N = input()

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


OP1 = ["+","-"]
OP2 = ["+","-"]
OP3 = ["+","-"]


for op1 in OP1:


    if op1 == "+":
        ab = a + b
    else:
        ab = a - b

    for op2 in OP2:
        if op2 == "+":
            abc = ab + c
        else:
            abc = ab - c

        for op3 in OP3:
            if op3 == "+":
                abcd = abc + d
            else:
                abcd = abc - d

            if abcd == 7:
                print("{}{}{}{}{}{}{}=7".format(a,op1,b,op2,c,op3,d))
                sys.exit(0)

Solution (Python):
A, B, C, D = (int(i) for i in str(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,b,c,d = map(int, list(input()))

for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            res = 0
            if op1=="+":
                res += a+b
            else:
                res += a-b
            if op2=="+":
                res += c
            else:
                res -= c
            if op3=="+":
                res += d
            else:
                res -= d
            if res==7:
                print("".join([str(a),op1,str(b),op2,str(c),op3,str(d),"=7"]))
                exit()

Solution (Python):
def getanswer(num, ops, total):
    idx = len(ops)
    if idx == 3:
        return ops if total == 7 else None
    return getanswer(num, ops + "+", total + num[idx+1]) or \
        getanswer(num, ops + "-", total - num[idx+1])


def main():
    num = [int(x) for x in input()]
    ops = getanswer(num, "", num[0])
    retval = ""
    for i in range(3):
        retval += str(num[i]) + ops[i]
    retval += str(num[3]) + "=7"
    print(retval)


if __name__ == "__main__":
    main()

Solution (Python):

def get_formula(a,b,c,d) :
	for f1 in range(2) :
		s = str(a)
		if (f1 == 0) :
			s += "+"
		else : 
			s += "-"
		
		s += str(b)
		for f2 in range(2) :
			s2 = s
			if (f2 == 0) :
				s2 += "+"
			else : 
				s2 += "-"
			
			s2 += str(c)
			for f3 in range(2) :
				s3 = s2
				if (f3 == 0) :
					s3 += "+"
				else : 
					s3 += "-"
				
				s3 += str(d)
				if (eval(s3) == 7) :
					return s3

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

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

Solution (Python):
S = list(str(input()))
A = S[0]
B = S[1]
C = S[2]
D = S[3]
a = int(A)
b = int(B)
c = int(C)
d = int(D)
if a+b+c+d == 7:
    print(A+"+"+B+"+"+C+"+"+D+"=7")
elif a-b+c+d == 7:
    print(A+"-"+B+"+"+C+"+"+D+"=7")
elif a+b-c+d == 7:
    print(A+"+"+B+"-"+C+"+"+D+"=7")
elif a+b+c-d == 7:
    print(A+"+"+B+"+"+C+"-"+D+"=7")
elif a-b-c+d == 7:
    print(A+"-"+B+"-"+C+"+"+D+"=7")
elif a-b+c-d == 7:
    print(A+"-"+B+"+"+C+"-"+D+"=7")
elif a+b-c-d == 7:
    print(A+"+"+B+"-"+C+"-"+D+"=7")
elif a-b-c-d == 7:
    print(A+"-"+B+"-"+C+"-"+D+"=7")

Solution (Python):
import itertools
A, B, C, D = [int(_) for _ in input()]
B = [-B, B]
C = [-C, C]
D = [-D, D]
for i, j, k in itertools.product(range(2), repeat=3):
    if A + B[i] + C[j] + D[k] == 7:
        print('+'.join(map(str, [A, B[i], C[j], D[k]])).replace('+-', '-') + '=7')
        exit()

Solution (Python):
n = list(input())
def saiki(list_1,list_2,t): 
    for e in list_1:
        for b in [0,1]:
            if b == 0:
                list_2.append(e + "+" + n[t])
            elif b == 1:
                list_2.append(e + "-" + n[t])
    list_1.clear()
    if t < 3:
        return saiki(list_2,list_1,t+1)
    else:
        return list_2
list_1 = [n[0]]
list_2 = []
t = 1
list_3 = saiki(list_1,list_2,t)
for i in list_3:
    result = int(i[0])
    for j in [1,3,5]:
        if i[j] == "+":
            result += int(i[j+1])
        elif i[j] == "-":
            result -= int(i[j+1])
    if result == 7:
        print(i + "=7")
        exit()

Solution (Python):
from sys import exit
def fun(arr,i,j,k):
    ans = arr[0]
    if i == '+':
        ans += arr[1]
    else:
        ans += -arr[1]
    if j == '+':
        ans += arr[2]
    else:
        ans -= arr[2]
    if k == '+':
        ans += arr[3]
    else:
        ans -= arr[3]
    return ans
s = raw_input().strip()
s = [int(x) for x in s]
for i in ['+','-']:
    for j in ['+','-']:
        for k in ['+','-']:
            if fun(s,i,j,k) == 7:
                print str(s[0])+i+str(s[1])+j+str(s[2])+k+str(s[3])+"=7"
                exit(0)