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):
def main():
	n = [int(i) for i in input()]
	for i in range(7):
		x2 = base_10_to_n(i,2)
		for _ in range(3-len(x2)):	
			x2 = '0' + x2
		ans = n[0]
		for j in range(3):
			if(x2[j] == '0'):
				ans += n[j+1]
			else:
				ans -= n[j+1]
		if(ans == 7):
			text = str(n[0])
			for j in range(3):
				if(x2[j] == '0'):
					text = text + '+' + str(n[j+1])
				else:
					text = text + '-' + str(n[j+1])
			print(text+'=7')
			return 0

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

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

operator = ['+', '-']

for i in range(2 ** 3):
    result = a + operator[int(format(i, 'b').zfill(3)[0])] \
        + b + operator[int(format(i, 'b').zfill(3)[1])] \
        + c + operator[int(format(i, 'b').zfill(3)[2])] \
        + d

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

Solution (Python):
inputs = input()

length = len(inputs) - 1
for i in range(2 ** length):
    formula = ''
    operator = format(i, 'b').zfill(length)
    for index in range(length):
        formula += inputs[index] + ('+' if operator[index] == '0' else '-')
    formula += inputs[-1]
    if eval(formula) == 7:
        print(formula + '=7')
        break

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

def op(i,j,p):
    if p == 0:
        return i + j
    elif p == 1:
        return i - j
def sign(p):
    if p == 1:
        return "-"
    elif p == 0:
        return "+"
for p in range(2):
    x = op(a,b,p)
    for q in range(2):
        y = op(x,c,q)
        for r in range(2):
            if op(y,d,r) == 7:
                break
        else:
            continue
        break
    else:
        continue
    break
print(str(a)+sign(p)+str(b)+sign(q)+str(c)+sign(r)+str(d)+"=7")

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

op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      if eval("A {} B {} C {} D".format(i, j, k)) == 7:
        print("{}{}{}{}{}{}{}=7".format(A, i, B, j, C, k, D))
        exit()

Solution (Python):
nums = list(input())
A = [0, 1]
B = [0, 1]
C = [0, 1]
ops = {
  0: "+",
  1: "-"
}
total = 0
res = ''
for a in range(2):
    for b in range(2):
        for c in range(2):
            if a == 0:
                total = int(nums[0]) + int(nums[1])
            else:
                total = int(nums[0]) - int(nums[1])
            if b == 0:
                total = total + int(nums[2])
            else:
                total = total - int(nums[2])
            if c == 0:
                total = total + int(nums[3])
            else:
                total = total - int(nums[3])
            if total == 7:
                res = nums[0] + ops[a] + nums[1] + ops[b] + nums[2] + ops[c] + nums[3] + "=7"
print(res)

Solution (Python):
s=input()
l=2**3

for i in range(l):
    j=i
    c=int(s[0])
    n=1
    for x in range(3):
        if i & 1 ==1:
            c+=int(s[n])
        else:
            c-=int(s[n])
        i=i>>1
        n+=1
    
    if c==7:
        break

ss=[s[0]]
for i in range(3):
    if j & 1 ==1:
        ss.append('+')
    else:
        ss.append('-')
    ss.append(s[i+1])
    j=j>>1
print(''.join(ss)+'=7')

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

op = ["+","-"]

for i in op:
    for j in op:
        for k in op:
            if eval("A {} B {} C {} D".format(i, j, k)) == 7:
                print("{}{}{}{}{}{}{}=7".format(A, i, B, j, C, k, D))
                exit()

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

for i in range(2):
    op1="+"*(1-i)+"-"*i
    for j in range(2):
        op2="+"*(1-j)+"-"*j
        for k in range(2):
            op3="+"*(1-k)+"-"*k
            sum=a+b*(-1)**i+c*(-1)**j+d*(-1)**k
            if sum==7:
                print(a,op1,b,op2,c,op3,d,"=7",sep="")
                sys.exit(0)

Solution (Python):
S = input()
S_list = list(S)
n = len(S) 
a = []

list_0or1 = [0] * (n-1)
check = []

def f(i):
    if i == n-1 :
        check.append(list_0or1.copy())
    if i != n-1:
        list_0or1[i] = 0
        f(i+1)
    if i != n-1:
        list_0or1[i] = 1
        f(i+1)
f(0)

sum_list = []
s_list = []
for i in range(len(check)):
    S_list_copy = S_list.copy()
    for j in range(n-1) :
        if check[i][j] == 1 :
            S_list_copy[j+1] = '+' + S_list_copy[j+1]
        if check[i][j] == 0 :
            S_list_copy[j+1] = '-' + S_list_copy[j+1]
    S_list_copy = ''.join(S_list_copy)
    sum_list.append(S_list_copy)
    S_list_copy = [int(S_list_copy[0]), int(S_list_copy[2]), int(S_list_copy[4]), int(S_list_copy[6])]
    s = S_list_copy[0]
    for j in range(n-1) :
        if check[i][j] == 1 :
            s = s + S_list_copy[j+1]
        if check[i][j] == 0 :
            s = s - S_list_copy[j+1]
    s_list.append(s) 
if 7 in s_list:
    print(sum_list[s_list.index(7)]+'=7')

Solution (Python):
A, B, C, D = [int(e) for e in input()]
for b in [[+B, "+"+str(B)], [-B, "-"+str(B)]]:
  for c in [[+C, "+"+str(C)], [-C, "-"+str(C)]]:
    for d in [[+D, "+"+str(D)], [-D, "-"+str(D)]]:
      if A+b[0]+c[0]+d[0] == 7:
        ans = str(A) + b[1] + c[1] + d[1] + "=7"
        print(ans)
        break
    else:
      continue
    break
  else:
    continue
  break

Solution (Python):
T = list(map(int,list(input())))
for i in range(2**3):
  ans = T[0]
  op = ["+"]*3
  for j in range(3):
    if (i>>j) & 1:
      ans += T[j+1]
    else:
      ans -= T[j+1]
      op[j] = "-"
  if ans == 7:
    print(T[0],op[0],T[1],op[1],T[2],op[2],T[3],"=7",sep="")
    exit()

Solution (Python):

abcd = tuple(map(int, input()))
ans = []

for i in range(8, 16):
    s = abcd[0]
    eq = [str(s)]
    for j in range(1, 4):
        if int(bin(i)[-j]):
            s += abcd[j]
            eq.append("+" + str(abcd[j]))
        else:
            s -= abcd[j]
            eq.append("-" + str(abcd[j]))

    if s == 7:
        eq.append("=7")
        ans.append("".join(eq))

print(ans[0])

Solution (Python):
import sys

num = str(input())
nums = [int(i) for i in num]

for i in range(2**3):
    res = nums[0]
    
    for pos_i in range(0, 3):
        if (i >> pos_i) & 1:
            res += nums[pos_i + 1]
        else:
            res -= nums[pos_i + 1]
    
    
    pos = ["-"]*3
    if i >> 0 & 1:
        pos[0] = "+"
    if i >> 1 & 1:
        pos[1] = "+"
    if i >> 2 & 1:
        pos[2] = "+"
            
    res_msg = "{}{}{}{}{}{}{}={}".format(nums[0], pos[0], nums[1], pos[1], nums[2], pos[2], nums[3], res)


    if res == 7:
        print(res_msg)
        sys.exit()

Solution (Python):
n = [int(x) for x in input()]
op_cnt= len(n)-1 
for bit in range(2**op_cnt):
    op = ["-"] * op_cnt
    for i in range(op_cnt):
        if ((bit>>i) & 1):
            op[op_cnt-1-i] = "+"
    lis = []
    lis.append(str(n[0]))
    lis.append(op[0])
    lis.append(str(n[1]))
    lis.append(op[1])
    lis.append(str(n[2]))
    lis.append(op[2])
    lis.append(str(n[3]))
    calc = ""
    for item in lis:
        calc += item
    if eval(calc) == 7:
        print(calc+ "=7")
        break

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

Solution (Python):
a,b,c,d=input()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
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):
num = list(input())
ans = 7
for i in range(2 ** len(num)):
    total = 0
    ans_num = []
    ans_op = []
    for j in range(len(num)):
        if((i >> j) & 1):
            ans_num.append(num[j])
            if(j >= 1):
                ans_op.append('+')
            total += int(num[j])
        else:
            ans_num.append(num[j])
            if (j >= 1):
                ans_op.append('-')
            total -= int(num[j])
    if(total == ans):
        print(ans_num[0]+ans_op[0]+ans_num[1]+ans_op[1]+ans_num[2]+ans_op[2]+ans_num[3]+'=7')
        break

Solution (Python):
*ABCD, = map(int, list(input()))
N = 3
op = []
for bit in range(0, 1<<N):
    tmp = []
    for i in range(N):
        if (bit>>i) & 1:
            tmp.append("+")
        else:
            tmp.append("-")
    
    ans = ABCD[0]
    for i in range(N):
        if tmp[i] == "+":
            ans += ABCD[i+1]
        else:
            ans -= ABCD[i+1]
    if ans == 7:
        break

A = str(ABCD[0])
for i in range(N):
    A += str(tmp[i])
    A += str(ABCD[i+1])
A += "=7"
print(A)

Solution (Python):
S = input()
count = len(S)-1
for i in range(2**count):
  sign=['-']*count
  for j in range(count):
    if ((i>>j)&1):
      sign[j]='+'
  formula=''
  for k in range(count):
    formula += S[k] + sign[k]
  formula += S[count]
  if eval(formula)==7:
    print(formula+'=7')
    break

Solution (Python):



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

for i in range(2**3):
    bit = [0]*3
    for j in range(3):
        if (i >> j) & 1:
            bit[j] = 1
    s = a
    ans = [a,None,b,None,c,None,d,'=',7]
    k = 0
    for j in range(3):
        if bit[j] == 1:
            if j == 0:
                s += b
            elif j == 1:
                s += c
            elif j == 2:
                s += d
            ans[2*k+1] = '+'
        else:
            if j == 0:
                s -= b
            elif j == 1:
                s -= c
            elif j == 2:
                s -= d
            ans[2*k+1] = '-'
        k += 1
    if s == 7:
        print(''.join(map(str,ans)))
        break

Solution (Python):
S = input()

op_cnt = len(S) - 1

for i in range(2 ** op_cnt):
  sign = ["+"] * op_cnt
  for j in range(op_cnt):
    if ((i>>j)&1):
      sign[j] = "-"
       
  formula = ""      
  for k in range(op_cnt):
    formula += S[k] + sign[k]
  formula += S[op_cnt]
  if eval(formula) == 7:
    print(formula + "=7")
    break

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

num = input()

A, B, C, D = [int(num[i]) for i in range(4)]

list_op = ["+", "-"]

list_equation = []

for i in range(2):
    
    for j in range(2):
        
        for k in range(2):
            
            ans = A + (-1)**i * B + (-1)**j * C + (-1)**k * D
            
            if ans == 7:
                
                equation = str(A) + list_op[i] + str(B) + list_op[j] + str(C) + list_op[k] + str(D) + "=7"
                
                list_equation.append(equation)

print(list_equation[0])

Solution (Python):
row = input()
row = list(row)
row = list(map(int, row))
Flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            sum = row[0]
            if i == 0:
                op1 = "+"
                sum += row[1]
            else:
                op1 = "-"
                sum -= row[1]
            if j == 0:
                op2 = "+"
                sum += row[2]
            else:
                op2 = "-"
                sum -= row[2]   
            if k == 0:
                op3 = "+"
                sum += row[3]
            else:
                op3 = "-"
                sum -= row[3]  
            if sum == 7:
                Flag = True
                break
        if Flag:
            break
    if Flag:
        break

print(row[0],op1,row[1],op2,row[2],op3,row[3],"=7", sep="")

Solution (Python):
A, B, C, D = [int(c) for c in input()]

expressions = [
    "{}+{}+{}+{}",
    "{}+{}+{}-{}",
    "{}+{}-{}+{}",
    "{}-{}+{}+{}",
    "{}-{}-{}+{}",
    "{}-{}+{}-{}",
    "{}+{}-{}-{}",
    "{}-{}-{}-{}",
]

for exp in expressions:
    exp = exp.format(A, B, C, D)
    if eval(exp) == 7:
        print(exp + "=7")
        break

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

Solution (Python):
S = list(map(int, list(input())))

def sol() :
    for i in range(8) :
        s = S[0]
        ret = [-1] * 3
        for j in range(1,4) :
            mask = 2**(j - 1)
            op = i & mask
            if op == 0 :
                s += S[-j]
                ret[-j] = '+'
            else :
                s -= S[-j]
                ret[-j] = '-'
        if s == 7 :
            return ret
    return -1

ans = sol()

print(S[0], end='')
for i in range(3) :
    print(ans[i], end='')
    print(S[i+1], end='')
print('=7')

Solution (Python):
abcd = input()

plmi = ['+', '-']
ABCD = []
for s in abcd:
    ABCD.append(int(s))


ans = 0
ans_l = ''
def dfs(buff, i, buff2):
    global ans
    global ans_l

    if buff == 7 and i == 4:
        ans += 1
        ans_l = buff2

    if i == 4:
        return

    dfs(buff+ABCD[i],i+1, buff2+'+')
    dfs(buff-ABCD[i],i+1, buff2+'-')


buff_l = []
dfs(ABCD[0], 1, '')


ans = ''
ans_l = list(ans_l)
for i in range(4):
    ans += str(ABCD[i])
    if i < 3:
        ans += str(ans_l[i])


print(ans+'=7')

Solution (Python):
S = input()

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

Solution (Python):
S = input()

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

Solution (Python):
import sys

input = sys.stdin.readline
I = list(input())
I.pop()
A, B, C, D = list(map(int, I))

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


for i in range(2**(len(S)-1)):
  x = ''
  for j in range(len(S)-1):
    x += S[j]
    if ((i>>j)&1):
      x += "+"
    else:
      x += "-"
  x += S[-1]
  if eval(x)==7:
    print(x + "=7")
    break

Solution (Python):
a=list(map(str,input()))
n=len(a)
b=[[] for i in range(2**(n-1))]
for i in range(2**(n-1)):
    for j in range(n-1):
        if ((i >> j) & 1) ==1:
            b[i].append("+")
        else:
            b[i].append("-")

for j in range(2**(n-1)):
    result = [None]*(n+n-1)
    result[::2]=a
    result[1::2]=b[j]
    ans=eval(''.join(result))
    if ans==7:
        aa=[''.join(result),"=",str(ans)]
        print(''.join(aa))
        exit()

Solution (Python):
n = input()
for i in range(2**3):
    sign = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):
            sign[j] = "+"

    formula = n[0] + sign[0] + n[1] + sign[1] + n[2] + sign[2] + n[3]
    if eval(formula) == 7:
        print(formula+'=7')
        break

Solution (Python):
ABCD = list(map(int, input()))
a, b, c, d = ABCD[0], ABCD[1], ABCD[2], ABCD[3]
op = ['+', '-']
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = 0
            if i == 0:
                ans = a + b
            else:
                ans = a - b
            if j == 0:
                ans += c
            else:
                ans -= c
            if k == 0:
                ans += d
            else:
                ans -= d
            if ans == 7:
                print('{}{}{}{}{}{}{}={}'.format(a,op[i],b,op[j],c,op[k],d,ans))
                flag = True
                break
        if flag:
            break
    if flag:
        break

Solution (Python):
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
import sys
for i in range(8):
    j_list=[]
    op=(i>>0)&1
    if op:
        ans=a+b
        j_list.append('+')
    else:
        ans=a-b
        j_list.append('-')
    op=(i>>1)&1
    if op:
        ans+=c
        j_list.append('+')
    else:
        ans-=c
        j_list.append('-')
    op=(i>>2)&1
    if op:
        ans+=d
        j_list.append('+')
    else:
        ans-=d
        j_list.append('-')
    if ans==7:
        print(s[0]+j_list[0]+s[1]+j_list[1]+s[2]+j_list[2]+s[3]+'=7')
        sys.exit()

Solution (Python):
import itertools
l = [int(i) for i in list(str(input()))]
pm=[1,-1]
l_i=list(itertools.product(pm,repeat=3))
for i in l_i:
    tmp=l[0]
    for j in range(3):
        tmp+=i[j]*l[j+1]
    if tmp==7:
        ans=[str(l[0]),"a",str(l[1]),"a",str(l[2]),"a",str(l[3]),"=7"]
        if i[0]==1:ans[1]="+"
        else:ans[1]="-"
        if i[1]==1:ans[3]="+"
        else:ans[3]="-"
        if i[2]==1:ans[5]="+"
        else:ans[5]="-"
        print("".join(ans))
        exit()

Solution (Python):
I = input()
A, B, C, D = int(I[0]), int(I[1]), int(I[2]), int(I[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):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



S = list(sys.stdin.readline().rstrip())

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

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

def result(N):
    if N[0]+N[1]+N[2]+N[3] ==7:
        print('{}+{}+{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]+N[2]+N[3]==7:
        print('{}-{}+{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]-N[2]+N[3]==7:
        print('{}+{}-{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]+N[2]-N[3]==7:
        print('{}+{}+{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]-N[2]+N[3]==7:
        print('{}-{}-{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]+N[2]-N[3]==7:
        print('{}-{}+{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]-N[2]-N[3]==7:
        print('{}+{}-{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]-N[2]-N[3]==7:
        print('{}-{}-{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
result(N)

Solution (Python):
a=input()
for i in range(2**(len(a)-1)):
    tmp=a[0]+"".join(["+-"[i>>j&1]+k for j,k in enumerate(a[1:])])
    if eval(tmp)==7:
        print(tmp+"=7")
        break

Solution (Python):
def dfs(i, total):
    global ans
    if i == len(s):
        if eval(total) == 7:
            ans = total + "=7"
            return ans
        return 0
    dfs(i + 1, total + "+" + s[i])
    dfs(i + 1, total + "-" + s[i])

s = input()
ans = 0
dfs(1, s[0])
print(ans)

Solution (Python):
import sys

S = input()

operators = ['+', '-']

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            exp = S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3]
            if eval(exp) == 7:
                print("{}{}{}{}{}{}{}=7".format(S[0], op1, S[1], op2, S[2], op3, S[3]))
                sys.exit(0)

Solution (Python):
serial = list(input())
numbers = [int(s) for s in serial]
ak = "0"
bk = "0"
ck = "0"
for ai in range(2):
    for bi in range(2):
        for ci in range(2):
            kotae = 0
            if ai == 0:
                kotae = numbers[0] + numbers[1]
            else:
                kotae = numbers[0] - numbers[1]
            if bi == 0:
                kotae = kotae + numbers[2]
            else:
                kotae = kotae - numbers[2]
            if ci == 0:
                kotae = kotae + numbers[3]
            else:
                kotae = kotae - numbers[3]

            if kotae == 7:
                ak = "+" if ai == 0 else "-"
                bk = "+" if bi == 0 else "-"
                ck = "+" if ci == 0 else "-"
print(serial[0] + ak + serial[1] + bk + serial[2] + ck + serial[3] + "=7")

Solution (Python):
def generateit(s, n):
	m = n
	ans = s[0]
	for i in range(0, 3):
		if m % 2 == 1:
			ans = ans + '+' + s[i+1]
		else:
			ans = ans + '-' + s[i+1]
		m //= 2
	return ans

S = input()
for i in range(0, 8):
	n = i
	sum = int(S[0])
	for j in range(0, 3):
		if n % 2 == 1:
			sum += int(S[j+1])
		else:
			sum -= int(S[j+1])
		n //= 2
	if sum == 7:
		print(generateit(S, i)+'=7')
		break

Solution (Python):
if __name__ == '__main__':
    x = list(input())

    for i in range(2**3):
        state =[]
        state.append(x[0])
        for j in range(3):
            if ((i >> j) & 1) == 1:
                state.append('+')
            else:
                state.append('-')
            state.append(x[j+1])
        str_state = ''.join(state)
        if eval(str_state) == 7:
            print(str_state + '=7')
            break

Solution (Python):
s = input()
for i in range(1 << 3):
    S = list(s)
    total = int(s[0])
    for j in range(len(s)-1):
        if (i >> j) & 1:
            total += int(s[j+1])
            S.insert(2*j+1,"+")
        else:
            total -= int(s[j+1])
            S.insert(2*j+1,"-")
    if total == 7:
        print("".join(map(str,S))+"=7")
        break

Solution (Python):
ABCD=input()






for i in range(2**3):
    count=int(ABCD[0])
    ans=ABCD[0]
    for j in range(3):
        if i&(1<<j):
            count+=int(ABCD[j+1])
            ans+="+"
        else:
            count-=int(ABCD[j+1])
            ans+="-"
        ans+=ABCD[j+1]
    if count==7:
        ans+="=7"
        print(ans)
        quit()

Solution (Python):
from itertools import product, accumulate
S = input()

def eval_(s, pat):
    s = list(map(int, s))
    ans = s[0]
    for i in range(3):
        if pat[i] == '+':
            ans += s[i+1]
        else:
            ans -= s[i+1]
    return ans

eq = ''
for pat in product(('+', '-'), repeat=3):
    if eval_(S, pat) == 7:
        eq = S[0]
        for i in range(3):
            eq += pat[i] + S[i+1]
        break

print(eq+'=7')

Solution (Python):


a, b, c, d = map(str, input())

sign = "+-"
for i in range(2):
    for j in range(2):
        for k in range(2):
            if int(eval(a+sign[i]+b+sign[j]+c+sign[k]+d)) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d) + "=7")
                exit()

Solution (Python):
from itertools import product
s = input()
options = product(["+", "-"], repeat=3)
for op in options:
    v = s[0]
    for i in range(3):
        v += op[i] + s[i+1]
    if eval(v) == 7:
        break
print(v+"=7")

Solution (Python):
def dfs(i, f):
    global ans
    if i == len(s) - 1:
        if eval(f) == 7:
            ans = f + "=7"
            return ans
        return 0
    dfs(i + 1, f + "+" + s[i+1])
    dfs(i + 1, f + "-" + s[i+1])
    
s = input()
ans = ""
dfs(0, s[0])
print(ans)

Solution (Python):
def calc(expression):
    result = int(expression[0])
    i = 1
    while i < len(expression):
        c = expression[i]
        if c == "+":
            i+=1
            result+=int(expression[i])
        elif c == "-":
            i+=1
            result-=int(expression[i])
        i+=1
    return result

S=input()
ex=[S[0]]

for s in S[1:]:
    tmp=ex
    ex=[]
    for e in tmp:
        ex.append(e + "+" + s)
        ex.append(e + "-" + s)

for e in ex:
    if calc(e) == 7:
        print(e+"=7")
        break

Solution (Python):
ABCD = input()
A, B, C, D = (int(ABCD[i]) for i in range(4))
op = ['+', '-']
for i in range(2):
    if i == 0:
        W = A + B
    else:
        W = A - B
    for j in range(2):
        if j == 0:
            X = W + C
        else:
            X = W - C
        for k in range(2):
            if k == 0:
                Y = X + D
            else:
                Y = X - D
            if Y == 7:
                print(A, op[i], B, op[j], C, op[k], D, '=7', sep='')
                exit()

Solution (Python):
ABCD = input()
A, B, C, D = (int(ABCD[i]) for i in range(4))
op = ['+', '-']
for i in range(2):
    if i == 0:
        W = A + B
    else:
        W = A - B
    for j in range(2):
        if j == 0:
            X = W + C
        else:
            X = W - C
        for k in range(2):
            if k == 0:
                Y = X + D
            else:
                Y = X - D
            if Y == 7:
                print(A, op[i], B, op[j], C, op[k], D, '=7', sep='')
                exit()

Solution (Python):

N = input()

for i in range(2 ** 3):

    ops = format(i,"b")
    ops = ops.zfill(3)

    op_lis = []

    for j in ops:

        if j == "0":
            op_lis.append(1)
        else:
            op_lis.append(-1)

    if int(N[0]) + op_lis[0] * int(N[1]) +op_lis[1] * int(N[2]) + op_lis[2] * int(N[3]) == 7:

        ans = N[0]

        for k in range(len(op_lis)):
            if op_lis[k] == 1:
                ans += "+"
            else:
                ans += "-"

            ans += N[k+1]

        ans += "=7"

        print (ans)
        break

Solution (Python):
s = input()
abcd = [int(s[0]),int(s[1]),int(s[2]),int(s[3])]
mark = ['-','+']
for i in range(1 << 3):
    alla = abcd[0]
    i2 = format(i,'03b')
    for j in range(3):
        if i2[2 - j] == '0':
            alla -= abcd[3 - j]
        else:
            alla += abcd[3 - j]
    if alla == 7:
        print(s[0] + mark[int(i2[0])] + s[1] + mark[int(i2[1])] + s[2] + mark[int(i2[2])] + s[3] + '=7')
        exit()

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

op_cnt = n - 1

for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    ans = A + op[0] + B + op[1] + C + op[2] + D
    if eval(ans) == 7:
        print(ans + "=7")
        break

Solution (Python):
import sys
def solve(l, r):
	if r == "":
		if eval(l) == 7:
			print(l + "=7")
			sys.exit()
	else:
		solve(l + "+" + r[0], r[1:])
		solve(l + "-" + r[0], r[1:])

s = input()
solve(s[0], s[1:])

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

for x in itertools.product(["-", "+"], repeat = 3):
	ans = s[0] + x[0] + s[1] + x[1] + s[2] + x[2] + s[3]
	if eval(ans) == 7:
		print(ans + "=7")
		break

Solution (Python):
import itertools

A, B, C, D = input()
for p in itertools.product(['+', '-'], repeat = 3):
    equ = A + p[0] + B + p[1] + C + p[2] + D
    
    if(eval(equ) == 7):
        print(equ + '=7')
        break

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

ABCD = S()

for i in range(1<<3):
    tmp = 0
    bit = i

    for j in range(3):
        if (bit & 1):
            tmp += int(ABCD[-j-1])
        else:
            tmp -= int(ABCD[-j-1])
        bit >>= 1
        
    tmp += int(ABCD[0])
    if (tmp == 7):
        ans = i
        break


operands = []
for i in range(3):
    if (ans & 1):
        operands.append("+")
    else:
        operands.append("-")
    ans >>= 1

for i, ope in enumerate(operands[::-1]):
    print(ABCD[i], end="")
    print(ope, end="")
print(ABCD[3], end="")
print("=7")

Solution (Python):
from sys import stdin
input=stdin.readline().rstrip()
input_list=list(input)
n=len(input_list)-1

for i in range(2**n):
    out=input_list[0]
    for j in range(n):
        if ((i >> j) & 1):
            out+="+"
        else:
            out+="-"
        out+=input_list[j+1]
    if eval(out)==7:
        print(out+"=7")
        break

Solution (Python):
s = input();
count1 = 0;
for i in range(8) :
	if i < 4 :
		op1 = '+';
	else :
		op1 = '-';
	
	if count1 % 2 == 0 :
		op2 = '+';
	else :
		op2 = '-';
	
	if i % 2 == 0 :
		op3 = '+';
	else :
		op3 = '-';
		count1 += 1;
	
	ans = s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3];
	if eval(ans) == 7 :
		print(ans+'=7');
		break;

Solution (Python):

s=list(input())
n=len(s)-1

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