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 conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"


if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    for i in range(1 << bin_pattern_digit):
        
        result = int(abcd[0:1])
        for j in range(bin_pattern_digit):
            
            
            
            if i & 1 << (bin_pattern_digit - j -1 ):
                
                result += int(abcd[j + 1])
            
            else:
                
                result -= int(abcd[j + 1])

        
        if result == 7:
            break

    
    
    
    
    
    
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")

Solution (Python):
S=list(input())
for i in range(4):
  S[i]=int(S[i])
for i in range(8):
  ans=S[0]
  s=format(i,"05b")
  A=[]
  for j in range(3):
    if s[-1-j]=="1":
      A.append(j)
  for i in range(3):
    if i in A:
      ans=ans+S[i+1]
    else:
      ans=ans-S[i+1]
  if ans==7:
    print(S[0],end="")
    for i in range(3):
      if i in A:
        print("+",end="")
      else:
        print("-",end="")
      print(S[i+1],end="")
    print("=7")
    break

Solution (Python):




def main():
    ABCD = input()

    op = ['+', '-']
    result = ''

    for i in range(2**3):
        bins = list(map(int, format(i, '03b')))
        f = ABCD[0] + op[bins[0]] + ABCD[1] + \
            op[bins[1]] + ABCD[2] + op[bins[2]] + ABCD[3]
        if eval(f) == 7:
            result = f + '=7'
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):

s = input()

ints = [int(s[i]) for i in range(len(s))]

rope = []
o = []
o.append(str(ints[0]))

for i  in range(2**(len(ints)-1)):
	total = ints[0]
	ope = ['-' for i in range(len(ints)-1)]

	for j in range(len(ints)-1):

		if((i>>j) & 1):
			total = total + ints[j+1]
			ope[j] = '+'
		else :
			total = total - ints[j+1]
			ope[j] = '-'

	
	if total == 7:
		rope = ope
		break


for i in range(len(rope)):
	o.append(rope[i])
	o.append(str(ints[i+1]))


print(''.join(o)+'=7')

Solution (Python):
def resolve():
    I = input()
    L = [int(c) for c in I]
    
    
    for i in range(2 ** 3):
        val=L[0]
        ans=[]
        for j in range(3):  
            if ((i >> j) & 1):
                val+=L[j+1]
                ans.append('+')
            else:
                val-=L[j+1]
                ans.append('-')
                
        if val==7:
            for k in range(3):
                print('{}{}'.format(L[k],ans[k]),end='')
            print('{}=7'.format(L[3]))
            break





resolve()

Solution (Python):
abcd = input()


for bit in range(1<<3):
  f = abcd[0]
  sum = int(f)
  for i in range(3):
    if bit & 1<<i:
      f += '+' + abcd[i+1]
      sum += int(abcd[i+1])
    else:
      f += '-' + abcd[i+1]
      sum -= int(abcd[i+1])
  
  if sum == 7:
    print(f + '=7')
    exit()

Solution (Python):
abcd = input()


def dfs(i, f, sum):
  if i == 3:
    if sum ==7:
      print(f + '=7')
      exit()
    
  else:
    dfs(i+1, f + '+' + abcd[i+1], sum + int(abcd[i+1]))
    dfs(i+1, f + '-' + abcd[i+1], sum - int(abcd[i+1]))


dfs(0, abcd[0], int(abcd[0]))

Solution (Python):
import itertools, re

abcd = input()
abcd = [int(x) for x in abcd]
p = list(itertools.product([1,-1], repeat=3))

f = abcd[0]
fs = str(abcd[0])
for i in range(len(p)):
  for j in range(3):
    f += abcd[j+1]*p[i][j]
    if p[i][j] <0:
      fs += '-' + str(abcd[j+1])
    else:
      fs += '+' + str(abcd[j+1])
  if f == 7:
    print(fs + '=7')
    exit()
  else:
    f = abcd[0]
    fs = str(abcd[0])

Solution (Python):
import copy

def add_num(li, op):
    ans = li[0]
    ans_str = ''
    for i in range(len(op)):
        if op[i] == 0:
            ans -= li[i + 1]
            op_str = '-'
        else:
            ans += li[i + 1]
            op_str = '+'
        ans_str += (str(li[i]) + op_str)
    if ans == 7:
        ans_str += str(li[-1])
        print(ans_str + '=7')
        exit()
    return ans


if __name__ == '__main__':
    tmp = list(input())
    tmp = [int(v) for v in tmp]
    op = [0,0,0]
    for i in range(0, 3):
        op_w = copy.copy(op)
        op_w[i] = 1
        add_num(tmp, op_w)
    for i in range(0,3):
        op_w = copy.copy(op)
        op_w[i] = 1
        if i + 1 == len(op):
            j = 0
        else:
            j = i + 1
        op_w[j] = 1
        add_num(tmp, op_w)
    add_num(tmp, op)
    add_num(tmp, [1,1,1])

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

def main():
    s = input().strip()
    a = int(s[0])
    s = s[1:]
    for i in range(2**3):
        tmp = a
        ans = str(a)
        for j in range(3):
            if i&1:
                tmp += int(s[j])
                ans += "+" + s[j]
            else:
                tmp -= int(s[j])
                ans += "-" + s[j]
            i >>= 1
        
        if tmp == 7:
            print(ans + "=7")
            return
            





if __name__ == "__main__":
    main()

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

for operators in product(["+","-"],repeat=3):
  formula=""
  for i in range(3):
    formula+=s[i]+operators[i]
  formula+=s[-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("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()
if a+b+c-d==7:
  print("%d+%d+%d-%d=7"%(a,b,c,d))
  exit()
if a+b-c+d==7:
  print("%d+%d-%d+%d=7"%(a,b,c,d))
  exit()
if a+b-c-d==7:
  print("%d+%d-%d-%d=7"%(a,b,c,d))
  exit()  
if a-b+c+d==7:
  print("%d-%d+%d+%d=7"%(a,b,c,d))
  exit()
if a-b+c-d==7:
  print("%d-%d+%d-%d=7"%(a,b,c,d))
  exit()
if a-b-c+d==7:
  print("%d-%d-%d+%d=7"%(a,b,c,d))
  exit()
if a-b-c-d==7:
  print("%d-%d-%d-%d=7"%(a,b,c,d))
  exit()

Solution (Python):
A_D = str(input())
op = ['']*3
l = []
for i in range(4):
  l.append(A_D[i])
for i in range(2**3):
  i = format(i,"03b")
  for j in range(3):
    if i[j] == '0':
      op[j] = '+'
    elif i[j] == '1':
      op[j] = '-'
  if eval(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]) == 7:
    break
print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+'=7')

Solution (Python):
A_D = str(input())
op = ['']*3
l = []
for i in range(4):
  l.append(A_D[i])
for i in range(2**3):
  bit_i = bin(i)[-3:]
  i = bit_i.replace('b','0')
  for j in range(3):
    if i[j] == '0':
      op[j] = '+'
    elif i[j] == '1':
      op[j] = '-'
  if eval(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]) == 7:
    break
print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+'=7')

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

def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    elif n<7:
        solve(m,n+2)
        solve(m[:n]+"-"+m[n+1:],n+2)

solve(a+"+"+b+"+"+c+"+"+d,1)

Solution (Python):
from itertools import product
nums = list(input())
for operators in product(['+', '-'], repeat=3):
    formula = ''
    for i in range(3):
        formula += nums[i] + operators[i]
    formula += nums[-1]
    if eval(formula) == 7:
        print(formula+'=7')
        break

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

ll = list(itertools.product([0,1], repeat=3))

for l in ll:
    tmp = a
    tmp_st = str(a)
    for i,num in enumerate(l):
        if num == 0:
            if i == 0:
                tmp -= b
                tmp_st += '-' + str(b)
            elif i == 1:
                tmp -= c
                tmp_st += '-' + str(c)
            else:
                tmp -= d
                tmp_st += '-' + str(d)
        if num == 1:
            if i == 0:
                tmp += b
                tmp_st += '+' + str(b)
            elif i == 1:
                tmp += c
                tmp_st += '+' + str(c)
            else:
                tmp += d
                tmp_st += '+' + str(d)
    if tmp == 7:
        tmp_st += '=7'
        print(tmp_st)
        sys.exit()

Solution (Python):
import sys

s=list(input())

def f(p,i,F):
  if i == 4 and p == 7:
    print(F+"=7")
    sys.exit()
  elif i==4:
    return ""
  else:
    f(p+int(s[i]),i+1,F+"+"+s[i])
    f(p-int(s[i]),i+1,F+"-"+s[i])
    
f(int(s[0]),1,s[0])

Solution (Python):
import sys
S=input()
a,b,c,d=S[0],S[1],S[2],S[3]
lst=['+','-']
for i in lst:
  for j in lst:
    for k in lst:
      if eval(a+i+b+j+c+k+d+'==7'):
        print(a+i+b+j+c+k+d+'=7')
        sys.exit()

Solution (Python):
a = list(input())
n = len(a)
def dfs(i, s, sum_):
  if i == n-1:
    if sum_ == 7:
      print(s+"=7")
      exit()
  else:
    dfs(i+1, s+"+"+a[i+1], sum_+int(a[i+1]))
    dfs(i+1, s+"-"+a[i+1], sum_-int(a[i+1]))

print(dfs(0,a[0],int(a[0])))

Solution (Python):
a = list(input())
s = "+-"
for i in range(2):
  for j in range(2):
    for k in range(2):
      if eval(a[0]+s[i]+a[1]+s[j]+a[2]+s[k]+a[3]) == 7:
        print(str(a[0]+s[i]+a[1]+s[j]+a[2]+s[k]+a[3])+"=7")
        quit()

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

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

Solution (Python):
V = list(input())
N = len(V) - 1
for bit in range(1 << N):
    op = ['+' if bit & (1 << i) else '-' for i in range(N)]
    s = V[0] + op[0] + V[1] + op[1] + V[2] + op[2] + V[3]
    
    if eval(s) == 7:
        print(s + '=7')
        exit()

Solution (Python):
def main():
  N = input()
  operators = [["+","+","+"],["+","+","-"],["+","-","+"],["-","+","+"],["+","-","-"],["-","+","-"],["-","-","+"],["-","-","-"]]
  for x,y,z in operators:
        tmp = N[0]+x+N[1]+y+N[2]+z+N[3]
        if eval(tmp) == 7:
              print(tmp+"=7")
              break

if __name__ == "__main__":
      main()

Solution (Python):
abcd = list(map(int, input()))
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[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):
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
op1 = '+'
op2 = '+'
op3 = '+'
for B in [b, -b]:
    for C in [c, -c]:
        for D in [d, -d]:
            if a + B + C + D == 7:
                if B < 0:
                    op1 = '-'
                if C < 0:
                    op2 = '-'
                if D < 0:
                    op3 = '-'
                print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                exit()

Solution (Python):
N = input()
import itertools
for p in itertools.product([0, 1], repeat=3):
  res = int(N[0])
  for i in range(3):
    if p[i]==0:
      res += int(N[i+1])
    else:
      res -= int(N[i+1])
  if res==7:
    bit = p
    break

oper = ['+','-']
ans = N[0]
for i in range(3):
  ans += oper[bit[i]]
  ans += N[i+1]
ans += '=7'
print(ans)

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

def dfs(i, f, sum_):
    if i == n-1:
        if sum_ == 7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1, f+'+'+s[i+1], sum_+int(s[i+1]))
        dfs(i+1, f+'-'+s[i+1], sum_-int(s[i+1]))
        
print(dfs(0, s[0], int(s[0])))

Solution (Python):


numbers = list(input())

for i in range(1 << (len(numbers)-1)):
    tmp = numbers[0]
    for j in range(len(numbers)-1):  
        if (i >> j) & 1:
            tmp += "+"
        else:
            tmp += "-"
        tmp += numbers[j+1]
    if eval(tmp) == 7:
        print(tmp+"=7")
        break

Solution (Python):

numbers = list(input())



def rec(s, n):
    if n == 3:
        if eval(s) == 7:
            print(s+"=7")
            exit()
        return
    rec(s+"+"+numbers[n+1], n+1)
    rec(s+"-"+numbers[n+1], n+1)


rec(numbers[0], 0)

Solution (Python):
a,b,c,d=list(map(str,input()))
def solve(m,n):
    if eval(m)==7:
        print(m+"=7")
        exit(0)
    elif n<7:
        solve(m,n+2)
        solve(m[:n]+"-"+m[n+1:],n+2)
solve(a+"+"+b+"+"+c+"+"+d,1)

Solution (Python):
nums = [int(s) for s in input()]
N = 4

ans = [0]*N
for flag in range(1<<N):
    ans = nums[0]
    for i in range(N-1):
        if flag & 1<<i:
            ans += nums[i+1]
        else:
            ans -= nums[i+1]
    if ans == 7:
        ans_str = str(nums[0])
        for i in range(N-1):
            if flag & 1<<i:
                ans_str += "+"
            else:
                ans_str += "-"
            ans_str += str(nums[i+1])
        ans_str += "=7"
        print(ans_str)
        break

Solution (Python):
S=input()
ans=0
for i in range(1<<3):
    lst = ['-']*3
    for j in range(3):
        if 1&(i>>j):
            lst[2-j] = '+'
    total = ''
    for n, m in zip(S, lst+['']):
        total += (n+m)
    if eval(total) == 7:
        print(total + '=7')
        break

Solution (Python):
A,B,C,D=list(input())
op="+-"
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(A+op[i]+B+op[j]+C+op[k]+D) == 7:
                print(str(A+op[i]+B+op[j]+C+op[k]+D)+"=7")
                exit()

Solution (Python):
nums = list(map(int, list(input().rstrip())))
    
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1, f+'+'+str(nums[i+1]), sum+nums[i+1])
        dfs(i+1, f+'-'+str(nums[i+1]), sum-nums[i+1])
        
dfs(0, str(nums[0]), nums[0])

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

Solution (Python):
a = input()

plusminus = ['+', '-']

def calc(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    else:
        ValueError

def cnt_calc(a, op1, op2, op3):
    return calc(
                int(a[3]),
                calc(
                    int(a[2]),
                    calc(
                        int(a[0]), int(a[1]), op1
                    ),
                    op2
                ),
                op3
            )


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

Solution (Python):
def main():
    a = input()
    n = 3
    op = ['']*n
    for i in range(1 << n):
        total = int(a[0])
        for j in range(n):
            if 1 & (i >> j):
                total += int(a[j+1])
                op[j] = '+'
            else:
                total -= int(a[j+1])
                op[j] = '-'
        if total == 7:
            break
    ans = a[0]
    for i in range(n):
        ans += op[i]+a[i+1]
    ans += '=7'
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import itertools

S = input()

in_list = list(S)
a, b, c, d = list(S)

op_list = list(itertools.product(['+', '-'], repeat=3))

for o in op_list:
    f = []
    for i, v in enumerate(in_list):
        f += v
        if i >= len(in_list) - 1: break
        f += o[int(i)]
    f_str = ''.join(f)
    total = eval(f_str)
    if total == 7:
        f_str += '=7'
        break
print(f_str)

Solution (Python):
import sys

S=input()
N=len(S)-1
op = ['']*N
for i in range(1<<N):
    ans = int(S[0])
    for j in range(N):
        if 1&(i>>j):
            ans -= int(S[j+1])
            op[j] = '-'
        else:
            ans += int(S[j+1])
            op[j] = '+'
    if ans == 7:
        break

output = S[0]
for i in range(N):
    output = output + op[i] + S[i+1]
output = output + '=7'

print(output)

Solution (Python):
s = input()

n = 3
sum = 0

for i in range(1 << n):
  u = []
  t = list(s)
  
  for j in range(n):
    if((i >> j) & 1):
      u.append(1)
    else:
      u.append(0)
  
  for j in range(3):
    if(u[j] == 1):
      t.insert(((2*(j+1))-1),'+')
    else:
      t.insert(((2*(j+1))-1),'-')
  if(eval(''.join(t))==7):
    print(''.join(t)+'=7')
    break

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































nums = (b, c, d)
for i in range(2 ** 3):
    ans = a
    op = []
    for shift in range(3):
        if i >> shift & 1:
            op.append('+')
            ans += nums[shift]
        else:
            op.append('-')
            ans -= nums[shift]
    if ans == 7:
        print(a, op[0], b, op[1], c, op[2], d, '=7', sep='')
        break

Solution (Python):
from itertools import product
s = input()
for bit in product(['-', '+'], repeat=len(s)-1):
    q = ''
    for i in range(len(s)*2-1):
        if i % 2 == 0:
            q += s[i//2]
        else:
            q += bit[(i-1)//2]
    ans = eval(q)
    if ans == 7:
        print(q+'=7')
        exit()

Solution (Python):
abcd = input()
int_abcd = list(map(int, abcd))
for i in range(1 << 3):    
    op = ['-'] * 3 + ['=7']
    sum_abcd = int_abcd[0]
    for j in range(3):
        if (i >> j) & 1:
            op[2 - j] = '+'
        sum_abcd += (-1)**(((i >> j) & 1) + 1) * int_abcd[3 - j]
    if sum_abcd == 7:
        break

for num, pm in zip(abcd, op):
    print(num, pm, sep='', end='')

Solution (Python):
n = [x for x in input()]
l=len(n)-1
for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if ((i>>j)&1):
            op[l-1-j]="+"
    formula=""
    for p,q in zip(n,op + [""]):
        formula+=(p+q)
    if eval(formula)==7:
        print(formula + "=7" )
        break

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

case = ["+", "-"]
set_combination = list(itertools.product(case, repeat=3))

for x in set_combination:
    if x[0] == "+":
        sum_abcd = abcd[0] + abcd[1]
    else:
        sum_abcd = abcd[0] - abcd[1]
    if x[1] == "+":
        sum_abcd = sum_abcd + abcd[2]
    else:
        sum_abcd = sum_abcd - abcd[2]
    if x[2] == "+":
        sum_abcd = sum_abcd + abcd[3]
    else:
        sum_abcd = sum_abcd - abcd[3]

    if sum_abcd == 7:
        print("%d%s%d%s%d%s%d=7" % (abcd[0], x[0],
                                    abcd[1], x[1], abcd[2], x[2], abcd[3]))
        break

Solution (Python):
import itertools

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



for i in itertools.product([0,1], repeat=3):
    r=list(i)
    sump=a[0]
    for ii in range(3):
        if r[ii]==0:
            sump=sump-a[ii+1]
        else:
            sump=sump+a[ii+1]

    if sump==7:
        stra=str(a[0])
        for ii in range(3):
            if r[ii]==0:
                stra=stra+"-"+str(a[ii+1])
            else :
                stra=stra+"+"+str(a[ii+1])
        stra=stra+"=7"        
        print(stra)
        break

Solution (Python):
ABCD = int(input())
a = int(ABCD//10e2)
b = int((ABCD-a*10e2)//10e1)
c = int((ABCD-a*10e2-b*10e1)//10)
d = int(ABCD-a*10e2-b*10e1-c*10)
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):
n = input()
s_num = len(n) -1 
all_p_m = []
for i in range(2**s_num):
  p_m_list = [False for i in range(s_num)]
  for j in range(s_num):
    if ((i >>j) & 1):
      p_m_list[j] = True
  all_p_m.append(p_m_list)
  
for p_m in all_p_m:
  result = int(n[0])
  for i in range(len(p_m)):
    if p_m[i] == True:
      result += int(n[i + 1])
    else:
      result -= int(n[i + 1])
  if result == 7:
    ans_p_m = p_m

ans = ["0" for i in range(7)]
for _ in range(7):
  if _ %2 ==0:
    ans[_] = n[_//2]
  else:
    if ans_p_m[_//2] == True:
    	ans[_] = "+"
    else:
      ans[_] = "-"
ans.append("=7")    
print("".join(ans))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	S = list(map(int, "".join(S)))
	a = []
	def dfs(i, res, ans):
		if i==len(S)-1:
			if res==7:
				ans += "=7"
				a.append(ans)
		else:
			dfs(i+1, res + S[i+1], ans+"+"+str(S[i+1]))
			dfs(i+1, res - S[i+1], ans+"-"+str(S[i+1]))
	dfs(0,S[0],str(S[0]))
	print(a[0])

if __name__ == '__main__':
	main()

Solution (Python):
import operator

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

operators = {"+": operator.add, "-": operator.sub}

for ope_key1, ope1 in operators.items():
    for ope_key2, ope2 in operators.items():
        for ope_key3, ope3 in operators.items():
            if ope3(ope2(ope1(a, b), c), d) == 7:
                print("{0}{1}{2}{3}{4}{5}{6}=7".format(a, ope_key1, b, ope_key2, c, ope_key3, d))
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
nums = input()
op_cnt = len(nums) - 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] = "+"
    formula = ""
    for p_n, p_o in zip(nums, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):

a,b,c,d = input()
s = "+-"

for p in s:
    for q in s:
        for r in s:
            f = a+p+b+q+c+r+d
            if eval(f) == 7:
                print(f+"=7")
                exit()

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

ops = []
for i in range(1 << 3):
    ops = []
    for j in range(3):
        if (i >> j & 1) == 1:
            ops.append("+")
        else:
            ops.append("-")
    ans = nums[0]
    for j in range(3):
        if ops[j] == "+":
            ans += nums[j+1]
        else:
            ans -= nums[j+1]
    if ans == 7:
        print(nums[0], end="")
        for j in range(3):
            print(ops[j] + str(nums[j+1]), end="")
        print("=7")
        exit()

Solution (Python):
s=list(input())
n=len(s)
 
def dfs(i,f,su):
    if i==n-1:
        if su==7:
            print(f+"=7")
            exit()
    else:
        dfs(i+1,f+"+"+s[i+1], su+int(s[i+1]))
        dfs(i+1,f+"-"+s[i+1], su-int(s[i+1]))
 
 
print(dfs(0,s[0],int(s[0])))

Solution (Python):
a,b,c,d=input()
for f in [a+p+b+q+c+r+d for p in'+-'for q in'+-'for r in'+-']:
 if eval(f)==7:print(f+'=7');break

Solution (Python):
a,b,c,d=input()
s='+-'
for p in s:
 for q in s:
  for r in s:
   f=a+p+b+q+c+r+d
   if eval(f)==7:print(f+'=7');exit()

Solution (Python):
a,b,c,d=input()
import itertools as it
for p,q,r in it.product('+-',repeat=3):
  f=a+p+b+q+c+r+d
  if eval(f)==7: print(f+'=7'); break

Solution (Python):
S = input()
l = ['+', '-']
flg = False
for i in range(2):
  if flg:
    break
  for j in range(2):
    if flg:
      break
    for k in range(2):
      exp = S[0] + l[i] + S[1] + l[j] + S[2] + l[k] + S[3]
      if eval(exp) == 7:
        print(exp + '=7')
        flg = True
        break

Solution (Python):
N=input()
A=int(N[0])
E=7-A
for i in range(8):
 F=["-","-","-"]
 B=int(N[1])
 C=int(N[2])
 D=int(N[3])
 for j in range(3):
  if ((i >> j) & 1):
   F[j]="+"
 if F[0]=="-":
  B*=-1
 if F[1]=="-":
  C*=-1
 if F[2]=="-":
  D*=-1
 if B+C+D==E:
  print(str(A)+str(F[0])+str(abs(B))+str(F[1])+str(abs(C))+str(F[2])+str(abs(D))+"=7")
  break

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np

Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): 
    s = input()
    op = ["+","+","+"]
    for i in range(1 << 3):
        for j in range(3):
            if i >> j & 1:
                op[j] = "-"
        tmp = s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]
        if eval(tmp) == 7:
            print(tmp+"=7")
            exit()
        op = ["+","+","+"]
if __name__ == "__main__":
    main()

Solution (Python):
A, B, C, D = (int(x) for x in input())

class Op(int):
  def __str__(self):
     return '-' if self < 0 else '+'
    
pm = (Op(1), Op(-1))    

def solve():
  for op1 in pm:
    for op2 in pm:
      for op3 in pm:
        if A + op1 * B + op2 * C + op3 * D == 7:
          print(''.join(str(x) for x in [A, op1, B, op2, C, op3, D]) + '=7')
          return

solve()

Solution (Python):
s=list(input())
for i in range(4):
  s[i]=int(s[i])
op=['+','-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      cnt=s[0]
      if i==0:
        cnt+=s[1]
      else:
        cnt-=s[1]
      if j==0:
        cnt+=s[2]
      else:
        cnt-=s[2]
      if k==0:
        cnt+=s[3]
      else:
        cnt-=s[3]
      if cnt==7:
        print(str(s[0])+op[i]+str(s[1])+op[j]+str(s[2])+op[k]+str(s[3])+'=7')
        exit()

Solution (Python):
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
while True:
    if a + b + c + d == 7:
        print('%d+%d+%d+%d=7'%(a,b,c,d))
        break
    if a + b + c - d == 7:
        print('%d+%d+%d-%d=7'%(a,b,c,d))
        break
    if a + b - c + d == 7:
        print('%d+%d-%d+%d=7'%(a,b,c,d))
        break
    if a + b - c - d == 7:
        print('%d+%d-%d-%d=7'%(a,b,c,d))
        break
    if a - b - c - d == 7:
        print('%d-%d-%d-%d=7'%(a,b,c,d))
        break
    if a - b + c + d == 7:
        print('%d-%d+%d+%d=7'%(a,b,c,d))
        break
    if a - b + c - d == 7:
        print('%d-%d+%d-%d=7'%(a,b,c,d))
        break
    if a - b - c + d == 7:
        print('%d-%d-%d+%d=7'%(a,b,c,d))
        break

Solution (Python):

from itertools import permutations, combinations,combinations_with_replacement,product
N = input()



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


a=list(product(['-','+'],repeat=3)) 

for i in a:
    ans = N[0]+i[0]+N[1]+i[1]+N[2]+i[2]+N[3]
    
    if(eval(ans)==7):
        print(ans+'=7')
        break
'''
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):

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('{}+{}+{}+{}=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):
N = str(input())
S=[int(c) for c in N]

eq_1=0 
for num in range(1<<(len(S)-1)):
    eq_1 = S[0]
    list_1=[]
    for i in range(len(S)-1):
        if num & (1 << i):
            eq_1+=S[i+1]
            list_1.append("+")
        else:
            eq_1-=S[i+1]
            list_1.append("-")
    if eq_1==7:
        print("{}{}{}{}{}{}{}=7".format(S[0],list_1[0],S[1],list_1[1],S[2],list_1[2],S[3]))
        break

Solution (Python):
N = str(input())
num=N
S=[int(c) for c in N]






hako=[]
eq_1=0 
eq_2=0
ans=0


for num in range(1<<(len(S)-1)):
    eq_1 = S[0]
    eq_2 = S[0]
    list_1=[]
    for i in range(len(S)-1):
        if num & (1 << i):
            eq_1+=S[i+1]
            list_1.append("+")
        else:
            eq_1-=S[i+1]
            list_1.append("-")
    if eq_1==7:
        print("{}{}{}{}{}{}{}=7".format(S[0],list_1[0],S[1],list_1[1],S[2],list_1[2],S[3]))
        break

Solution (Python):
s = input()

def op(i):
    if i == 0:
        return "+"
    else:
        return "-"

for i in range(2):
    for k in range(2):
        for j in range(2):
            f = s[0] + op(i) + s[1] + op(k) + s[2] + op(j) + s[3] 
            if eval(f) == 7:
                print(f + "=7")
                exit()