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

for i in range(1 << 3):
    start = ["+", "+", "+"]
    for j in range(3):
        if (i >> j) & 1:
            start[j] = "-"
    
    ans = int(x[0])
    for k in range(3):
        if start[k] == "+":
            ans += int(x[k + 1])
        else:
            ans -= int(x[k + 1])
    
    if ans == 7:
        print(x[0] + str(start[0]) + x[1] + str(start[1]) + x[2] + str(start[2]) + x[3] + "=7")
        break

Solution (Python):
import itertools
L = ['+', '-']
s = list(input())
for l in itertools.product(L, repeat=3):
  if 7 == eval(s[0]+l[0]+s[1]+l[1]+s[2]+l[2]+s[3]):
    print(s[0]+l[0]+s[1]+l[1]+s[2]+l[2]+s[3]+'=7')
    break

Solution (Python):
A=list(input())
b=[]
for i in range(2**3):
  b.clear()
  for j in range(3):
    if (i>>j)&1:
      b.append("+")
    else:
      b.append("-")
  c=eval(A[0]+b[0]+A[1]+b[1]+A[2]+b[2]+A[3])
  if c==7:
    print(A[0]+b[0]+A[1]+b[1]+A[2]+b[2]+A[3]+"=7")
    exit()

Solution (Python):
def dfs(i,sumnum,sums):
    global ans
    if i == 4:
        if sumnum == 7:
            print(sums + "=7")
            exit()
    else:
        dfs(i+1,sumnum + int(s[i]),sums + "+" + s[i])
        dfs(i+1,sumnum - int(s[i]),sums + "-" + s[i])
s = input()
dfs(1,int(s[0]),s[0])

Solution (Python):
def dfs(i,sumnum,sums):
    global ans
    if i == 4:
        if sumnum == 7:
            print(sums + "=7")
            exit()
    else:
        dfs(i+1,sumnum + int(s[i]),sums + "+" + s[i])
        dfs(i+1,sumnum - int(s[i]),sums + "-" + s[i])
s = input()
ans = ""
dfs(1,int(s[0]),s[0])

Solution (Python):
def dfs(i,sumnum,sums):
    global ans
    if i == 4:
        if sumnum == 7:
            ans = sums + "=7"
    else:
        dfs(i+1,sumnum + int(s[i]),sums + "+" + s[i])
        dfs(i+1,sumnum - int(s[i]),sums + "-" + s[i])
s = input()
ans = ""
dfs(1,int(s[0]),s[0])
print(ans)

Solution (Python):
def dfs(i,sum1,sum2):
    global ans
    if i == 4 and sum1 != 7:
        return 0
    elif i == 4 and sum1 == 7:
        ans = sum2 + "=7"
        return 0
    else:
        dfs(i + 1,sum1 + int(s[i]),sum2 + "+" + s[i])
        dfs(i + 1, sum1 - int(s[i]), sum2 + "-" + s[i])

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

Solution (Python):
num = list(input())
for i in range(2**3):
    n = []
    pm = ["+","+","+"]
    for j in range(3):
        if ((i >> j) & 1):
            pm[j] = "-"
    for k in range(3):
        n.append(num[k])
        n.append(pm[k])
    n.append(num[3])
    formula = ""
    for j in range(7):
        formula += n[j] 
    if eval(formula) == 7:
        [print(n[k],end="") for k in range(7)]
        print("=7")
        exit()

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

ans=0
for bit in range(1 << (n - 1)):
    
    
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            
            f += "+"
        else:
          f+="-"
        f += s[i + 1]
        
    
    ans=eval(f)
    if ans==7:
      f+="=7"
      print(f)
      exit()

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

for i in [-1,1]:
  for j in [-1,1]:
    for k in [-1,1]:
      if A + B*i+ C*j + D*k == 7:
        it = "-" if i == -1 else "+"
        jt = "-" if j == -1 else "+"
        kt = "-" if k == -1 else "+"
        print(str(A)+it+str(B)+jt+str(C)+kt+str(D)+"=7")
        exit(0)

Solution (Python):
def si(p):
  if p == 0:
    return "-"
  else:
    return "+"
N = int(input())
X = [N // 1000, (N % 1000) // 100, (N % 100) // 10, N % 10]
f = 0
for i in range(2):
  for j in range(2):
    for k in range(2):
      x = X[0] + (2 * i - 1) * X[1] + (2 * j - 1) * X[2] + (2 * k - 1) * X[3]
      if x == 7:
        print(str(X[0]) + si(i) + str(X[1]) + si(j) + str(X[2]) + si(k) + str(X[3]) + "=7")
        f = 1
        break
    if f == 1:
      break
  if f == 1:
    break

Solution (Python):
def dfs(i,sum1,sum2):
    global ans
    
    if i == 4 and sum1 != 7:
        return 0
    elif i == 4 and sum1 == 7:
        ans = sum2 + "=7"
    else:
        dfs(i + 1,sum1 - int(s[i]),sum2 + "-" +s[i])
        dfs(i + 1,sum1 + int(s[i]),sum2 + "+" +s[i])

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

Solution (Python):
s = str(input())
for i in range(8):
  t = s[0]
  x = int(t)
  if i%2 == 0:
    t = t + "+"+ s[1]
    x += int(s[1])
  else:
    t = t + "-" + s[1]
    x -= int(s[1])
  if (i//2)%2 == 0:
    t = t + "+" + s[2]
    x += int(s[2])
  else:
    t = t + "-" + s[2]
    x -= int(s[2])
  if (i//4)%2 == 0:
    t = t + "+" + s[3]
    x += int(s[3])
  else:
    t = t + "-" + s[3]
    x -= int(s[3])
  if x == 7:
    print(t+"=7")
    exit()

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=map(int,input())
if a+b-c+d == 7:
        print('%d+%d-%d+%d=7' %(a,b,c,d))
        exit()
elif a+b-c-d == 7:
        print('%d+%d-%d-%d=7' %(a,b,c,d))
        exit()
elif a-b-c+d == 7:
        print('%d-%d-%d+%d=7' %(a,b,c,d))
        exit()
elif a-b-c-d == 7:
        print('%d-%d-%d-%d=7' %(a,b,c,d))
        exit()
elif a+b+c+d ==7:
        print('%d+%d+%d+%d=7' %(a,b,c,d))
        exit()
elif a+b+c-d ==7:
        print('%d+%d+%d-%d=7' %(a,b,c,d))
        exit()
elif a-b+c+d ==7:
        print('%d-%d+%d+%d=7' %(a,b,c,d))
        exit()
elif a-b+c-d ==7:
        print('%d-%d+%d-%d=7' %(a,b,c,d))
        exit()

Solution (Python):
n = [int(x) for x in input()]
for i in range(2 ** 3):
    a = list([str(n[0]), '-', str(n[1]), '-', str(n[2]), '-', str(n[3])])
    total = n[0]
    for j in range(3):
        if ((i >> j) & 1):
            a[int(2*j)+1] = '+'
            total = total + n[j+1]
        else:
            total = total - n[j+1]
    if total == 7:
        a.append('=7')
        print(''.join(a))
        exit()

Solution (Python):






def insert_str(target, i, char):
    return target[:i] + char + target[i:]

def calc(target, i):
    global ans
    
    if ans != "":
        return
    
    if i == 7:
        if eval(target) == 7:
            ans = target+"=7"
            return ans
        return
    calc(insert_str(target, i, "+"), i+2)
    calc(insert_str(target, i, "-"), i+2)
        
S = input()
N = len(S)
ans = ""
calc(S, 1)


print(ans)

Solution (Python):
a, b, c, d = map(int, list(input()))
if a + b + c + d == 7:
    print("{}+{}+{}+{}=7".format(a, b, c, d))
elif a + b + c - d == 7:
    print("{}+{}+{}-{}=7".format(a, b, c, d))
elif a + b - c + d == 7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
elif a - b + c + d == 7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
elif a + b - c - d == 7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
elif a - b - c + d == 7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
elif a - b + c - d == 7:
    print("{}-{}+{}-{}=7".format(a, b, c, d))
elif a - b - c - d == 7:
    print("{}-{}-{}-{}=7".format(a, b, c, d))

Solution (Python):
m = input()
m = list(m)
m = list(map(int,m))
for i in range(2**3):
    n = m[0]
    x = i
    t = []
    for _ in range(3):
        if x % 2 != 0:
            n += m[_+1]
            t.append('+')
        else:
            n -= m[_+1]
            t.append('-')
        x = x // 2
    if n == 7:
        l = [m[0],t[0],m[1],t[1],m[2],t[2],m[3],'=',7]
        l = list(map(str,l))
        print(''.join(l))
        break

Solution (Python):
s = input()

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

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

Solution (Python):
A,B,C,D = map(int,input())
tfs = []
rt = str(A)
for bt in (True, False):
  for ct in (True, False):
    for dt in (True, False):
      tfs.append([bt,ct,dt])
for bt,ct,dt in tfs:
  tmp=7-A
  tmp = tmp-B if bt else tmp+B
  tmp = tmp-C if ct else tmp+C
  tmp = tmp-D if dt else tmp+D
  if tmp == 0:
    rt+="+" if bt else "-"
    rt+=str(B)
    rt+="+" if ct else "-"
    rt+=str(C)
    rt+="+" if dt else "-"
    rt+=str(D)
    rt+="=7"
    break

print(rt)

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):
data=list(input())
if eval(data[0]+"+"+data[1]+"+"+data[2]+"+"+data[3])==7:
    print(data[0]+"+"+data[1]+"+"+data[2]+"+"+data[3]+"=7")
elif eval(data[0]+"+"+data[1]+"+"+data[2]+"-"+data[3])==7:
    print(data[0]+"+"+data[1]+"+"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"+"+data[1]+"-"+data[2]+"-"+data[3])==7:
    print(data[0]+"+"+data[1]+"-"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"+"+data[1]+"-"+data[2]+"+"+data[3])==7:
    print(data[0]+"+"+data[1]+"-"+data[2]+"+"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"+"+data[2]+"+"+data[3])==7:
    print(data[0]+"-"+data[1]+"+"+data[2]+"+"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"+"+data[2]+"-"+data[3])==7:
    print(data[0]+"-"+data[1]+"+"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"-"+data[2]+"-"+data[3])==7:
    print(data[0]+"-"+data[1]+"-"+data[2]+"-"+data[3]+"=7")
elif eval(data[0]+"-"+data[1]+"-"+data[2]+"+"+data[3])==7:
    print(data[0]+"-"+data[1]+"-"+data[2]+"+"+data[3]+"=7")
else:
    pass

Solution (Python):
abcd = input()

for i in range(1 << 3):
    res = int(abcd[0])
    op = abcd[0]
    for k in range(3):
        if i >> k & 1:
            res += int(abcd[k + 1])
            op += "+" + abcd[k + 1]
        else:
            res -= int(abcd[k + 1])
            op += "-" + abcd[k + 1]
    if res == 7:
        op += "=7"
        print(op)
        break

Solution (Python):
import sys
s = input()
for i in range(8):
    siki = s[0]
    tmp = int(s[0])
    for j in range(3):
        if i&(1<<j):
            siki = siki+'+'+s[j+1]
            tmp+=int(s[j+1])
        else:
            siki = siki + '-' + s[j+1]
            tmp-=int(s[j+1])
    if tmp==7:
        print(siki,"=7",sep="")
        exit()

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

for mask in range(2**n):
    total = L[0]
    s = str(L[0])
    for i in range(1, n):
        num = L[i]
        
        if mask & (1 << i):
            total += num
            s += '+' + str(num)
        else:
            total -= num
            s += '-' + str(num)
    if total == 7:
        print(s+'=7')
        exit()

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

Solution (Python):
a = input()

for x in range(1<<3):
  s = a[0]

  for i in range(3):
    if x & (1<<i):
      s += '+'
    else:
      s += '-'
    s += a[i+1]

  if eval(s) == 7:
    print(s + '=7')
    exit()

Solution (Python):
S= input()
List=list(S)
mid=int(List[0])
opList = ["+"]*3
res="a"

for bits in range(2**3): 
  for j in range(3):
    if((bits>>j) & 1):
      opList[j] = "+"
      mid = mid + int(List[j+1])
    else:
      opList[j] = "-"
      mid = mid - int(List[j+1])
  if mid == 7:
    res = List[0]+opList[0]+List[1]+opList[1]+List[2]+opList[2]+List[3]+"=7"
    break
  else:
    mid = int(List[0])
    opList = ["+"]*3
print(res)

Solution (Python):
S = input()
A, B, C, D = [int(s) for s in S]
op_l = ["+", "-"]

ex = ""
for op_1 in op_l:
    for op_2 in op_l:
        for op_3 in op_l:
            ans = A + B if op_1 == "+" else A - B
            ans = ans + C if op_2 == "+" else ans - C
            ans = ans + D if op_3 == "+" else ans - D
            if ans == 7:
                ex = str(A) + op_1 + str(B) + op_2 + str(C) + op_3 \
                     + str(D) + "=7"

print(ex)

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

for i in range(1<<(l-1)):
  Q=[]
  ans=int(S[0])
  for j in range(l-1):
    if (i>>j)&1:
      Q.append('+')
    else:
      Q.append('-')
  for k in range(l-1):
    if Q[k]=='+':
      ans+=int(S[k+1])
    else:
      ans-=int(S[k+1])
  if ans==7:
    ret=str(S[0])
    for k in range(l-1):
      ret+=Q[k]
      ret+=S[k+1]
    ret+='=7'
    print(ret)
    exit()

Solution (Python):
def solve():
    a, b, c, d = map(int, list(input()))
    op = ["+", "-"]
    ans = ""
    for op1 in range(2):
        for op2 in range(2):
            for op3 in range(2):
                s = "a"+op[op1]+"b"+op[op2]+"c"+op[op3]+"d"
                if eval(s) == 7:
                    return str(a)+op[op1]+str(b)+op[op2]+str(c)+op[op3]+str(d)+"=7"


print(solve())

Solution (Python):
ABCD=input()
f=""
for bit in range(1<<3):
  f=ABCD[0]
  for i in range(3):
    if bit&(1<<i):
      f+="+"
    else:
      f+="-"
    f+=ABCD[i+1]
  if eval(f)==7:
    print(f+"=7")
    exit()

Solution (Python):
def main():
    abcd = list( map( int , list( input() ) ) )

    for i in range( 2 ** 3 ):
        ans = str( abcd[0] )
        sum = abcd[0]
        x = i

        for j in range( 1,4 ):
                
            y = x % 2
            if y:
                sum += abcd[ j ]
                ans += '+'
            else:
                sum -= abcd[ j ]
                ans += '-'
            
            ans += str( abcd[ j ] )

            x = x // 2
        if sum == 7:
            ans += '=7'
            break
    print(ans)





main()

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

Solution (Python):
import itertools

s = input()
op = ["+","-"]
for ops in itertools.product(op, repeat=3):
  result = int(s[0]) 
  for i in range(len(ops)):
    if ops[i] == "+":
      result += int(s[i+1]) 
    else :
      result -= int(s[i+1]) 
  if result == 7:
    print(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3]+"="+str(result))
    break

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

for i in [True, False]:
    for j in [True, False]:
        for k in [True, False]:
            if i:
                ans = a[0] + a[1]
            else:
                ans = a[0] - a[1]
            if j:
                ans += a[2]
            else:
                ans -= a[2]
            if k:
                ans += a[3]
            else:
                ans -= a[3]
            if ans == 7:
                ans = str(a[0])
                if i:
                    ans += '+'
                else:
                    ans += '-'
                ans += str(a[1])
                if j:
                    ans += '+'
                else:
                    ans += '-'
                ans += str(a[2])
                if k:
                    ans += '+'
                else:
                    ans += '-'
                ans += str(a[3]) + '=7'
                print(ans)
                exit()

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

ss = []

def numToString(s):
    if s >= 0:
        s = '+' + str(s)
    else:
        s = str(s)
    return s

for i in range(2):
    if sum(s) == 7:
        ss += str(s[0])
        ss += list(map(numToString, s[1:4]))
        ss = ''.join(ss)
        print(ss + '=7')
        exit()

    for j in range(2):
        if sum(s) == 7:
            ss += str(s[0])
            ss += list(map(numToString, s[1:4]))
            ss = ''.join(ss)
            print(ss + '=7')
            exit()

        for k in range(2):
            if sum(s) == 7:
                ss += str(s[0])
                ss += list(map(numToString, s[1:4]))
                ss = ''.join(ss)
                print(ss + '=7')
                exit()

            s[3] *= -1
        s[2] *= -1
    s[1] *= -1

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

for i in range(2**n):
  res=int(a[0])
  ans=[a[0]]
  for j in range(1,n):
    if i&(1<<j):
      ans.append('+')
      ans.append(a[j])
      res+=int(a[j])
    else:
      ans.append('-')
      ans.append(a[j])
      res-=int(a[j])
  if res==7:
    print(*ans,'=7',sep='')
    exit()

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    abcd = list(map(int,list(S())))
    bits = itertools.product([0,1],repeat=3)

    for bit in bits:
        cnt = abcd[0]
        for i,op in zip(abcd[1:],bit):
            if op == 0:
                cnt += i
            else:
                cnt -= i
        if cnt == 7:
            ans = str(abcd[0])
            for i,op in zip(abcd[1:],bit):
                ans += "+" if op == 0 else "-"
                ans += str(i)
            break
    ans += "=7"
    print(ans)
main()

Solution (Python):
s = input()

for bit in range(1 << 3):
    ans = s[0]
    value = int(s[0])
    for i in range(3):
        if bit & (1 << i):
            ans += "+" + s[i+1]
            value += int(s[i+1])
        else:
            ans += "-" + s[i+1]
            value -= int(s[i+1])
    
    if value == 7:
        print(ans + "=7")
        exit()

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


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

Solution (Python):
s = input()
n = len(s) - 1
for i in range(1 << n):
    p_or_m = ['-'] * n
    for j in range(n):
        if i >> j & 1:
            p_or_m[n-j-1] = '+'
    
    formula = ''
    for k in range(n):
        formula += s[k] + p_or_m[k]
    formula += s[3]
    if  eval(formula) == 7:
        print(formula + '=7')
        exit()

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

for i in range(2**(l-1)):
    ans = 0
    a = s[0]
    for j in range(l-1):
        if i >> j & 1 == 0:
            a += '+' + s[j+1]
        elif i >> j & 1 == 1:
            a += '-' + s[j+1]
    ans = eval(a)
    if ans == 7:
        print(a + '=7')
        exit()

Solution (Python):
from itertools import zip_longest

s = list(input())

for i in range(2**3) :
    lis = []
    c = ""
    for j in range(3) :
        if (i >> j) & 1 :
            lis.append("+")
        else:
            lis.append("-")
        
    for a, b in zip_longest(s, lis, fillvalue = "") :
        c += a + b
    
    if eval(c) == 7 :
        print(f"{c}=7")
        break

Solution (Python):
from itertools import zip_longest

s = list(input())

for i in range(2**3) :
    lis = []
    c = ""
    for j in range(3) :
        if (i >> j) & 1 :
            lis.append("+")
        else:
            lis.append("-")
        
    for a, b in zip_longest(s, lis, fillvalue = "") :
        c += a + b
    
    if eval(c) == 7 :
        print(f"{c}=7")
        break

Solution (Python):
def main():
    import sys
    a = input()
    ans =0
    for i in range(2**3):
        t = a[0]
        for j in range(3):
            if i & (1 <<j):
                t = t +'+'
            else:
                t = t +'-'
            t = t +a[j+1]
        ans =eval(t)
        if ans == 7:
            print(t+'=7')
            sys.exit()
if __name__ =='__main__':
    main()

Solution (Python):
import re

def dfs(i, formula_str):
    if i == 4:
        res = int(formula_str[0])
        for j in range(2, 7, 2):
            if formula_str[j-1] == "+":
                res += int(formula_str[j])
            else:
                res -= int(formula_str[j])
        if res == 7:
            return True, formula_str
        return False, formula_str
    else:
        f_1, formula_str_1 = dfs(i+1, formula_str + "+" + s[i])
        f_2, formula_str_2 = dfs(i+1, formula_str + "-" + s[i])
        if f_1:
            return True, formula_str_1
        elif f_2:
            return True, formula_str_2
        else:
            return False, None

s = input()
f, ans = dfs(1, s[0])
print(ans + "=7")

Solution (Python):
S = [a for a in input()]
N = [int(a) for a in S]
M = [N[0]] + [-N[i] for i in range(1,4)]

S.insert(1, '+')
S.insert(3, '+')
S.insert(5, '+')

if sum(N) == 7:
    S = S
    print(''.join(S) + '=7')
    exit()

for i in range(1, 4):
    N[i] = -N[i]
    
    if sum(N) == 7:
        
        S[2 * i - 1] = '-'
        print(''.join(S) + '=7')
        exit()
    else: N[i] = -N[i]

for i in range(1, 4):
    S[1], S[3], S[5] = '-', '-', '-'
    
    M[i] = -M[i]
    
    if sum(M) == 7:
        S[2 * i - 1] = '+'
        print(''.join(S) + '=7')
        exit()
    else:
      M[i] = -M[i]

Solution (Python):
from itertools import permutations
a = list(map(int, input()))

op = ['+', '+', '+', '-', '-', '-']
for ops in permutations(op, 3):
    now = a[0]
    for i in range(3):
        if ops[i] == '+':
            now += a[i+1]
        else:
            now -= a[i+1]
    if now == 7:
        print("{}{}{}{}{}{}{}=7".format(
            a[0], ops[0], a[1], ops[1], a[2], ops[2], a[3]))
        exit()

Solution (Python):
abcd=input()

res=''
for i in range(2**3):
    B=format(i,'b').zfill(3)
    sum_=int(abcd[0])
    res=abcd[0]
    j=1
    for k in range(3):
        if B[k]=='1':
            sum_+=int(abcd[j])
            res+='+'
        else:
            sum_-=int(abcd[j])
            res+='-'
        res+=abcd[j]
        j+=1
    if sum_==7:
        break

print('{}=7'.format(res))

Solution (Python):
lsnum = list(input())
lsnum1 = [int(i) for i in lsnum]
ls = ['+','-']
for i in range(2 ** 3):
    ans = lsnum1[0]
    for j in range(3):  
        if ((i >> j) & 1):  
           ans += lsnum1[j+1]
        else:
            ans -= lsnum1[j+1]
    if ans == 7:
        bit = i
        break
ans2 = lsnum[0]
for i in range(3):
    if ((bit >> i) & 1):
        ans2 += '+'+lsnum[i+1]
    else:
        ans2 += '-'+lsnum[i+1]
print(ans2+'=7')

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

Solution (Python):
s=input()
numbers=[]
[numbers.append(int(s[i])) for i in range(4)]
for i in range(2**3):
  opes=[]
  count=numbers[0]
  for j in range(3):
    if (i>>j)&1:
      opes.append("+")
      count+=numbers[j+1]
    else:
      opes.append("-")
      count-=numbers[j+1]
  if count==7:
    print(numbers[0],end="")
    for k in range(3):
      print(opes[k],end="")
      print(numbers[k+1],end="")
    print("=",end="")
    print(count)
    exit()

Solution (Python):
S = list(input())
total=int(S[0])
i = 0
j = 0
k = 0
while True:
    if i == 0:
        total += int(S[1])
    else:
        total -= int(S[1])
    if j == 0:
        total += int(S[2])
    else:
        total -= int(S[2])
    if k == 0:
        total += int(S[3])
    else:
        total -= int(S[3])

    if total == 7:
        break
    else:
        if k == 0:
            k = 1
        else:
            k = 0
            if j == 0:
                j = 1
            else:
                j = 0
                i = 1
    total = int(S[0])
if i == 0:
    op1 = '+'
else:
    op1 = '-'
if j == 0:
    op2 = '+'
else:
    op2 = '-'
if k == 0:
    op3 = '+'
else:
    op3 = '-'


print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+'=7')

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

Solution (Python):
def main():
  s = input()

  for op in range(16):
    t = s[0]
    for j in range(3):
      if (op & (1 << j)):
        t = t + "+"
      else:
        t = t + "-"
      t = t + s[j+1]
    
    if eval(t) == 7:
      print(t + "=7")
      exit(0)
      
  
if __name__ == '__main__':
  main()

Solution (Python):
S = input()
l = len(S)
ans = 0

for i in range(2**(l-1)):
    T = S[0]
    for j in range(l-1):
        if i>>j & 1:
            T = T + "-"
        else:
            T = T + "+"
        T = T+S[j+1]
    if eval(T) == 7:
        print(T+"=7")
        exit()

Solution (Python):
S=input()

for i in range(2**3):
    t=S[0]
    for j in range(3):
        if i & (1<<j):
            t+='+'
        else:
            t+='-'
        t+=S[j+1]
    if eval(t)==7:
        break
print(t+'=7')

Solution (Python):
from itertools import product

s=input()

for op in product(["+","-"],repeat=3):
  formula =""
  for i in range(3):
    formula+=s[i]+op[i]
  formula+=s[-1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Solution (Python):
from itertools import product

s=input()

for op in product(["+","-"],repeat=3):
  formula =""
  for i in range(3):
    formula+=s[i]+op[i]
  formula+=s[-1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Solution (Python):
nums = list(map(int, list(input())))
ans = ''
for n in range(8):
    bits = bin(n)[2:].zfill(3)
    total = nums[0]
    ans = str(nums[0])
    for i, b in enumerate(bits):
        if b == '0':
            total += nums[i+1]
            ans += '+' + str(nums[i+1])
        else:
            total -= nums[i+1]
            ans += '-' + str(nums[i+1])

    if total == 7:
        ans += '=7'
        break

print(ans)

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):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    ABCD = S()
    A = ABCD[0]
    BCD = ABCD[1:]

    ans = [A, '', BCD[0], '', BCD[1], '', BCD[2], '=', '7']
    for i in range(2 ** 3):
        tmp = int(A)
        for j in range(3):
            if i >> j & 1:
                tmp += int(BCD[j])
                ans[j*2+1] = '+'
            else:
                tmp -= int(BCD[j])
                ans[j*2+1] = '-'
        if tmp == 7:
            print(''.join(ans))
            break

if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
abcd=str(input())
n=len(abcd)
ans=int(abcd[0])
sign=[]
for i in range(2**(n-1)):
    for j in range(n-1):
        if (i>>j)&1==True:
            ans+=int(abcd[j+1])
            sign.append("+")
        else:
            ans-=int(abcd[j+1])
            sign.append("-")
    if ans==7:
        print(abcd[0]+sign[0]+abcd[1]+sign[1]+abcd[2]+sign[2]+abcd[3]+"=7")
        sys.exit()
    else:
        ans=int(abcd[0])
        sign=[]

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:
    op1 = op2 = op3 = "+"
elif A + B + C - D == 7:
    op1 = op2 = "+"
    op3 = "-"
elif A + B - C + D == 7:
    op1 = op3 = "+"
    op2 = "-"
elif A + B - C - D == 7:
    op1 = "+"
    op2 = op3 = "-"
elif A - B + C + D == 7:
    op1 = "-"
    op2 = op3 = "+"
elif A - B + C - D == 7:
    op1 = op3 = "-"
    op2 = "+"
elif A - B - C + D == 7:
    op1 = op2 = "-"
    op3 = "+"
elif A - B - C - D == 7:
    op1 = op2 = op3 = "-"
print(S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3] + "=7")

Solution (Python):
s=input()
for i in range(2**3):
    t=s[0]
    for j in range(3):
        if i%2:t+='+'
        else:t+='-'
        i//=2
        t+=s[j+1]
    if eval(t+'==7'):
        print(t+'=7')
        exit()

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[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):
List = [int(n) for n in input()]
ans = [List[0]] * 4
for i in range(8):
    for j in range(3):
        if i & (1<<j):
            ans[j+1]= -List[j+1]
        else:
            ans[j+1] = List[j+1]
    if sum(ans) == 7:
        break
ans = [str(ans[0])] + ['+' + str(x) if x>=0 else str(x) for x in ans[1:]]
print("".join(ans) + '=7')

Solution (Python):
s = input()

def dfs(i,tmp,sum):
    if i == 3:
        if sum == 7:
            print(tmp + "=7")
            exit()

    else:
        dfs(i+1, tmp +"+"+ s[i+1], sum + int(s[i+1]))
        dfs(i+1, tmp +"-"+ s[i+1], sum - int(s[i+1]))

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

Solution (Python):


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

num = input()
nums = [int(num[0]), int(num[1]), int(num[2]), int(num[3])]

sum_ = sum(nums)

for bit in range(1 << 3):
    tmp = sum_
    ops = ['+', '+', '+']
    for j in range(3):
        if bit & (1 << j):
            tmp -= 2 * nums[j+1]
            ops[j] = '-'
    if tmp == 7:
        res = str(nums[0]) + ops[0] + str(nums[1]) + ops[1] + str(nums[2]) + ops[2] + str(nums[3]) + '=7'
        print(res)
        break

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

ans = 0


for bit in range(1 << (n-1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        else:
            f += "-"
        f += s[i+1]
    if  eval(f) == 7:
        print(f+"=7")
        break

Solution (Python):
import sys

A = list(map(int,sys.stdin.readline().rstrip()))

from itertools import product

X = ['+','-']
for a in product(X,repeat=3):
    b = A[0]
    for i in range(3):
        if a[i] == '+':
            b += A[i+1]
        else:
            b -= A[i+1]
    if b == 7:
        print(str(A[0])+a[0]+str(A[1])+a[1]+str(A[2])+a[2]+str(A[3])+'=7')
        break