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 = list(input())
ar = [["+","-"],["+","-"],["+","-"]]
count = 0
t = 0
for x in ar[0]:
    for y in ar[1]:
        for z in ar[2]:
            count += int(a[0])
            if x == "+":
                count += int(a[1])
            elif x == "-":
                count -= int(a[1])
            if y == "+":
                count += int(a[2])
            elif y == "-":
                count -= int(a[2])
            if z == "+":
                count += int(a[3])
            elif z == "-":
                count -= int(a[3])
            if count == 7 and t ==0:
                print(a[0]+x+a[1]+y+a[2]+z+a[3]+"=7")
                t += 1
            count = 0

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


def caliculation(sum, operator, _input):
    if op[operator] == "+":
        sum += _input
    elif op[operator] == "-":
        sum -= _input
    return sum


for i in range(2):
    for j in range(2):
        for k in range(2):
            sum = int(s[0])
            sum = caliculation(sum, i, int(s[1]))
            sum = caliculation(sum, j, int(s[2]))
            sum = caliculation(sum, k, int(s[3]))
            if sum == 7:
                print("{}{}{}{}{}{}{}{}".format(s[0], op[i], s[1], op[j], s[2], op[k], s[3], "=7"))
                exit()

Solution (Python):
S = input()
op = ["+", "-"]
for a in op:
    for b in op:
        for c in op:
            f = S[0] + a + S[1] + b + S[2] + c + S[3]
            if eval(f) == 7:
                print(f + "=7")
                break
        else:
            continue
        break
    else:
        continue
    break

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

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

Solution (Python):
abcd = input()

for i in range(1<<3):
	formula = abcd[0]
	for j in range(3):
		formula += "+-"[(i>>j)%2]
		formula += abcd[j+1]
	if eval(formula) == 7:
		print(formula + "=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):
NN = list(input())
 
for i in range(2**3):
    N = NN[:]
    for j in range(3):
        if i & 2**j:
            if j == 0:
                N.insert(1, '+')
            elif j == 1:
                N.insert(3, '+')
            else:
                N.insert(5, '+')
        else:
            if j == 0:
                N.insert(1, '-')
            elif j == 1:
                N.insert(3, '-')
            else:
                N.insert(5, '-')
    if eval(''.join(N)) == 7:
        print(''.join(N)+'=7')
        break

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

for i in range(2**3):
    N = NN[:]
    for j in range(3):
        if i & (1 << j):
            if j == 0:
                N.insert(1, '+')
            elif j == 1:
                N.insert(3, '+')
            else:
                N.insert(5, '+')
        else:
            if j == 0:
                N.insert(1, '-')
            elif j == 1:
                N.insert(3, '-')
            else:
                N.insert(5, '-')
    if eval(''.join(N)) == 7:
        print(''.join(N)+'=7')
        break

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

for i in range(8):
    result = ABCD[0]
    for j in range(3):
        if (1<<j & i)>>j:
            result += ABCD[j+1]
        else:
            result -= ABCD[j+1]

    if result == 7:
        result = i
        break

print(ABCD[0], end='')
print('+' if 1 & result else '-', end='')
print(ABCD[1], end='')
print('+' if 10 & result else '-', end='')
print(ABCD[2], end='')
print('+' if 100 & result else '-', end='')
print(str(ABCD[3]) + '=7')

Solution (Python):
n = input()
s = [int(i) for i in n]
v = 0
w = ''
for p in range(2):
  if p == 0:
    v = s[0] + s[1]
    w = n[0] + "+" + n[1]
  else:
    v = s[0] - s[1]
    w = n[0] + "-" + n[1]
  for q in range(2):
    if q == 0 and p == 0:
      v += +s[2]
      w += "+" + n[2]
    elif q == 1 and p == 0:
      v = s[0] + s[1] - s[2]
      w =  n[0] + "+" + n[1] + "-" + n[2]
    elif q == 0 and p == 1:
      v += +s[2]
      w += "+" + n[2]
    elif q == 1 and p == 1: 
      v = s[0] - s[1] - s[2]
      w =  n[0] + "-" + n[1] + "-" + n[2]
    for r in range(2):
      if r == 0:
        if v+s[3] == 7:
          print(w + "+" + n[3] + "=7")
          exit()
      else:
        if v-s[3] == 7:
          print(w + "-" + n[3] + "=7")
          exit()

Solution (Python):
if __name__=='__main__':
  sums=0
  num=[x for x in range(1,4)]
  S=list(map(int,input()))
  answer=[S[0],'a',S[1],'b',S[2],'c',S[3]]
  for i in range(1<<3):
    output=[]
    for j in range(3):
      if ((i>>j)&1)==1:
        output.append(num[j])
    plus=[S[o] for o in output]
    sabun=list(filter(lambda x: x not in output, num))
    mins=[S[m] for m in sabun]
    if sum(plus)-sum(mins)+S[0]==7:
      for o in output:
        answer[2*o-1]='+'
      for m in sabun:
        answer[2*m-1]='-'
      answer=map(str, answer)
      print(''.join(answer)+'=7')
      break

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

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

Solution (Python):
num_str = list(str(input()))
num = []
for i in range(4):
    num.append(int(num_str[i]))
if num[0] + num[1] + num[2] + num[3] == 7:
    print(num[0], "+", num[1], "+", num[2], "+", num[3], "=7", sep="")
    
elif num[0] - num[1] + num[2] + num[3] == 7:
    print(num[0], "-" ,num[1] ,"+", num[2] ,"+" ,num[3] ,"=7", sep="")
    
elif num[0] + num[1] - num[2] + num[3] == 7:
    print(num[0], "+" ,num[1] ,"-" ,num[2], "+", num[3] ,"=7", sep="")
    
elif num[0] + num[1] + num[2] - num[3] == 7:
    print(num[0], "+", num[1], "+" ,num[2], "-", num[3], "=7", sep="")
    
elif num[0] - num[1] - num[2] + num[3] == 7:
    print(num[0] ,"-" ,num[1], "-" ,num[2] ,"+" ,num[3] ,"=7", sep="")
    
elif num[0] - num[1] + num[2] - num[3] == 7:
    print(num[0] ,"-" ,num[1] ,"+" ,num[2] ,"-", num[3], "=7", sep="")
    
elif num[0] - num[1] - num[2] - num[3] == 7:
    print(num[0] ,"-", num[1], "-" ,num[2] ,"-", num[3],"=7", sep="")
    
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(num[0], "+" ,num[1] ,"-" ,num[2], "-" ,num[3], "=7", sep="")

Solution (Python):
import queue

def check(operator_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operator_list):
        if op == '+':
            res += num_list[i + 1]
        elif op == '-':
            res -= num_list[i + 1]

    return res == 7

def concat(operator_list, num_list):
    res = str(num_list[0])
    for op, num in zip(operator_list, num_list[1:]):
        res += op
        res += str(num)

    return res + "=7"

def solve():
    line = input()
    num_list = []
    for s in line:
        num_list.append(int(s))

    q = queue.Queue()
    q.put([])
    N = len(num_list)
    while not q.empty():
        operator_list = q.get()
        
        if len(operator_list) == N - 1:
            if check(operator_list, num_list):
                return concat(operator_list, num_list)

        else:
            q.put(operator_list + [ '+' ])
            q.put(operator_list + [ '-' ])

    return "No Answer"


print(solve())

Solution (Python):
def check(operator_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operator_list):
        if op == '+':
            res += num_list[i + 1]
        elif op == '-':
            res -= num_list[i + 1]

    return res == 7

def concat(operator_list, num_list):
    res = str(num_list[0])
    for op, num in zip(operator_list, num_list[1:]):
        res += op
        res += str(num)

    return res + "=7"

def solve():
    line = input()
    num_list = []
    for s in line:
        num_list.append(int(s))

    stack = []
    stack.append([])
    N = len(num_list)
    while len(stack) > 0:
        operator_list = stack.pop()
        
        if len(operator_list) == N - 1:
            if check(operator_list, num_list):
                return concat(operator_list, num_list)

        else:
            stack.append(operator_list + [ '+' ])
            stack.append(operator_list + [ '-' ])

    return "No Answer"


print(solve())

Solution (Python):
import sys

def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    num_list = list(map(str, num_list))
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        
        string += op
        string += num
    string += "=7"
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0):
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) 
            stack.append(l + ["-"])

    print(result)

if __name__ == "__main__":
    main()

Solution (Python):
nums = map(int, list(raw_input()))
ans = None
for op1 in ("+", "-"):
  for op2 in ("+", "-"):
    for op3 in ("+", "-"):
      x = nums[0]
      x += nums[1] * (1 if op1 == "+" else -1)
      x += nums[2] * (1 if op2 == "+" else -1)
      x += nums[3] * (1 if op3 == "+" else -1)
      if x == 7:
        ans = str(nums[0])+op1+str(nums[1])+op2+str(nums[2])+op3+str(nums[3])+"=7"
    if ans:
      break
  if ans:
    break
print ans

Solution (Python):
ABCD=input()
def Op_change(a):
  if a==1:
    return "+"
  elif a==-1:
    return "-"
  else:
    return ""
A=int(ABCD[0])
B=int(ABCD[1])
C=int(ABCD[2])
D=int(ABCD[3])
Op=[1,-1]
Op_List=[]
Flag=0
for i in Op:
  for j in Op:
    for k in Op:
      if A+i*B+j*C+k*D==7:
        Flag=1        
        Op_List.append(Op_change(i))
        Op_List.append(Op_change(j))
        Op_List.append(Op_change(k))
        break
    if Flag==1:
      break
  if Flag==1:
      break
print(str(A)+Op_List[0]+str(B)+Op_List[1]+str(C)+Op_List[2]+str(D)+"=7")

Solution (Python):
s = input()
abcd = [int(a) for a in s]
flg = 0
for i in range(2**3):
    if flg != 0:
        break
    bin_i = format(i, '03b')
    ops = [int(a)*2-1 for a in bin_i]
    sum = abcd[0]
    for j in range(3):
        sum += ops[j]*abcd[j+1]
        if sum==7:
            flg = 1
            break

ans = s[0]
for j in range(3):
    if ops[j]==1:
        a = '+'
    else:
        a = '-'
    ans += a+s[j+1]
print(ans+'=7')

Solution (Python):
N = input()

A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
ans1 = A+B+C+D
ans2 = A+B+C-D
ans3 = A+B-C+D
ans4 = A+B-C-D
ans5 = A-B+C+D
ans6 = A-B+C-D
ans7 = A-B-C+D
ans8 = A-B-C-D

if ans1 == 7:
	print('%d+%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d+%d-%d=7' % (A, B, C, D))
elif ans3 == 7:
	print('%d+%d-%d+%d=7' % (A, B, C, D))
elif ans4 == 7:
	print('%d+%d-%d-%d=7' % (A, B, C, D))
elif ans5 == 7:
	print('%d-%d+%d+%d=7' % (A, B, C, D))
elif ans6 == 7:
	print('%d-%d+%d-%d=7' % (A, B, C, D))
elif ans7 == 7:
	print('%d-%d-%d+%d=7' % (A, B, C, D))
else:
	print('%d-%d-%d-%d=7' % (A, B, C, D))

Solution (Python):
from itertools import zip_longest

abcd = input()

for i in range(0, 8):
	signs = bin(i)[2:].zfill(3).replace("1", "+").replace("0", "-")
	formula = "".join("".join(s) for s in zip_longest(abcd, signs, fillvalue=""))
	if eval(formula) == 7:
		print(formula+"=7")
		exit()

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

op = ('+', '-')

flag = False
for op1 in op:
    for op2 in op:
        for op3 in op:
           if eval(A+op1+B+op2+C+op3+D) == 7:
                flag = True
                break
        if flag: break
    if flag: break

print(A+op1+B+op2+C+op3+D+'=7')

Solution (Python):
def dfs(i,total,s=""):
    if i == 3:
        if total == 7:
            return s
        else:
            return False

    s += "+"
    ans = dfs(i+1, total+l[i+1], s)
    if ans:
        return ans

    s = s[:-1]
    s += "-"
    ans = dfs(i+1, total-l[i+1], s)
    if ans:
        return ans


l = list(map(int,input()))
operation = dfs(0,l[0])
result = ""

for i in range(3):
    result += str(l[i]) + operation[i]
print(result + str(l[3]) + "=7")

Solution (Python):
a,b,c,d = list(map(int,list(input())))
ans = []
if a+b+c+d == 7:
    ans = ['+','+','+']
elif a+b+c-d == 7:
    ans = ['+','+','-']
elif a+b-c-d == 7:
    ans = ['+','-','-']
elif a+b-c+d == 7:
    ans = ['+','-','+']
elif a-b+c-d == 7:
    ans = ['-','+','-']
elif a-b-c-d == 7:
    ans = ['-','-','-']
elif a-b-c+d == 7:
    ans = ['-','-','+']
else:
    ans = ['-','+','+']

print('{}{}{}{}{}{}{}=7'.format(a,ans[0],b,ans[1],c,ans[2],d))

Solution (Python):
a,b,c,d=map(int,input())
s=[1,-1]
f=['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+b*s[i]+c*s[j]+d*s[k]==7:
                    print(str(a)+f[i]+str(b)+f[j]+str(c)+f[k]+str(d)+'=7')
                    exit()

Solution (Python):

import sys

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

op = ["+", "-"]
for i in range(2):
    ans = a
    if i == 0:
        ans += b
    else:
        ans -= b
    ans1 = ans
    for j in range(2):
        ans = ans1
        if j == 0:
            ans += c
        else:
            ans -= c
        ans2 = ans
        for k in range(2):
            ans = ans2
            if k == 0:
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(str(a) + op[i] + str(b) + op[j] + str(c) + op[k] + str(d) + "=7")
                sys.exit()

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

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

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

if A+B+C+D==7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D==7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B-C+D==7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B+C+D==7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B-C-D==7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B+C-D==7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D==7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B-C-D==7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Solution (Python):

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

for i in range(8):
    opB = 2 * int(i & 1 > 0) - 1
    opC = 2 * int(i & 2 > 0) - 1
    opD = 2 * int(i & 4 > 0) - 1
    if A + opB * B + opC * C + opD * D == 7: break

ans = str(A)
for opX, X in [(opB, str(B)), (opC, str(C)), (opD, str(D))]:
    ans += "+" if opX > 0 else "-"
    ans += X
ans += "=7"

print(ans)

Solution (Python):


import itertools

if __name__=='__main__':
    str = input()
    signs_comb = list(itertools.product([1, -1], repeat=3))
    for signs in signs_comb:
        sum = int(str[0])
        for i in range(3):
            sum += signs[i] * int(str[i + 1])
        if sum == 7:
            sign_char = ['+' if i==1 else '-' for i in signs]
            break
    exp = str[0] + sign_char[0] + str[1] + sign_char[1] + str[2] + sign_char[2] + str[3] + '=7'
    print(exp)

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

Solution (Python):
def solve(ABCD):
    for i in range(0, 8):
        ops = "{:03b}".format(i)
        op1 = "+" if ops[0] == "0" else "-"
        op2 = "+" if ops[1] == "0" else "-"
        op3 = "+" if ops[2] == "0" else "-"
        s = ABCD[0] + op1 + ABCD[1] + op2 + ABCD[2] + op3 + ABCD[3]
        if eval(s) == 7:
            return s + "=7"
    return "error"


if __name__ == "__main__":
    ABCD = input()
    print(solve(ABCD))

Solution (Python):
x = list(map(int, list(input())))
y = [0] * 4
for i in range(8):
    y[0] = x[0]
    s = y[0]
    p = list(map(int, list(format(i, '03b'))))
    for j in range(3):
        y[j + 1] = (2 * p[j] - 1) * x[j + 1]
        s += y[j + 1]
    if s == 7:
        print('{}{:+d}{:+d}{:+d}=7'.format(y[0], y[1], y[2], y[3]))
        exit()

Solution (Python):
def 解():
    aD = [int(_) for _ in list(input().rstrip())]
    iA = 2**3
    for i in range(iA):
        iR = aD[0]
        for j in range(3):
            if i & (1 << j) :
                iR += aD[j+1]
            else:
                iR -= aD[j+1]
        if iR == 7:
            sR = str(aD[0])
            def buildSS(b):
                if b :
                    return "+"
                else:
                    return "-"
            for j in range(3):
                sR = "".join((sR,buildSS(i&(1<<j)),str(aD[j+1])))
            print("".join((sR,"=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('%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):
A, B, C, D = map(int, list(input()))

f = True

for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            if f == True:
                R = 0
                r = ''
                if op1 == 0:
                    R = A + B
                    r = '%s+%s' % (A, B)
                else:
                    R = A - B
                    r = '%s-%s' % (A, B)
                if op2 == 0:
                    R += C
                    r = '%s+%s' % (r, C)
                else:
                    R -= C
                    r = '%s-%s' % (r, C)
                if op3 == 0:
                    R += D
                    r = '%s+%s' % (r, D)
                else:
                    R -= D
                    r = '%s-%s' % (r, D)
                if R == 7:
                    print('%s=7' % r)
                    f = False

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

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

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

sum = nums[0]
ans = ""
a = ""
check = False
for i in range(2):
    if check:
        break
    else:
        sum = nums[0]
        ans = s[0]
    if i == 0:
        sum += nums[1]
        ans += "+"
    else:
        sum -= nums[1]
        ans += "-"
    ans += s[1]
    for j in range(2):
        sum2 = sum
        ans2 = ans
        if j == 0:
            sum2 += nums[2]
            ans2 += "+"
        else:
            sum2 -= nums[2]
            ans2 += "-"
        ans2 += s[2]
        for k in range(2):
            sum3 = sum2
            ans3 = ans2
            if k == 0:
                sum3 += nums[3]
                ans3 += "+"
            else:
                sum3 -= nums[3]
                ans3 += "-"
            ans3 += s[3]
            if sum3 == 7:
                check = True
                a = ans3
a += "=7"
print(a)

Solution (Python):
n = list(input())
for i in range(8):
    ans = n[0]
    ans += '+-'[i%2] + n[1]
    ans += '+-'[i//4] + n[2]
    ans += '+-'[(i%4)//2] + n[3]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Solution (Python):

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

n=8
bit=0
while(bit<n):
    tmp=ABCD[0]
    for i in range(0,3):
        if(bit & 1<<i):
            tmp+=ABCD[i+1]
        else:
            tmp-=ABCD[i+1]
    if(tmp==7):
        break
    else:
        bit+=1

print(ABCD[0],end="")
for i in range(0,3):
    if(bit & 1<<i):
        print("+{}".format(ABCD[i+1]),end="")
    else:
        print("-{}".format(ABCD[i+1]),end="")        
print("=7")

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

op = ['+', '-']

for i in op:
    for j in op:
        for k in op:
            f = A + i + B + j + C + k + D
            if eval(f) == 7:
                print(f + '=7')
                exit()

Solution (Python):
def pumi(i):
    if i == 0:
        H = '+'
    else:
        H = '-'
    return H
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
flag = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            if A +(1-2*i)*B +(1-2*j)*C + (1-2*k)*D == 7:
                flag = 1
                break
        if flag == 1:
             break
    if flag == 1:
        break
H = str(A)+pumi(i)+str(B)+pumi(j)+str(C)+pumi(k)+str(D)+'=7'
print(H)

Solution (Python):
def Cal(A, B, op):
    if op == "+":
        return A + B
    else:
        return A - B

Num = input()
OP = ["---", "--+", "-+-", "-++", "+--", "+-+", "++-", "+++"]

for o in OP:
    Sum = Cal(int(Num[0]), int(Num[1]), o[0])
    Sum = Cal(Sum, int(Num[2]), o[1])
    Sum = Cal(Sum, int(Num[3]), o[2])
    if Sum == 7:
        print(Num[0]+o[0]+Num[1]+o[1]+Num[2]+o[2]+Num[3]+"=7")
        break

Solution (Python):
import sys
from operator import add, sub

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

for i in range(2):
    if i == 0:
        op1 = add
    else:
        op1 = sub
    for j in range(2):
        if j == 0:
            op2 = add
        else:
            op2 = sub
        for k in range(3):
            if k == 0:
                op3 = add
            else:
                op3 = sub

            if op3(op2(op1(A, B), C), D) == 7:
                op1 = "+" if i == 0 else "-"
                op2 = "+" if j == 0 else "-"
                op3 = "+" if k == 0 else "-"
                print(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7")
                sys.exit()

Solution (Python):
abcd = list(input())
l = list(map(int,abcd))
ans_list = []
ans_list.append(l[0]+l[1]+l[2]+l[3])
ans_list.append(l[0]+l[1]+l[2]-l[3])
ans_list.append(l[0]+l[1]-l[2]+l[3])
ans_list.append(l[0]+l[1]-l[2]-l[3])
ans_list.append(l[0]-l[1]+l[2]+l[3])
ans_list.append(l[0]-l[1]+l[2]-l[3])
ans_list.append(l[0]-l[1]-l[2]+l[3])
ans_list.append(l[0]-l[1]-l[2]-l[3])

for i in range(7):
	if ans_list[i] == 7:
		if i == 0:
			print(str(l[0])+'+'+str(l[1])+'+'+str(l[2])+'+'+str(l[3])+'=7')
			break
		elif i == 1:
			print(str(l[0])+'+'+str(l[1])+'+'+str(l[2])+'-'+str(l[3])+'=7')
			break
		elif i == 2:
			print(str(l[0])+'+'+str(l[1])+'-'+str(l[2])+'+'+str(l[3])+'=7')
			break
		elif i == 3:
			print(str(l[0])+'+'+str(l[1])+'-'+str(l[2])+'-'+str(l[3])+'=7')
			break
		elif i == 4:
			print(str(l[0])+'-'+str(l[1])+'+'+str(l[2])+'+'+str(l[3])+'=7')
			break
		elif i == 5:
			print(str(l[0])+'-'+str(l[1])+'+'+str(l[2])+'-'+str(l[3])+'=7')
			break
		elif i == 6:
			print(str(l[0])+'-'+str(l[1])+'-'+str(l[2])+'+'+str(l[3])+'=7')
			break
		elif i == 7:
			print(str(l[0])+'-'+str(l[1])+'-'+str(l[2])+'-'+str(l[3])+'=7')
			break

Solution (Python):
a, b, c, d = list(input())
ops = ['+', '-']
fin = False
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = a+op1+b+op2+c+op3+d
            res = eval(s)
            if res == 7:
                print(s+'=7')
                fin = True
                break
        if fin == True:
            break
    if fin == True:
        break

Solution (Python):


s = input()
l = [0]*7
pm = [ '+', '-' ]

for i in range(0,len(s)):
  
  l[i*2]=s[i]

exp=""

def opeval(x,op,y):
  res = 0
  if op == '+':
    res = x + y
  else:
    res = x - y
  return res

def walk(l):
  res = int(l[0])
  for i in range(0,len(l)-2,2):
    res = opeval( res, l[i+1], int(l[i+2]))
    
  return res

for i in range(0,2):
  l[1]=pm[i]
  for j in range(0,2):
    l[3]=pm[j]
    for k in range(0,2):
      l[5]=pm[k]
      res=walk(l)
      if res==7:
        exp = ''.join(l)
        exp = exp + '=7'
    


print(exp)

Solution (Python):
a, b, c, d = list(input())
op = '+-'
ans = ''
for i in op:
    for j in op:
        for k in op:
            cal = a+i + b+j + c+k + d
            if eval(cal) == 7:
                ans = cal + '=7'
print(ans)

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

a = [0,0,0,0]
for i in range(4):
    a[i] = int(n[i])

op = [0,0,0]
for i in range(8):
    temp = i
    for j in range(3):
        op[j] = temp % 2
        temp //= 2

    check = 0
    ans = a[0]
    for j in range(3):
        if op[j] == 0:
            ans += a[j + 1]
        else:
            ans -= a[j + 1]
    if ans == 7:
        s = str(a[0])
        for j in range(3):
            if op[j] == 0:
                s = s + "+" + str(a[j + 1])
            else:
                s = s + "-" + str(a[j + 1])
        s += "=7"
        print(s)
        exit()

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

sum = 0
for i in range(4):
    sum = sum + n[i]


if sum == 7:
    print(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')

else:
    if 4*n[1] == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()

    if 4*n[2] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()
    if 4*n[3] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[1] + n[2])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[3] + n[2])  == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 2*n[1] + 2*n[3] == sum - 7:
        print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[1] + n[2] + n[3])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')

Solution (Python):

import itertools
ope = ['+','-']
ope_list = itertools.product(ope, repeat=3)

In = list(map(int, list(input())))




for op1,op2,op3 in ope_list:
    if op1 == '+':
        tmp1 = In[0] + In[1]
    else:
        tmp1 = In[0] - In[1]

    if op2 == '+':
        tmp2 = tmp1 + In[2]
    else:
        tmp2 = tmp1 - In[2]

    if op3 == '+':
        tmp3 = tmp2 + In[3]
    else:
        tmp3 = tmp2 - In[3]

    if tmp3 == 7:
        print('{0}{1}{2}{3}{4}{5}{6}=7'.format(In[0],op1,In[1],op2,In[2],op3,In[3]))
        exit()

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

op = ["+", "-"]
for i in op:
    for j in op:
        for k in op:
            cal = a + i + b + j + c + k + d
            if eval(cal) == 7:
                ans = cal + "=7"

print(ans)

Solution (Python):
s=input()
l=['+']*3+['']
for k in range(7):
  a=''.join([i+j for i,j in zip(s,l)])
  if eval(a)==7:
    print(a+'=7')
    break
  l=list(bin(k+1)[2:].zfill(3).replace('0','+').replace('1','-'))+['']

Solution (Python):
i=input()

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

if a+b+c+d==7:
    x="+"
    y="+"
    z="+"
elif a+b+c-d==7:
    x="+"
    y="+"
    z="-"
elif a+b-c+d==7:
    x="+"
    y="-"
    z="+"    
elif a-b+c+d==7:
    x="-"
    y="+"
    z="+"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b+c-d==7:
    x="-"
    y="+"
    z="-"
elif a+b-c-d==7:
    x="+"
    y="-"
    z="-"
elif a-b-c-d==7:
    x="-"
    y="-"
    z="-"
    
    
print(a,end="")
print(x,end="")
print(b,end="")
print(y,end="")
print(c,end="")
print(z,end="")
print(d,end="")
print("=7")

Solution (Python):
a=list(input())
l = ["+","-"]

for p in l:
  for q in l:
    for r in l:
      x = a[0]+p+a[1]+q+a[2]+r+a[3]
      if eval(x) == 7:
        print(x+  '=7')
        exit()

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

Solution (Python):
a = list(input())
l = ["+", "-"]
for p in l:
  for q in l:
    for r in l:
      x = a[0]+p+a[1]+q+a[2]+r+a[3]
      if eval(x) == 7:
        print(x + "=7")
        exit()