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():
    a = list(map(int, list(input())))
    for i in range(2**3):
        cnt = a[0]
        pm = []
        for j in range(3):
            if ((i >> j) & 1):
                cnt += a[j+1]
                pm.append('+')
            else:
                cnt -= a[j+1]
                pm.append('-')
        if cnt == 7:
            print('{}{}{}{}{}{}{}=7'.format(a[0], pm[0], a[1], pm[1], a[2], pm[2], a[3]))
            break

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
A, B, C, D = input()
for i in itertools.product(['+', '-'], repeat=3):
    if eval(A+i[0]+B+i[1]+C+i[2]+D) ==7:
        print(A+i[0]+B+i[1]+C+i[2]+D+'=7')
        exit()

Solution (Python):
A, B, C, D = input()
for i in range(2**3):
    ans =["+", "+", "+"]
    for j in range(3):
        if (i>>j) & 1:
            ans[j] = "-"
    if eval(A+ans[0]+B+ans[1]+C+ans[2]+D) ==7:
        print(A+ans[0]+B+ans[1]+C+ans[2]+D+'=7')
        break

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

for bit in range(2 ** 3):
    value = ABCD[0]
    equation = str(ABCD[0])
    for i in range(3):
        if bit & (1 << i):
            value += ABCD[i + 1]
            equation = equation + '+' + str(ABCD[i + 1])
        else:
            value -= ABCD[i + 1]
            equation = equation + '-' + str(ABCD[i + 1])
    if value == 7:
        print(equation + '=7')
        break

Solution (Python):
nums = input()
op = [""]*3
for i in range(2**3):
    b = bin(i)[2:]
    b = "0"*(3 - len(b)) + b
    for j in range(len(b)):
        if b[j] == "1":
            op[j] = "+"
        else:
            op[j] = "-"
    string = "".join(nums[i]+op[i] for i in range(3))+nums[-1]
    if eval(string) == 7:
        print(string + "=7")
        break

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

def change_pnsign(op):
    if op == 1:
        op = "+"
        return op
    else:
        op = "-"
        return op


list = [1,-1]
for op1,op2,op3 in itertools.product(list,list,list):
    ans = a+op1*b+op2*c+op3*d
    if ans == 7:
        OP1=change_pnsign(op1)
        OP2=change_pnsign(op2)
        OP3=change_pnsign(op3)
        print(f"{a}{OP1}{b}{OP2}{c}{OP3}{d}=7")
        sys.exit()

Solution (Python):
from itertools import product

ABCD=input()
for tf in list(product([False,True],repeat=3)):
  sum_=int(ABCD[0])
  str_=ABCD[0]
  for j in range(3):
    if tf[j]==True:
      str_+="+"
      sum_+=int(ABCD[j+1])
    else:
      str_+="-"
      sum_-=int(ABCD[j+1])
    str_+=ABCD[j+1]
  if sum_==7:
    print(str_+"=7")
    exit()
print("No")

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

for i in range(1<<3):
    num = [a, b, c, d]
    for j in range(3):
        if i>>j & 1 != 1:  
            num[j+1] *= -1
    ans = sum(num)
    if ans == 7:
        for k, n in enumerate(num):
            if n >= 0 and k > 0:
                print('+', n, sep='', end='')
            else:
                print(n, sep='', end='')
        else:
            print('=7', sep='')
        break

Solution (Python):

s = input()
for bit in range(1<<3):
    a = int(s[0])
    func = s[0]
    for i in range(3):
        if bit & (1<<i):
            func += '+'
            a += int(s[i+1])
        else : 
            func += '-'
            a -= int(s[i+1])
        func += s[i+1]
    
    if a == 7:
        print(func + '=7')
        exit()
print('No')

Solution (Python):
n = input()
for x in range(1 << 3):
    opr = ["-"] * 3
    for i in range(3):
        if x & (1 << i):
            opr[i] = "+"
    shiki = "%s%s%s%s%s%s%s" % (n[0], opr[0], n[1], opr[1], n[2], opr[2], n[3])
    if eval(shiki) == 7:
        print("%s=7" % shiki)
        break

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

def get_str(i):
    if i >= 0:
        s = "+{}".format(i)
    else:
        s = "{}".format(i)
    return s

for i in range(1 << 3):
    ai, bi, ci, di = a, b, c, d
    if (i >> 2) % 2:
        bi = -b
    if (i >> 1) % 2:
        ci = -c
    if (i >> 0) % 2:
        di = -d

    if ai+bi+ci+di == 7:
        s = ""
        s += get_str(ai)
        s += get_str(bi)
        s += get_str(ci)
        s += get_str(di)
        s += "=7"
        print(s[1::])
        break

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

Solution (Python):
n = input()
op_cnt = len(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] = "+"  

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
a,b,c,d = input()
for i in range(2**3):
    x = ['-','-','-']
    for j in range(3):
        if i>>j&1:
            x[j] = '+'
    if eval(a+x[0]+b+x[1]+c+x[2]+d) == 7:
        print(a+x[0]+b+x[1]+c+x[2]+d + '=7')
        break

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

def m(x):
    re = a
    ls = [str(a)]
    for i in range(3):
        if (x>>i)&1 == 1 :
            re +=int(n[i+1])
            ls.append('+'+n[i+1])
        else:
            re -=int(n[i+1])
            ls.append('-'+n[i+1])
    return re, ls

for j in range(8):
    if m(j)[0]==7:
        print(''.join(m(j)[1])+'=7')
        exit()

Solution (Python):
from itertools import product

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

ops = product([1,-1],repeat=3)

for op in ops:
  test = a + b * op[0] + c * op[1] + d * op[2]
  if test == 7:
    _op = [""]*3
    for i in range(3):
      _op[i] = "+" if op[i] == 1 else "-"
    print("{}{}{}{}{}{}{}=7".format(a,_op[0],b,_op[1],c,_op[2],d))
    exit()
print(-1)

Solution (Python):
def dfs(i, f, sum):
  if i == 3:
    if sum == 7:
      print(f + '=7')
      exit()
      
  else:
    dfs(i+1, f + '-' + n[i+1], sum-int(n[i+1]))
    dfs(i+1, f + '+' + n[i+1], sum+int(n[i+1]))
    
n = input()
dfs(0, n[0], int(n[0]))

Solution (Python):

def abc079_c():
    stlist = input()

    def DFS(i,sum,li):
        if i == len(stlist)-1:
            if sum == 7:
                print(str(stlist[0])+str(li[0])+str(stlist[1])+str(li[1])+str(stlist[2])+str(li[2])+str(stlist[3])+"=7")
                exit()
            return

        
        li[i]="+"
        DFS(i+1,sum+int(stlist[i+1]),li)

        
        li[i]="-"
        DFS(i+1,sum-int(stlist[i+1]),li)

    DFS(0,int(stlist[0]),[[] for i in range(3)])










abc079_c()

Solution (Python):
from itertools import product

A,B,C,D=map(int,input())
O=["+","-"]
X=product(O,repeat=3)

for (p,q,r) in X:
    T="{}{}{}{}{}{}{}".format(A,p,B,q,C,r,D)
    if eval(T)==7:
        print("{}=7".format(T))
        break

Solution (Python):
n = input()
l = len(n)-1
for i in range(2**l):
  s = n[0]
  a = int(n[0])
  for j in range(l):
    if i >> j & 1:
      s += "+"
      a += int(n[j+1])
    else:
      s += "-"
      a -= int(n[j+1])
    s += n[j + 1]
  if a == 7:
    print(s + "=7")
    break

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

for i in range(2**3):
    op = ['+', '+', '+']
    for j in range(3):
        if (i >> j) & 1 == 1:
            op[j] = '-'
    if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
        print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
        sys.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])]

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

for i in b:
    for j in c:
        for k in d:
            if 7 == a + i + j + k:
                print('{}{}{}{}{}{}{}=7'.format(a, sign(i), abs(i), sign(j), abs(j), sign(k), abs(k)))
                exit(0)

Solution (Python):
import itertools as it
n=[x for x in input()]
In=list(it.product(['+','-'],repeat=3))
for k in range(8):
   ans = eval(n[0]+In[k][0]+n[1]+In[k][1]+n[2]+In[k][2]+n[3])
   if ans==7:
    print(n[0]+In[k][0]+n[1]+In[k][1]+n[2]+In[k][2]+n[3]+"=7")
    exit()

Solution (Python):
import sys
a, b, c, d = [n for n in list(input())]
n = 3

for bit in range(1<<n):
    
    op = []
    for i in range(n):
        if bit & (1<<i):
            op.append('+')
        else:
            op.append('-')
    

    formula = a + op[2] + b + op[1] + c + op[0] + d
   
    if eval(formula) == 7:
        print(formula+'=7')
        sys.exit(0)

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

Solution (Python):
S = input()
for i in range(1 << 3):
    op = ['+'] * 3
    for j in range(3):
        if i >> j & 1:
            op[j] = '-'
    res = ''
    for s, p in zip(S, op):
        res += s + p
    res += S[-1]
    if eval(res) == 7:
        res += '=7'
        print(res)
        break

Solution (Python):
abcd = input()

n = 2 ** 3
result = ''

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * (3 - len(bin_n)) + bin_n

  num = int(abcd[0])
  for j in range(3):
    if bin_n[j] == '0':
      num += int(abcd[j+1])

    else:
      num -= int(abcd[j+1])

  if num == 7:
    result = bin_n

print(abcd[0], end='')
print('+' if result[0] == '0' else '-', end='')
print(abcd[1], end='')
print('+' if result[1] == '0' else '-', end='')
print(abcd[2], end='')
print('+' if result[2] == '0' else '-', end='')
print(abcd[3], end='')
print('=7')

Solution (Python):
a,b,c,d=map(int,input())
A,B,C,D=str(a),str(b),str(c),str(d)
if a+b+c+d==7:
    print(A+"+"+B+"+"+C+"+"+D+"=7")
elif a+b+c-d==7:
    print(A+"+"+B+"+"+C+"-"+D+"=7")
elif a+b-c+d==7:
    print(A+"+"+B+"-"+C+"+"+D+"=7")
elif a-b+c+d==7:
    print(A+"-"+B+"+"+C+"+"+D+"=7")
elif a+b-c-d==7:
    print(A+"+"+B+"-"+C+"-"+D+"=7")
elif a-b+c-d==7:
    print(A+"-"+B+"+"+C+"-"+D+"=7")
elif a-b-c+d==7:
    print(A+"-"+B+"-"+C+"+"+D+"=7")
else:
    print(A+"-"+B+"-"+C+"-"+D+"=7")

Solution (Python):
import itertools
s = input()
plm = ['+','-']

for i in itertools.product(plm, repeat=3):
    moziretsu =s[0]+i[0]+s[1]+i[1]+s[2]+i[2]+s[3]
    if eval(moziretsu) == 7:
        print(moziretsu+'=7')
        break

Solution (Python):
S = input()
ans = 0
signal = ['']*3

for i in range(2**3):
    if bin(i & 1) == bin(1):
        ans += int(S[3])
        signal[2] = '+' 
    else:
        ans -= int(S[3])
        signal[2] = '-'
    
    if bin(i>>1 & 1) == bin(1):
        ans += int(S[2])
        signal[1] = '+' 
    else:
        ans -= int(S[2])
        signal[1] = '-' 
    
    if bin(i>>2 & 1) == bin(1):
        ans += int(S[0])+int(S[1])
        signal[0] = '+'
    else:
        ans += int(S[0])-int(S[1])
        signal[0] = '-' 

    if ans == 7:
        print('%s%s%s%s%s%s%s=7' % (S[0], signal[0], S[1], signal[1], S[2], signal[2], S[3]))
        break
    else:
        ans = 0

Solution (Python):


import sys

def check(a,b,c,d,ans_pattern):
    ans_list=[b,c,d]
    ans=a
    for i in range(3):
        if ans_pattern[i]=="+":
            ans+=ans_list[i]
        else:
            ans-=ans_list[i]
    if ans==7:
        print("{}{}{}{}{}{}{}=7".format(a,ans_pattern[0],b,ans_pattern[1],c,ans_pattern[2],d))
        sys.exit() 

def main2():
    
    
    a,b,c,d=map(int,input())
    for i in range(2**3):
        ans_pattern=["+","+","+"]
        for j in range(3):
            if (i >> j)&1:
                ans_pattern[j]="-"
        check(a,b,c,d,ans_pattern)
 
if __name__=="__main__":
    main2()

Solution (Python):
S = input().strip()


for i in range(2**3):
  ans = S[0] 
  _sum = int(S[0]) 
  for j in range(3):
    if (i>>j)&1: 
      """ビットが1のとき"""
      ans += "+" + S[j+1]
      _sum += int(S[j+1])
    else:
      """ビットが0のとき"""
      ans += "-" + S[j+1]
      _sum -= int(S[j+1])
  if _sum == 7:
    ans += "=7"
    print(ans)
    quit()

Solution (Python):
S = input()
a,b,c,d = int(S[0]),int(S[1]),int(S[2]),int(S[3])
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):
import itertools

number = input()
A, B, C, D = (int(number[i]) for i in range(4))
for op1, op2, op3 in itertools.product(['+','-'], repeat=3):
    result = A
    if(op1 == '+'):
        result+=B
    else:
        result-=B
    if(op2 == '+'):
        result+=C
    else:
        result-=C
    if(op3=='+'):
        result+=D
    else:
        result-=D
    if result == 7:
        print(A,op1,B,op2,C,op3,D,'=7',sep='')
        break

Solution (Python):

    
S = input()
num = len(S) - 1

for i in range(2**num):
    op=["-"]*num
    for j in range(num):
        if (i>>j)&1:
            op[num-j-1]="+"
            
    formula=""
    for op_S,op_num in zip(S,op+[""]):
        formula += op_S + op_num

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

Solution (Python):
import sys


S = [s for s in input()]
A = [int(s) for s in S]

for i in range(1 << 3):
    b = format(i, f'03b')[::-1]
    t = A[0]
    u = S[0]
    for j in range(3):
        if b[j] == '1':
            t += A[j + 1]
            u += "+" + S[j + 1]
        else:
            t -= A[j + 1]
            u += "-" + S[j + 1]
    if t == 7:
        print(u + "=7")
        sys.exit()

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


nums = list(map(int, S()))
ans = ''
for i in range(2 ** 3):
    res = nums[0]
    ans = str(nums[0])
    for j in range(3):
        if i >> j & 1:
            res += nums[j + 1]
            ans += f'+{nums[j + 1]}'
        else:
            res -= nums[j + 1]
            ans += f'-{nums[j + 1]}'
    if res == 7:
        ans += '=7'
        break
print(ans)

Solution (Python):
s=input()

for i in range(2**3):
  chk=""
  for j in range(3):
    chk+=s[j]
    if (i>>j)&1==1:
      chk+='+'
    else:
      chk+='-'
  chk+=s[3] 
  if eval(chk)==7:
    break
print(f"{chk}=7")

Solution (Python):

from itertools import product

s = input()
op_patterns = product(['+', '-'], repeat=3)

for operators in op_patterns:
    expression = f"{s[0]}{operators[0]}{s[1]}{operators[1]}{s[2]}{operators[2]}{s[3]}"
    if eval(expression) == 7:
        print(f"{expression}=7")
        break

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())


def main():
    ABCD = list(input())
    for ops in range(2**3):
        t = int(ABCD[0])
        ans = ABCD[0]
        for i in range(3):
            if (ops>>i)&1:
                t += int(ABCD[i+1])
                ans += '+'+ABCD[i+1]
            else:
                t -= int(ABCD[i+1])
                ans += '-'+ABCD[i+1]
        if t == 7:
            ans += '=7'
            print(ans)
            return


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

for i in range(8):
    cal = ""
    for j in range(3):
        cal += s[j]
        if (i >> j) & 1:
            cal += "+"
        else:
            cal += "-"
    cal += s[3]
    if eval(cal) == 7:
        break

print(f"{cal}=7")

Solution (Python):
def a(t,i):
    if i == l - 1:
        if eval(t)==7:
            print(t+"=7")
            exit()
        return
    a(t+"+"+N[i+1],i+1)
    a(t+"-"+N[i+1],i+1)

N = input()
l = len(N)
a(N[0],0)

Solution (Python):
n = input()
op_cnt = len(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] = "+"  

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
S = input()
N = len(S) - 1

for i in range(2**N):
    
    num = int(S[0])
    op = ["+","+","+",]
    
    for j in range(N):
        if i >> j & 1:
            op[-1-j] = "-"
            num -= int(S[-1-j])
        else:
            num += int(S[-1-j])
    
    if num == 7:
        print(S[0],op[0],S[1],op[1],S[2],op[2],S[3],"=7",sep="")
        break

Solution (Python):
abcd = input()

n = ["+","-"]
for i1 in n:
  for i2 in n:
    for i3 in n:
      if eval(abcd[0]+i1+abcd[1]+i2+abcd[2]+i3+abcd[3]) == 7:
        print(abcd[0]+i1+abcd[1]+i2+abcd[2]+i3+abcd[3]+"=7")
        exit()

Solution (Python):
def dfs(i, f, Sum):
    if i == 3:
        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]))
  
if __name__ == '__main__':        
    s = input()
    dfs(0, s[0], int(s[0]))

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

flag = 7
while flag >= 0:
    S = []
    total = nums[0]
    bin_str = format(flag, "03b")
    for i, bit in enumerate(bin_str, 1):
        if int(bit):
            total += nums[i]
            S.append("+")
        else:
            total -= nums[i]
            S.append("-")
    if total == 7:
        break
    
    flag -= 1
print(f"{nums[0]}{S[0]}{nums[1]}{S[1]}{nums[2]}{S[2]}{nums[3]}=7")

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

for i in range(2 ** (n - 1)):
    ope = S
    cur = 0
    for j in range(n - 1):
        if (i >> j) & 1:
            ope = ope[:-j - cur - 1] + '+' + ope[-j - cur - 1:]
        else:
            ope = ope[:-j - cur - 1] + '-' + ope[-j - cur - 1:]
        cur += 1
    if eval(ope) == 7:
        print(ope + '=7')
        break

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

Solution (Python):
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
  c=''
  c+=A[0]
  bns=int(A[0])
  for j in range(3):
    if i[j]==0:
      bns+=int(A[j+1])
      c+='+'+A[j+1]
    else:
      bns-=int(A[j+1])
      c+='-'+A[j+1]
  if bns==7:
    print(c+'=7')
    exit()

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

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

AA = ABCD[0]
BB = ABCD[1]
CC = ABCD[2]
DD = ABCD[3]

if A+B+C+D==7:
    print(AA+'+'+BB+'+'+CC+'+'+DD+'=7')
elif A+B+C-D==7:
    print(AA+'+'+BB+'+'+CC+'-'+DD+'=7')
elif A+B-C+D==7:
    print(AA+'+'+BB+'-'+CC+'+'+DD+'=7')
elif A+B-C-D==7:
    print(AA+'+'+BB+'-'+CC+'-'+DD+'=7')
elif A-B+C+D==7:
    print(AA+'-'+BB+'+'+CC+'+'+DD+'=7')
elif A-B+C-D==7:
    print(AA+'-'+BB+'+'+CC+'-'+DD+'=7')
elif A-B-C+D==7:
    print(AA+'-'+BB+'-'+CC+'+'+DD+'=7')
elif A-B-C-D==7:
    print(AA+'-'+BB+'-'+CC+'-'+DD+'=7')

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

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

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


def plus(items, key):
    if(key == 1):
        return items[0] + items[1]
    else:
        return items[0] - items[1]


def numToOp(num):
    return "+" if num == 1 else "-"


ans = 0
opList = [1, 1, 1]
i = 0
while ans != 7:
    aPlusB = plus([a, b], opList[0])
    aPlusBPlusC = plus([aPlusB, c], opList[1])
    ans = plus([aPlusBPlusC, d], opList[2])
    

    if ans != 7 and i <= 4:
        opList[i % 3] *= -1
        i += 1
    elif ans != 7 and i == 5:
        opList = [1, -1, 1]
        i += 1
    elif ans != 7 and i == 6:
        opList = [-1, 1, -1]
        i += 1



print(
    f"{a}{numToOp(opList[0])}{b}{numToOp(opList[1])}{c}{numToOp(opList[2])}{d}=7")

Solution (Python):
a = list(map(int, input()))
ans = ""
for i in range(2 ** 3):
  b = [i for i in a]
  for j in range(3):
    if (i >> j) & 1:
      b[j + 1] *= -1
  if sum(b) == 7:
    ans += (str)(b[0])
    for j in range(1, 4):
      if b[j] >= 0:
        ans += "+" + (str)(b[j])
      else:
        ans += (str)(b[j])
    ans += "=7"
    break
else:
  print("none")
print(ans)

Solution (Python):
from itertools import product

A, B, C, D = input()
for op1, op2, op3 in product("+-", repeat=3):
    exp = f"{A}{op1}{B}{op2}{C}{op3}{D}"
    if eval(exp) == 7:
        print(exp + "=7")
        exit()

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

Solution (Python):

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

for n in range(3**2):
    ans = nums[0]
    ops = []
    for i in range(3):
        if 1 & (n >> i):
            ans += nums[i+1]
            ops.append('+')
        else:
            ans -= nums[i+1]
            ops.append('-')

    if ans == 7:
        b = ['%d%s' % (nums[i], ops[i]) for i in range(3)]
        b += ['%d' % nums[3]]
        print(''.join(b) + '=7')
        exit()

Solution (Python):
def calc(S: str, cur: int, e: str):
    if S == "":
        if cur == 7:
            print(e+"=7")
            quit()
        else:
            return

    calc(S[1:], cur + int(S[0]), e + "+" + S[0])
    calc(S[1:], cur - int(S[0]), e + "-" + S[0])


S = input().strip()
ans = calc(S[1:], int(S[0]), S[0])

Solution (Python):
def resolve():
    A, B, C, D = list(input())
    OP = ("+", "-")
    for i in range(2**3):
        op = ["+" for _ in range(3)]
        for j in range(3):
            if (i >> j) & 1:
                op[j] = OP[0]
            else:
                op[j] = OP[1]
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + "=7")
            return

resolve()

Solution (Python):
import numpy as np

S = input()
ans = int(S[0])
ope = []

while True:
    for i in S[1:]:
        if np.random.randint(2) == 0:
            ans += int(i)
            ope.append("+")
        else:
            ans -= int(i)
            ope.append("-")

    if ans == 7:
        print(S[0]+ope[0]+S[1]+ope[1]+S[2]+ope[2]+S[3]+"=7")
        exit()
    else:
        ans = int(S[0])
        ope = []

Solution (Python):
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
pm = '+-'
for i in range(2):
  for j in range(2):
    for k in range(2):
      if i == 0:
        temp = a + b
      else:
        temp = a - b
      if j == 0:
        temp += c
      else:
        temp -= c
      if k == 0:
        temp += d
      else:
        temp -= d
      if temp == 7:
        print(s[0] + pm[i] + s[1] + pm[j] + s[2] + pm[k] + s[3] + '=7')
        exit()

Solution (Python):
def c_train_ticket():
    from itertools import product
    operands = tuple(input())
    
    for operators in product('+-', repeat=3):
        formula = ''.join(ch + op for ch, op in zip(operands, operators + ('',)))
        if eval(formula) == 7:
            return formula + '=7'
    return None  

print(c_train_ticket())

Solution (Python):
n = input()
l = len(n)-1

for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if (i>>j)&1:
            op[l - j - 1] = "+" 
    formula = ""
    for op_1,op_2 in zip(n,op+[""]): 
        formula += op_1 + op_2
    if eval(formula)==7:
        print(formula + "=7")
        break

Solution (Python):
from itertools import product
import sys

S = str(input())
A = list(product(['+', '-'], repeat=3))

for a in A:
    ans = 0
    tmp = ""
    for i in range(len(S)-1):
        tmp += S[i]+a[i]
    tmp += S[len(S)-1]
    ans += eval(tmp)
    if ans == 7:
        print(tmp+"=7")
        sys.exit()

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

    formula = ""
    for op_num,op_l in zip(n,op+[""]):
        formula += op_num + op_l
    if eval(formula)==7:
        print(formula+"=7")
        break

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

f, g = a+b, a-b
h, i, j, k = f+c, f-c, g+c, g-c
l, m, n, o, p, q, r, s = h + d, h - d, i + d, i - d, j + d, j - d, k + d, k - d
if(l == 7):
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif(m == 7):
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif(n == 7):
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif(o == 7):
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif(p == 7):
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif(q == 7):
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif(r == 7):
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif(s == 7):
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")

Solution (Python):
from collections import defaultdict
from itertools import product as pd

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

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

bitAll = pd([0,1],repeat=3)
for i in bitAll:
	t = l[0]
	for j in range(3):
		if i[j]==1:
			t+=l[j+1]
		else:
			t-=l[j+1]
	if t==7:
		tar = "".join([str(j) for j in list(i)])
		break

l = [str(i) for i in l]
tar = tar.replace("1","+")
tar = tar.replace("0","-")
print(l[0]+tar[0]+l[1]+tar[1]+l[2]+tar[2]+l[3]+"=7")

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

for i in range(2**3):
    tmp=[0]*3
    for j in range(3):
        if (i>>j)&1:
            tmp[j]=1
    
    ans=s[0]
    for i in range(3):
        ans=ans+(op[i][tmp[i]]+s[i+1])
    if eval(ans)==7:
        print(ans+"=7")
        break

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

op_cnt = len(abcd) - 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 = int(abcd[0])
    for j in range(1, len(abcd)):
        if op[j-1]=="+":
            ans += int(abcd[j])
        else:
            ans -= int(abcd[j])

    if ans==7:
        for j in range(len(abcd)):
            if j==len(abcd)-1:
                print(abcd[j], "=7", sep="")
            else:
                print(abcd[j], op[j], end="", sep="")
        break

Solution (Python):
s = input()

for i in range(2**3):
    tmp = s
    for j in range(3):
        if (i>>j) &1:
            tmp = tmp[:j*2+1] + "+" + tmp[j*2+1:]
        else:
            tmp = tmp[:j*2+1] + "-" + tmp[j*2+1:]
    if eval(tmp) == 7:
        print(tmp+ "=7")
        exit()

Solution (Python):
a=input()
n=len(a)-1
for i in range(2**n):
    result=['+','+','+']
    for j in range(n):
        if ((i>>j)&1)==1:
            result[j]='-'
    if eval(''.join([a[0],result[0],a[1],result[1],a[2],result[2],a[3]]))==7:
        print(''.join([a[0],result[0],a[1],result[1],a[2],result[2],a[3]])+'=7')
        exit()

Solution (Python):
num = list(input())
num = [int(i) for i in num]
 
if sum(num) == 7:
    print(f'{num[0]}+{num[1]}+{num[2]}+{num[3]}=7')
elif num[0]+num[1]+num[2]-num[3] == 7:
    print(f'{num[0]}+{num[1]}+{num[2]}-{num[3]}=7')
elif num[0]+num[1]-num[2]+num[3] == 7:
    print(f'{num[0]}+{num[1]}-{num[2]}+{num[3]}=7')
elif num[0]-num[1]+num[2]+num[3] == 7:
    print(f'{num[0]}-{num[1]}+{num[2]}+{num[3]}=7')
elif num[0]+num[1]-num[2]-num[3] == 7:
    print(f'{num[0]}+{num[1]}-{num[2]}-{num[3]}=7')
elif num[0]-num[1]+num[2]-num[3] == 7:
    print(f'{num[0]}-{num[1]}+{num[2]}-{num[3]}=7')
elif num[0]-num[1]-num[2]+num[3] == 7:
    print(f'{num[0]}-{num[1]}-{num[2]}+{num[3]}=7')
else:
    print(f'{num[0]}-{num[1]}-{num[2]}-{num[3]}=7')

Solution (Python):


from itertools import product


S = input()
R = []


for p in product(*((0,1),)*3):
    res = S[0]
    for i, s in enumerate(S[1:]):
        if p[i]:
            res = res + "+" + s
        else:
            res = res + "-" + s
    if eval(res) == 7:
        print(res + "=7")
        exit()

Solution (Python):
num = input()
x = ['+', '-']

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

Solution (Python):
num = input()

x = ["+", "-"]

for i in x:
  for j in x:
    for k in x:
      n = eval(num[0]+i+num[1]+j+num[2]+k+num[3])
      if n == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        exit()

Solution (Python):


import sys
N = input()
lst = []
for i in N:
    lst.append(i)
    

for i in range(2**3):
    op = ['+','+','+']
    for j in range(3):
        
        
        if (i>>j)&1 == 1:
            
            op[j] = '-'
    tes = [0]*7
    tes[::2] = lst
    tes[1::2] = op
    
    if eval(''.join(tes)) == 7:
        print(''.join(tes)+'=7')
        sys.exit()

Solution (Python):
a=list(input())
for i in range(4):
  a[i]=int(a[i])
x=sum(a)-7
dict={0:'+',1:'-'}
ans=0
for i in range(2):
  for j in range(2):
    for k in range(2):
        if x==(i*a[1]+j*a[2]+k*a[3])*2:
          print(a[0],dict[i],a[1],dict[j],a[2],dict[k],a[3],'=7',sep='')
          ans=1
        if ans==1:
          break
    if ans==1:
      break
  if ans==1:
    break

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

for bit in range(1 << 3):
    t = str(nums[0])
    s = nums[0]
    for i in range(3):
        if (bit >> i) & 1:
            s += nums[i + 1]
            t += "+" + str(nums[i + 1])
        else:
            s -= nums[i + 1]
            t += "-" + str(nums[i + 1])

    if s == 7:
        t += "=7"
        print(t)
        break