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 sys
N = int(input())
a = int(N//1000)
N = N-1000*a
b = int(N//100)
N = N-100*b
c = int(N//10)
N = N-10*c
d = int(N)
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
  sys.exit()
if a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
  sys.exit()
if a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
  sys.exit()
if a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
  sys.exit()
if a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
  sys.exit()

Solution (Python):
X = input()
a = int(X[0])
b = int(X[1])
c = int(X[2])
d = int(X[3])
end = 0
res = a
L = ['+', '-']

for i in L:
    if end == 1:
        break
    for j in L:
        if end == 1:
            break
      
        for k in L:
            res = a
            if i == '+':
                res += b
            else:
                res -= b
            
            if j == '+':
                res += c 
            else:
                res -= c
                
            if k == '+':
                res += d
            else:
                res -= d
            
            if res == 7:
                end = 1
                print(str(a) + i + str(b) + j + str(c) +  str(k) + str(d) + '=7')
                break

Solution (Python):
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	"""
	DP: 動的計画法を用いる
	"""
	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()

if __name__ == '__main__':
	main()

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

Solution (Python):
A,B,C,D = input()
op = '+----'
for i in range(8):
    s = A + op[i&4] + B + op[i&2] + C + op[i&1] + D
    if eval(s) == 7:
        print(s + '=7')
        break

Solution (Python):
from itertools import product
A, B, C, D = map(int, list(input()))
patterns = list(product(("+", "-"), ("+", "-"), ("+", "-")))
for pattern in patterns:
    temp = str(A) + pattern[0] + str(B) + \
        pattern[1] + str(C) + pattern[2] + str(D)
    if eval(temp) == 7:
        print(temp + "=7")
        break

Solution (Python):
from itertools import product
A, B, C, D = map(int, list(input()))
patterns = list(product(("+", "-"), ("+", "-"), ("+", "-")))
for pattern in patterns:
    if pattern[0] == "+":
        temp = A + B
    else:
        temp = A - B
    if pattern[1] == "+":
        temp = temp + C
    else:
        temp = temp - C
    if pattern[2] == "+":
        temp = temp + D
    else:
        temp = temp - D
    if temp == 7:
        print(str(A) + pattern[0] + str(B) +
              pattern[1] + str(C) + pattern[2] + str(D) + "=7")
        break

Solution (Python):
N=input()

for i in range(2):
    for j in range(2):
        for k in range(2):
            if int(N[0])+(-1)**i*int(N[1])+(-1)**j*int(N[2])+(-1)**k*int(N[3])==7:
                X=str(i)+str(j)+str(k)

Z=X.replace("0","+")
Z=Z.replace("1","-")

print(N[0]+Z[0]+N[1]+Z[1]+N[2]+Z[2]+N[3]+"=7")

Solution (Python):


a, b, c, d = list(input())
a = int(a)
b = int(b)
c = int(c)
d = int(d)
if a + b + c + d == 7:
    print('{0}+{1}+{2}+{3}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
    print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
    print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
    print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
    print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
    print('{0}-{1}+{2}-{3}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
    print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
    print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))

Solution (Python):

L = [int(x) for x in list(input())]
ans = 0

if L[0] + L[1] + L[2] + L[3] == 7:
    print("%d+%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
else:
    if L[0] - L[1] + L[2] + L[3] == 7:
        print("%d-%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
    else:
        if L[0] + L[1] - L[2] + L[3] == 7:
            print("%d+%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
        else:
            if L[0] + L[1] + L[2] - L[3] == 7:
                print("%d+%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
            else:
                if L[0] - L[1] - L[2] + L[3] == 7:
                    print("%d-%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
                else:
                    if L[0] - L[1] + L[2] - L[3] == 7:
                        print("%d-%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
                    else:
                        if L[0] + L[1] - L[2] - L[3] == 7:
                            print("%d+%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))
                        else:
                            if L[0] - L[1] - L[2] - L[3] == 7:
                                print("%d-%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))

Solution (Python):

A, B, C, D = map(int,list(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 = [int(x) for x in input()]

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

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

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

Solution (Python):
N = list(input())
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
def op(x):
    if x == 0:
        return '+'
    if x ==1:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            if A+B*(-1)**i+C*(-1)**j+D*(-1)**k == 7:
                print(str(A)+op(i)+str(B)+op(j)+str(C)+op(k)+str(D)+'=7')
                exit()

Solution (Python):
N=input()

a=int(N[0:1])
b=int(N[1:2])
c=int(N[2:3])
d=int(N[3:4])
if a+b+c+d==7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    exit()
if a-b+c+d==7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    exit()
if a+b-c+d==7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    exit()
if a+b+c-d==7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    exit()
if a-b-c+d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    exit()
if a-b+c-d==7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    exit()
if a+b-c-d==7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    exit()
if a-b-c-d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    exit()

Solution (Python):
ABCD = input()

for i in range(1 << 3):
    total = int(ABCD[0])
    equation = ABCD[0]
    for j in range(3):
        if i & (1 << j):
            total += int(ABCD[j+1])
            equation += "+"
        else:
            total -= int(ABCD[j+1])
            equation += "-"    
        equation += ABCD[j+1]
    if total == 7:
        equation += "=7"
        print(equation)
        break

Solution (Python):
input_tuple = tuple(map(int,list(input())))

n = 3
c_list = [list(map(int,format(i,"b").zfill(n))) for i in range(2**n)]

for i in c_list:
    input_list = list(input_tuple)
    for j, v in enumerate(i):
        if v == 1:
            input_list[j+1] = input_list[j+1] * -1
    if sum(input_list) == 7:
        break
ans = [str(input_list[0])]
for j in range(3):
    if i[j] == 0:
        ans.append("+")
    ans.append(str(input_list[j+1]))
else:
    ans.append("=7")

print("".join(ans))

Solution (Python):
abcd = str(input())

for i in range(1<<3):
    temp = int(abcd[0])
    ans = '{}'.format(abcd[0])

    for j in range(1, 4):
        if i >> (j-1) & 1:
            temp += int(abcd[j])
            ans += '+{}'.format(abcd[j])
        else:
            temp -= int(abcd[j])
            ans += '-{}'.format(abcd[j])
    if temp ==7:
        print(ans + "=7")
        break

Solution (Python):
*n, = map(int, list(input()))

def op(x):
    ops = []
    for i in range(3):
        ops.append(x%2)
        x//=2
    return ops

for x in range(2**3):
    ops = op(x)
    y = n[0]
    for i in range(1,4):
        y += n[i]*(1 if ops[i-1]==1 else -1)
    if y == 7:
        break

ans = str(n[0])
for i in range(3):
    if ops[i] == 1:
        ans += '+'
    else:
        ans += '-'
    ans += str(n[i+1])
print(ans+'=7')

Solution (Python):
raw = input()
nums = [] * 4
for i in range(0, 4):
    nums.append(int(raw[i]))





for i in range(0, 8):
    sum = nums[0]
    result = str(nums[0])
    for op in range(0,3):
        if (i >> op) & 1:
            sum += nums[op + 1]
            result += '+'
        else:
            sum -= nums[op + 1]
            result += '-'
        result += str(nums[op + 1])

    if sum == 7:
        result += '=7'
        print(result)
        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("{0}+{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B+C+D == 7: print("{0}-{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B-C+D == 7: print("{0}-{1}-{2}+{3}=7".format(A,B,C,D))
elif A-B-C-D == 7: print("{0}-{1}-{2}-{3}=7".format(A,B,C,D))
elif A+B-C+D == 7: print("{0}+{1}-{2}+{3}=7".format(A,B,C,D))
elif A+B+C-D == 7: print("{0}+{1}+{2}-{3}=7".format(A,B,C,D))
elif A+B-C-D == 7: print("{0}+{1}-{2}-{3}=7".format(A,B,C,D))
elif A-B+C-D == 7: print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))

Solution (Python):
S = input()
a=int(S[0])
b=int(S[1])
c=int(S[2])
d=int(S[3])
op1=[]
op2=[]
op3=[]
func=(('+',lambda x,y:x+y),('-',lambda x,y:x-y))
for f1 in func:
    op1.append((f1[1](a,b),f1[0]))
for o in op1:
    for f2 in func:
        op2.append((f2[1](o[0],c),o[1]+f2[0]))
for o in op2:
    for f3 in func:
        op3.append((f3[1](o[0],d),o[1]+f3[0]))
for o in op3:
    if o[0] == 7:
        print(str(a)+o[1][0]+str(b)+o[1][1]+str(c)+o[1][2]+str(d)+'=7')
        break

Solution (Python):

abcd = [int(_) for _ in list(input())]
op = [0, 1]


def cal(ops, abcd):
    if ops:
        op = ops.pop(0)
        _ = abcd.pop(0)
        if op:
            abcd[0] = _ + abcd[0]
            return cal(ops, abcd)
        else:
            abcd[0] = _ - abcd[0]
            return cal(ops, abcd)
    else:
        return abcd[0]


for op1 in op:
    for op2 in op:
        for op3 in op:
            _ = abcd[:]
            __ = [op1, op2, op3]
            if cal(__, _) == 7:
                ops = [op1, op2, op3]

abcd = [str(_) for _ in abcd]
ops = ['+' if op else '-' for op in ops]
tmp = [abcd[i] + _ for i, _ in enumerate(ops)]
tmp.append(abcd[-1])
print(''.join(tmp) + '=7')

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

Solution (Python):
X = input()
A = int(X[0])
B = int(X[1])
C = int(X[2])
D = int(X[3])
kai = 0
for i in range(2):
  if kai == 7 : break
  for j in range(2):
    if kai == 7 : break
    for k in range(2):
      if kai == 7 : break
      for h in range(2):
        kai = A + B * ((-1) ** j)  + C * ((-1) ** k) + D * ((-1) ** h)
        if kai == 7:
          if i == 1:
            i = "-"
          else:
            i = "+"
          if j == 1:
            j = "-"
          else:
            j = "+"
          if k == 1:
            k = "-"
          else:
            k = "+"
          if h == 1:
            h = "-"
          else:
            h = "+"
          ans = str(A) + j + str(B) + k + str(C) + h + str(D) +  "=7"
          break
print(ans)

Solution (Python):
_ = input()
a,b,c,d = [int(_[i]) for i in range(4)]
e = [-1,1]
def f(s):
    if s == 1:
        print("+",end="")
    else:
        print("-",end="")
for i in e:
    for j in e:
        for k in e:
            if a + i*b + j*c + k*d == 7:
                print(a,sep="",end="")
                f(i)
                print(b,end="")
                f(j)
                print(c,end="")
                f(k)
                print(d,"=7",sep="")
                exit()

Solution (Python):
n = input()
ns = [int(i) for i in n]
for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            if(ns[0]+i*ns[1]+j*ns[2]+k*ns[3]==7):
                ans = str(ns[0])
                if(i == -1):
                    ans += '-'
                else:
                    ans += '+'
                ans += str(ns[1])
                if(j == -1):
                    ans += '-'
                else:
                    ans += '+'
                ans += str(ns[2])
                if(k == -1):
                    ans += '-'
                else:
                    ans += '+'
                ans += str(ns[3])
                print(ans + '=7')
                exit()

Solution (Python):
num=list(map(int,list(input())))
op=[1,-1]
def ope(x):
    if x==1:
        return "+"
    else:
        return "-"

for k in op:
    for j in op:
        for i in op:
            if num[0]+num[1]*k+num[2]*j+num[3]*i==7:
                print("{0}{1}{2}{3}{4}{5}{6}=7".format(num[0],ope(k),num[1],ope(j),num[2],ope(i),num[3]))
                exit()

Solution (Python):
ABCD = input()
for i in range(8):
    tmp = bin(i)[2:].zfill(3)
    tmp_num = int(ABCD[0])
    result = ABCD[0]
    for op in range(3):
        if tmp[op] == '1':
            tmp_num += int(ABCD[op+1])
            result = result + '+' + ABCD[op+1]
        else:
            tmp_num -= int(ABCD[op+1])
            result = result + '-' + ABCD[op+1]
    if tmp_num == 7:
        break
print(result+'=7')

Solution (Python):
import itertools
A, B, C, D = list(input())
ops = itertools.product('+-', repeat=3)
res = ''
for op1, op2, op3 in ops:
    if eval(A+op1+B+op2+C+op3+D) == 7:
        res = A+op1+B+op2+C+op3+D
if res:
    print(res+'=7')
else:
    print('No')

Solution (Python):
import sys
s=input()
for op1 in '+-':
  for op2 in '+-':
    for op3 in '+-':
      if eval(s[0]+op1+s[1]+op2+s[2]+op3+s[3]) == 7:
        print(s[0]+op1+s[1]+op2+s[2]+op3+s[3]+'=7')
        sys.exit(0)

Solution (Python):
s = raw_input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
op = ['+', '-']

for i in range(0, 8):
	op1 = i / 4
	op2 = (i%4) / 2
	op3 = i % 2
	if a + (1-2*op1)*b + (1-2*op2)*c + (1-2*op3)*d == 7:
		print str(a) + op[op1] + str(b) + op[op2] + str(c) + op[op3] + str(d) + '=7'
		break

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

Solution (Python):
s = input()
ops = ['+', '-']
post = '=7'
for a in ops:
    for b in ops:
        for c in ops:
            now = s[0] + a + s[1] + b + s[2] + c + s[3]
            if eval(now) == 7:
                ans = now + post
                break
print(ans)

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

def main():
    n = input()
    A,B,C,D = map(int, [n[0],n[1],n[2],n[3]])

    for op1 in ["+","-"]:
        for op2 in ["+","-"]:
            for op3 in ["+","-"]:
                ans = op(A, op1, B)
                ans = op(ans, op2, C)
                ans = op(ans, op3, D)
                if ans == 7:
                    return str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7"



print(main())

Solution (Python):
from itertools import product
N=list(input())
for i in range(4):
    N[i]=int(N[i])



for op1, op2, op3 in product([1,-1],[1,-1],[1,-1]):
    if N[0] + N[1]*op1 + N[2]*op2 + N[3]*op3 == 7:
        print("{}{}{}{}{}{}{}=7".format(
            N[0],"+" if op1==1 else "-",
            N[1],"+" if op2==1 else "-",
            N[2],"+" if op3==1 else "-",
            N[3]))
        break

Solution (Python):
nums = list(input())
comb = []
def f(now):
  if len(now) == 3:
    comb.append(now)
    return
  
  f(now+['+'])
  f(now+['-'])

f([])

for op in comb:
  temp = nums[0]

  for j in range(len(op)):
    temp = temp + op[j] + nums[j+1]

  if eval(temp) == 7:
    print('{}{}{}'.format(temp, '=', '7'))
    break

Solution (Python):
I = input()
S = list(I)
temp = []
for i in range(8):
    for j in range(3):
        if i & 2**j > 0:
            temp.append(S[j] + "+")
        else:
            temp.append(S[j] + "-")
    temp.append(S[len(S)-1])
    temp = "".join(temp)
    if eval(temp) == 7:
        temp = temp + "=7"
        break
    temp = []

print(temp)

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


for mask in range(1<<3):
	val = a
	if 1 & (mask >> 0):
		val += b
	else:
		val -= b

	if 1 & (mask >> 1):
		val += c
	else:
		val -= c
	
	if 1 & (mask >> 2):
		val += d
	else:
		val -= d

	if val == 7:
		if 1 & (mask>>0):
			op1 = "+"
		else:
			op1 = "-"
		if 1 & (mask>>1):
			op2 = "+"
		else:
			op2 = "-"
		if 1 & (mask>>2):
			op3 = "+"
		else:
			op3 = "-"
		print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+"=7")
		exit(0)

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

while True:
    if int(val[0]) + int(val[1]) + int(val[2]) + int(val[3]) == 7:
        print("{0}+{1}+{2}+{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) - int(val[1]) - int(val[2]) - int(val[3]) == 7:
        print("{0}-{1}-{2}-{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) - int(val[1]) + int(val[2]) + int(val[3]) == 7:
        print("{0}-{1}+{2}+{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) + int(val[1]) - int(val[2]) + int(val[3]) == 7:
        print("{0}+{1}-{2}+{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) + int(val[1]) + int(val[2]) - int(val[3]) == 7:
        print("{0}+{1}+{2}-{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) - int(val[1]) - int(val[2]) + int(val[3]) == 7:
        print("{0}-{1}-{2}+{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) - int(val[1]) + int(val[2]) - int(val[3]) == 7:
        print("{0}-{1}+{2}-{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break
    elif int(val[0]) + int(val[1]) - int(val[2]) - int(val[3]) == 7:
        print("{0}+{1}-{2}-{3}=7".format(int(val[0]), int(val[1]), int(val[2]), int(val[3])))
        break

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

for op in itertools.product('-+', repeat=3):
    f = S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]
    if eval(f) == 7:
        print(f + '=7')
        exit()

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

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

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

Solution (Python):
line = list(map(int, list(input())))
l = len(line)-1
beki_list = [[0]*(l) for i in range(2**l)]

for i in range(2**l):
	i_2 = format(i, 'b')[::-1]
	for j in range(len(i_2)):
		beki_list[i][j] = int(i_2[j])

for i in beki_list:
	num = line[::1]
	pm_l = [num.pop(0)]
	for j in i:
		if j:
			pm_l += [num.pop(0)]
		else:
			pm_l += [-num.pop(0)]
	if (sum(pm_l) == 7):
		for n, k in enumerate(pm_l):
			if n == 0:
				print(str(k), end='')
			else:
				if k >= 0:
					print('+{}'.format(k), end='')
				else:
					print(str(k), end='')
		print('=7')
		exit()

Solution (Python):
s = input()
a = int(s[0])
b = [int(s[1]), - int(s[1])]
c = [int(s[2]), - int(s[2])]
d = [int(s[3]), - int(s[3])]
e = 0
f = 0
g = 0
sign = ["+", "-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+b[i]+c[j]+d[k] == 7:
                e = i
                f = j
                g = k
print(str(a)+sign[e]+str(b[0])+sign[f]+str(c[0])+sign[g]+str(d[0])+"=7")

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

Solution (Python):
import operator
from itertools import product

A, B, C, D = list(map(int, list(input())))
map_operator = {0: operator.sub, 1: operator.add}
map_string = {0: '-', 1: '+'}

for i, j, k in product((0, 1), repeat=3):
    sum = map_operator[k](map_operator[j](map_operator[i](A, B), C), D)
    if sum == 7:
        break

print(str(A) + map_string[i] + str(B) + map_string[j] \
    + str(C) + map_string[k] + str(D) + "=7")

Solution (Python):
n = input()
a = [int(x) for x in n]
if a[0]+a[1]+a[2]+a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]+a[1]+a[2]-a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'=7')
elif a[0]+a[1]-a[2]+a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]+a[1]-a[2]-a[3]==7:
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'=7')
elif a[0]-a[1]+a[2]+a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]-a[1]+a[2]-a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'=7')
elif a[0]-a[1]-a[2]+a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'=7')
elif a[0]-a[1]-a[2]-a[3]==7:
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'=7')

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

op = ['+', '-']

for i in range(7):
    formula = A + op[(i >> 0) & 1] + B + op[(i >> 1) & 1] + C + op[(i >> 2) & 1] + D
    if eval(formula) == 7:
        print(formula + '=7')
        break

Solution (Python):
s = input()
if int(s[0])+int(s[1])+int(s[2])+int(s[3]) == 7:
    op1, op2, op3 = "+", "+", "+"
if int(s[0])+int(s[1])+int(s[2])-int(s[3]) == 7:
    op1, op2, op3 = "+", "+", "-"
if int(s[0])+int(s[1])-int(s[2])+int(s[3]) == 7:
    op1, op2, op3 = "+", "-", "+"
if int(s[0])+int(s[1])-int(s[2])-int(s[3]) == 7:
    op1, op2, op3 = "+", "-", "-"
if int(s[0])-int(s[1])+int(s[2])+int(s[3]) == 7:
    op1, op2, op3 = "-", "+", "+"
if int(s[0])-int(s[1])+int(s[2])-int(s[3]) == 7:
    op1, op2, op3 = "-", "+", "-"
if int(s[0])-int(s[1])-int(s[2])+int(s[3]) == 7:
    op1, op2, op3 = "-", "-", "+"
if int(s[0])-int(s[1])-int(s[2])-int(s[3]) == 7:
    op1, op2, op3 = "-", "-", "-"
print(s[0]+op1+s[1]+op2+s[2]+op3+s[3]+"=7")

Solution (Python):


S = raw_input()
length = len(S)
N = 7

def dfs(depth, S):

    if depth == length - 1:
        if eval(S) == N:
            print S + "=" + str(N)
            return True

        else:
            return False

    
    if dfs(depth + 1, insert_minus(S, depth)):
        return True

    
    if dfs(depth + 1, insert_plus(S, depth)):
        return True

    return False

def insert_plus(S, depth):
    d = depth + S.count("+") + S.count("-") + 1
    return "{0}{1}{2}".format(S[:d],"+",S[d:])

def insert_minus(S, depth):
    d = depth + S.count("+") + S.count("-") + 1
    return "{0}{1}{2}".format(S[:d],"-",S[d:])

dfs(0,S)

Solution (Python):
def m():
    S = input()
    a, b, c, d = map(int, S)
    ope = [1, -1]
    sig_ope = ['+', '-']
    for w in range(2):
        for x in range(2):
            for y in range(2):
                ans = a + (b * ope[w]) + (c * ope[x]) + (d * ope[y])
                if ans == 7:
                    return "{0}{1}{2}{3}{4}{5}{6}=7".format(
                        a, sig_ope[w], b, sig_ope[x], c, sig_ope[y], d
                    )


print(m())

Solution (Python):
s = input()

for i in range(1<<len(s)-1):
    t = list(s)
    for j in reversed(range(1,len(s))):
        if i & (1<<(j-1)):
            t = t[:j]+["+"]+t[j:]
        else:
            t = t[:j]+["-"]+t[j:]
    ans = eval("".join(t))
    if ans == 7:
        break

print("".join(t)+"=7")

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()
    array_result.append(data.split(" "))

    flg = 1

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

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

    A,B,C,D = int(N[0]),int(N[1]),int(N[2]),int(N[3])

    op = ["+","-"]

    for one in op:
        for two in op:
            for three in op:
                ANS = A
                ANS = ANS + B if one=="+" else ANS - B
                ANS = ANS + C if two=="+" else ANS - C
                ANS = ANS + D if three=="+" else ANS - D
                if ANS==7:
                    print("{}{}{}{}{}{}{}=7".format(A,one,B,two,C,three,D))
                    return 0

kippu()

Solution (Python):
a, b, c, d = [i for i in input()]
op = ['+', '-']

for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d) == 7:
                print("{}=7".format(a+i+b+j+c+k+d))
                break

        else:
            continue
        break

    else:
        continue
    break

Solution (Python):
import itertools
N = list(input())
M = list(map(int, N))


def sign(a):
    if a == 0:
        return '+'
    else:
        return '-'


flag = 0
for b, c, d in itertools.product(range(2), range(2), range(2)):
    if M[1]*(-1)**b+M[2]*(-1)**c+M[3]*(-1)**d == 7-M[0]:
        b = sign(b)
        c = sign(c)
        d = sign(d)
        break

print(str(M[0])+b+str(M[1])+c+str(M[2])+d+str(M[3])+'=7')

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

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")
else:
    print(a+"-"+b+"-"+c+"-"+d+"=7")