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):
A, B, C, D = map(int, input())

if A + B + C + D == 7:
    print("{0}+{1}+{2}+{3}=7".format(A, B, C, D))

elif A + B + C - D == 7:
    print("{0}+{1}+{2}-{3}=7".format(A, B, C, D))

elif A + B - C + D == 7:
    print("{0}+{1}-{2}+{3}=7".format(A, B, C, D))

elif A + B - C - D == 7:
    print("{0}+{1}-{2}-{3}=7".format(A, B, C, D))

elif A - B + C + D == 7:
    print("{0}-{1}+{2}+{3}=7".format(A, B, C, D))

elif A - B + C - D == 7:
    print("{0}-{1}+{2}-{3}=7".format(A, B, C, D))

elif A - B - C + D == 7:
    print("{0}-{1}-{2}+{3}=7".format(A, B, C, D))

else:
    print("{0}-{1}-{2}-{3}=7".format(A, B, C, D))

Solution (Python):
s=input()
ans=0
def dfs(i,stri,sum): 
    global ans
    
    if i==3 and sum==7:
        
        ans=stri+"=7"
        
    
    if i<=2:
        dfs(i+1, stri+ f"+{s[i+1]}" , sum+int(s[i+1]))
        dfs(i+1, stri+ f"-{s[i+1]}", sum-int(s[i+1]))

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

Solution (Python):
s=input()
p=['+','-']
for i in range(8):
  t=s
  for j in range(3):
    t=t[:3-j]+p[(i>>j)&1]+t[3-j:]
  if eval(t)==7:
    print(t+'=7')
    exit()

Solution (Python):
correct = []
def dfs(i, s, stack):
	if i == 4:

		if eval(''.join(stack)) == 7:
			correct.append(''.join(stack) + '=7')
			return True
		else:
			return False

	if dfs(i+1, s,stack + ['+', s[i]]): return True
	if dfs(i+1, s,stack + ['-', s[i]]): return True
	return False
s = raw_input()
dfs(1, s, [s[0]])
print correct[0]

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

dic = { 1:"+" , -1:"-"}

import itertools
for AB,BC,CD in itertools.product([1,-1],repeat=3):
    tmp = A + B*AB + C*BC + D*CD

    if tmp ==7:
        ans = str(A)+dic[AB]+str(B)+dic[BC]+str(C)+dic[CD]+str(D)+"=7"
        print(ans)
        exit()

Solution (Python):
s = input()
a = [int(c) for c in s]
mark = ['+', '-']
sum = 0
ans = 0
for i in range(2**3):
    sum = int(a[0])
    for j in range(3):
        k = (i >> j)
        sum += int(a[j+1])*(-1)**k
    if sum == 7:
        ans = i
        break



b = []
m = []
formula = ''
for l in range(3):
    b.append(str(a[l+1]))
    c = (ans >> l & 1)
    m.append(mark[c])
    formula += (m[l] + b[l])
print(str(a[0]) + formula + '=7')

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

for i in range(2 ** (n - 1)):
    num = int(s[0])
    num_list = [str(s[0])]
    for j in range(n - 1):
        if (i >> j) & 1:
            num += int(s[j + 1])
            num_list.append("+" + str(s[j + 1]))
        else:
            num -= int(s[j + 1])
            num_list.append("-" + str(s[j + 1]))
    if num == 7:
        [print(t, end="") for t in num_list]
        print("=7")
        break

Solution (Python):
s = str(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):
abcd = str(input())
ans = ''

for i in range(2**(len(abcd)-1)):
  total = int(abcd[0])
  ans = abcd[0]
  for j in range(len(abcd)-1):
    if (i >> j) & 1:
      total += int(abcd[j+1])
      ans = ans + '+' + abcd[j+1]
    else:
      total -= int(abcd[j+1])
      ans = ans + '-' + abcd[j+1]
  if total == 7:
    ans = ans + '=7'
    break
print(ans)

Solution (Python):
from itertools import product
S = input()
n = len(S)
bit = list(product([0, 1], repeat = n - 1))
for state in bit:
    ans = int(S[0])
    s = S[0]
    for i in range(len(state)):
        if state[i] == 1:
            s += '+' + S[i + 1]
            ans += int(S[i + 1])
        else:
            s += '-' + S[i + 1]
            ans -= int(S[i + 1])
    if ans == 7:
        print(s + '=7')
        break

Solution (Python):
tn=list(map(int,list(input())))
for i in range(0,16,2):
  if sum(x*[1,-1][i>>k&1] for k,x in enumerate(tn))==7:
    s=''.join(list(['+','-'][i>>k&1]+str(tn[k]) for k in range(1,4)))
    print(str(tn[0])+s+'=7')
    break

Solution (Python):
import sys
S=list(input())
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
if A+B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"+"+C+"+"+D+"=7")
  sys.exit()
elif A+B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"+"+C+"-"+D+"=7")
  sys.exit()
elif A+B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"-"+C+"+"+D+"=7")
  sys.exit()
elif A-B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"+"+C+"+"+D+"=7")
  sys.exit()
elif A+B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"-"+C+"-"+D+"=7")
  sys.exit()
elif A-B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"-"+C+"+"+D+"=7")
  sys.exit()
elif A-B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"+"+C+"-"+D+"=7")
  sys.exit()
elif A-B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"-"+C+"-"+D+"=7")
  sys.exit()

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

for i in range(8):
    abcd = abcd_origin.copy()
    temp = []
    temp.append(abcd.pop(0))
    for j in range(3):
        if (i >> j) & 1:
            temp.append('+')
            temp.append(abcd.pop(0))
        else:
            temp.append('-')
            temp.append(abcd.pop(0))

    result = int(temp[0])

    for k in range(3):
        if temp[2 * k + 1] == '+':
            result += int(temp[2 * k + 2])
        else:
            result -= int(temp[2 * k + 2])

    if result == 7:
        equ = ''.join(temp) + '=7'
        print(equ)
        exit()

Solution (Python):
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+int(S[i+1]))
        make7(i+1, f+"-"+S[i+1], sum-int(S[i+1]))


S = input()
n = len(S)

make7(0, S[0], int(S[0]))

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]))
s = input()
dfs(0, s[0], int(s[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[-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()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
arr=[b,c,d]
for i in range(8):
    x=i
    m=a
    k=''
    for j in range(3):
        if x&1:
            m+=arr[j]
            k+='+'
        else:
            m-=arr[j]
            k+='-'
        x=x>>1
    if m==7:
        print (s[0]+k[0]+s[1]+k[1]+s[2]+k[2]+s[3]+'='+'7')
        break

Solution (Python):


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

for i in range(2):
    for j in range(2):
        for k in range(2):
            ops = ['-'] * 3
            r = a
            if i % 2 == 0:
                r += b
                ops[0] = '+'
            else:
                r -= b

            if j % 2 == 0:
                r += c
                ops[1] = '+'
            else:
                r -= c

            if k % 2 == 0:
                r += d
                ops[2] = '+'
            else:
                r -= d
            
            if r == 7:
                print(str(a) + ops[0] + str(b) + ops[1] + str(c) + ops[2] + str(d) + '=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]))
        
s = input()
dfs(0, s[0], int(s[0]))

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


s = input()

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

Solution (Python):
num = input()

op_count = 3

for i in range(2**op_count):
    op = ["-"] * op_count
    for j in range(op_count):
        if (i >> j & 1):
            op[j] = "+"

    equ = ""

    for n_i,o_i in zip(num,op + [""]):
        equ += n_i + o_i
    if(eval(equ) == 7):
        print(equ + "=7") 
        break

Solution (Python):
ABCD = input()
operations = []
def culc(num, ope):
    if len(ope) == 4:
        if num == 7:
            return operations.append(ope)
        else:
            return
    
    if len(ope) != 0 and ope[-1] == '+':
        num += int(ABCD[len(ope)])
    elif len(ope) != 0 and ope[-1] == '-':
        num -= int(ABCD[len(ope)])
    
    culc(num, ope+'+')
    culc(num, ope+'-')
        
culc(int(ABCD[0]), '')
ans = ''
for i in range(len(ABCD)):
    ans += ABCD[i] + operations[0][i]
print(ans[:7] + '=7')

Solution (Python):
n=[int(x) for x in input()]
op_cnt=len(n)-1
for i in range(2**op_cnt):
    ops=['-']*op_cnt
    for j in range(op_cnt):
        if ((i>>j)&1):
            ops[op_cnt-1-j]='+'
    num=n[0]
    for i,op in enumerate(ops):
        if op=='-':
            num-=n[i+1]
        else:
            num+=n[i+1]
    if num==7:
        print(str(n[0])+ops[0]+str(n[1])+ops[1]+str(n[2])+ops[2]+str(n[3])+'=7')
        exit()

Solution (Python):
ABCD = input()

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

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

for i in range(1 << 3):
    x = A[0]
    ans = str(A[0])
    for j in range(3):
        if i & 1 << j > 0:
            x += A[j + 1]
            ans += '+' + str(A[j + 1])
        else:
            x -= A[j + 1]
            ans += '-' + str(A[j + 1])
    if x == 7:
        print(ans + "=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 = ""*(2+len(n)-1)
    formula+=n[0]
    for w in range(len(n)-1):
        formula+=op[w]+n[w+1]
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
n=int(input())
d=n%10
c=(n//10)%10
b=(n//100)%10
a=n//1000

for i in range(8):
    k=[1,1,1]
    for j in range(3):
        if ((i>>j)&1):
            k[j]=-1
    if a+k[0]*b+k[1]*c+k[2]*d==7:
        for j in range(3):
            if k[j]==1:
                k[j]="+"
            else:
                k[j]="-"
        print(str(a)+k[0]+str(b)+k[1]+str(c)+k[2]+str(d)+"=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('{}{}{}{}{}{}{}=7'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3]))
                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]))


s = input()

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

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

done = False
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            left = a
            left += b if op1 == '+' else -b
            left += c if op2 == '+' else -c
            left += d if op3 == '+' else -d
            if left == 7:
                done = True
                break
        if done:
            break
    if done:
        break
print('{a}{op1}{b}{op2}{c}{op3}{d}=7'.format(a=a, b=b, c=c, d=d, op1=op1, op2=op2, op3=op3))

Solution (Python):
import sys
S = input()
A = [int(a) for a in list(S)]
N = 4
crt = 7

for i in range(2**(N-1)):
  i_ = i
  j = 1
  tmp = A[0]
  while j < N:
    if i_ % 2 == 0:
      tmp += A[j]
    else:
      tmp -= A[j]
    i_ = i_>>1
    j += 1
  
  if tmp == crt:
    T = str(A[0])
    i_ = i
    j = 1
    while j < N:
      if i_ % 2 == 0:
        T += "+"
      else:
        T += "-"
      T += str(A[j])
      i_ = i_>>1
      j += 1
    T += "=7"
    print(T)
    sys.exit()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    num = list(map(int, readline().strip()))

    for bits in range(1 << 3):
        tmp = num[0]
        for i in range(3):
            if bits & (1 << i):
                tmp += num[i + 1]
            else:
                tmp -= num[i + 1]
        if tmp == 7:
            ans = [str(num[0])]
            for i in range(3):
                if bits & (1 << i):
                    ans.append('+')
                else:
                    ans.append('-')
                ans.append(str(num[i + 1]))
            ans.append('=7')
            ans = ''.join(ans)
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import itertools

S=input()

for i in itertools.product(["+","-"],repeat=3):
    ans=""
    for j in range(len(i)):
        if i[j]=="+":
            ans+=S[j]+i[j]
        elif i[j]=="-":
            ans+=S[j]+i[j]
    ans+=S[-1]
    sum_num=eval(ans)
    if sum_num==7:
        print(ans+"=7")
        break

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

for i in range(2**3):
  ans = int(S[0])
  res = ["-","-","-"]
  for j in range(3):
    if ((i >> j) & 1):
      ans += int(S[j+1])
      res[j] = "+"
    else:
      ans -= int(S[j+1])
  if ans == 7:
    print(S[0]+res[0]+S[1]+res[1]+S[2]+res[2]+S[3]+"=7")
    exit()

Solution (Python):
S=input()
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
ans=""
for x in [1,-1]:
  for y in [1,-1]:
    for z in [1,-1]:
      if A+B*x+C*y+D*z==7:
        if x==1:
          sx="+"
        else:
          sx="-"
        if y==1:
          sy="+"
        else:
          sy="-"
        if z==1:
          sz="+"
        else:
          sz="-"
        ans=str(A)+sx+str(B)+sy+str(C)+sz+str(D)+"=7"
print(ans)

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

for lst in itertools.product(['+','-'],repeat=3):
  sum=int(x[0])
  for i in range(3):
    if lst[i]=='+':
      sum+=int(x[i+1])
    else:
      sum-=int(x[i+1])
  if sum==7:
    print(x[0]+lst[0]+x[1]+lst[1]+x[2]+lst[2]+x[3]+'=7')
    break

Solution (Python):
op=["+","-"]
a,b,c,d=map(str,input())

for o1 in op:
  for o2 in op:
    for o3 in op:
      form= a+o1+b+o2+c+o3+d
      if eval(form)==7:
        print(form+"=7")
        exit()

Solution (Python):
ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
for i in range(1):
    if A + B + C + D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        exit()
    if A - B + C + D == 7:
        print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        exit()
    if A + B - C + D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        exit()
    if A + B + C - D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        exit()
    if A - B - C + D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        exit()
    if A - B + C - D == 7:
        print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        exit()
    if A + B - C - D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        exit()
    if A - B - C - D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        exit()

Solution (Python):

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

for i in range(1):
    if int(A) + int(B) + int(C) + int(D) == 7:
        print(A + "+" + B + "+" + C + "+" + D +"=7")
        break
    if int(A) - int(B) + int(C) + int(D) == 7:
        print(A + "-" + B + "+" + C + "+" + D +"=7")
        break
    if int(A) + int(B) - int(C) + int(D) == 7:
        print(A + "+" + B + "-" + C + "+" + D +"=7")
        break
    if int(A) - int(B) - int(C) + int(D) == 7:
        print(A + "-" + B + "-" + C + "+" + D +"=7")
        break
    if int(A) + int(B) + int(C) - int(D) == 7:
        print(A + "+" + B + "+" + C + "-" + D +"=7")
        break
    if int(A) - int(B) + int(C) - int(D) == 7:
        print(A + "-" + B + "+" + C + "-" + D +"=7")
        break
    if int(A) + int(B) - int(C) - int(D) == 7:
        print(A + "+" + B + "-" + C + "-" + D +"=7")
        break
    if int(A) - int(B) - int(C) - int(D) == 7:
        print(A + "-" + B + "-" + C + "-" + D +"=7")
        break

Solution (Python):


import sys

def debug(*a):
    print(*a, file=sys.stderr)

s = input().strip()
v = [int(s[i]) for i in range(4)]
for x in range(8):
    a = v[0]
    for i in range(3):
        if (x >> i) & 1:
            a += v[i+1]
        else:
            a -= v[i+1]
    debug(f'x = {x}, a = {a}')
    if a == 7:
        s = ''
        for i in range(3):
            s += str(v[i])
            if (x >> i) & 1:
                s += '+'
            else:
                s += '-'
        s += str(v[3]) + '=7'
        print(s)
        sys.exit(0)

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

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

flag = [0]*3
tmp = 0
for i in range(8):
  flag[0]=(i>>2)&1
  flag[1]=(i>>1)&1
  flag[2]=(i)&1
  
  tmp = A +(-1)**flag[0]*B +(-1)**flag[1]*C +(-1)**flag[2]*D
  if tmp==7:
    ans=s[0]
    for j in range(3):
      if flag[j]:
        ans+="-"+s[j+1]
      else:
        ans+="+"+s[j+1]
    ans+="=7"
    print(ans)
    break

Solution (Python):
D = input()
A = [int(D[0]),int(D[1]),int(D[2]),int(D[3])]
for i in range(2**3):
    B = A[::1]
    C = ["+"]*3
    for j in range(3):
        if (i >> j) & 1:
            B[j+1] *= -1
            C[j] = "-"
    if sum(B) == 7:
        print(f"{A[0]}{C[0]}{A[1]}{C[1]}{A[2]}{C[2]}{A[3]}=7")
        exit()

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

Solution (Python):
s = str(input())
n = 4
for bit in range(1 << (n-1)):
    f = s[0]
    for i in range(0,(n-1)):
        if bit & (1 << i):
            f += '+-' + s[i+1]
        else:
            f += '+' + s[i+1]
    
    ans = sum(map(int,f.split('+')))
    if ans == 7:
        break
print(f.replace('+-','-')+'=7')

Solution (Python):



S = input().strip()
res = 7
num = list()
for i in range(len(S)):
    num.append(int(S[i]))

for b in range(2**(3)):
    b_str = format(b, 'b').zfill(len(S)-1)
    sum = num[0]
    for i in range(len(num) - 1):
        if b_str[i] == '0':
            sum -= num[i+1]
        else:
            sum += num[i+1]
    if sum == res:
        break

plus_or_minus = list()
for i in range(3):
    if b_str[i] == '0':
        plus_or_minus.append('-')
    else:
        plus_or_minus.append('+')
print('{}{}{}{}{}{}{}=7'.format(num[0], plus_or_minus[0], num[1], plus_or_minus[1], num[2], plus_or_minus[2], num[3]))

Solution (Python):
import itertools
s = input()
ans=0
for i in list(itertools.product([0,1], repeat=len(s)-1)):
    b = 0
    a = int(s[0])
    l = [a]+[0]*(2*(len(s)-1))
    for j in range(len(s)-1):
        if i[j] == 0:
            a += int(s[j+1])
            l[2*j+1] = '+'
            l[2*j+2] = str(s[j+1])
        else:
            a -= int(s[j+1])
            l[2*j+1] = '-'
            l[2*j+2] = str(s[j+1])
    if a == 7:
        l[0] = str(s[0])
        l += '=7'
        l = ''.join(l)
        print(l)
        break

Solution (Python):
A,B,C,D = (int(T) for T in list(input()))
ABCD = [A+B+C+D,A+B+C-D,A+B-C+D,A+B-C-D,A-B+C+D,A-B+C-D,A-B-C+D,A-B-C-D]
Op   = ['+++','++-','+-+','+--','-++','-+-','--+','---']
Disp = list(Op[ABCD.index(7)])
print('{}{}{}{}{}{}{}=7'.format(A,Disp[0],B,Disp[1],C,Disp[2],D))

Solution (Python):
import sys
a = list(str(input()))



for i in range(1 << 3):
    op = ['+']*3
    
    for j in range(3):
        if (i >> j)&1:
            
            op[j] = "-"
    op.append('')        
    res = ''
    
    for x,y in zip(a,op):
        res += x+y
        
    if eval(res) == 7:
        print(res+'=7')
        sys.exit()

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

for v in op:
    for w in op:
        for x in op:
            l = str(a+v+b+w+c+x+d)
            if eval (l) == 7:
                print (l+"=7")
                exit ()

Solution (Python):
import itertools
a, b, c, d = map(int, list(input()))
l1 = [1, -1]
l2 = [1, -1]
l3 = [1, -1]

for op1, op2, op3 in itertools.product(l1, l2, l3):
    tmp = a + b*op1 + c*op2 + d*op3
    if tmp == 7:
        break

op1, op2, op3 = map(lambda x: "+" if x==1 else "-", [op1, op2, op3])

print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+"=7")

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):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    a, b, c, d = list(input())
    ops = tuple(product(('+', '-'), repeat=3))
    for opse in ops:
        o = a + opse[0] + b + opse[1] + c + opse[2] + d
        s = eval(o)
        if s == 7:
            r = o + '=7'
            print(r)
            sys.exit()

if __name__ == '__main__':
    main()

Solution (Python):

X=input()

N=len(X)
n=N-1
A=0
num=0
total=0

for i in range(2**n):
    A=X[0]
    for j in range(n):
        if (i>>j)&1:
            A+=".+"+X[j+1]
        else:
            A+=".-"+X[j+1]

    num=list(map(int,A.split(".")))
    total=sum(num)

    if total==7:
        break

print(A.replace(".","")+"=7")

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

for bit in range(1 << 3):
    answer = 0
    op = ["-", "-", "-"]
    for i in range(3):
        if (bit >> i) & 1:
            op[i] = "+"
    if eval(abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3]) == 7:
        answer = abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3] + "=7"
        break
print(answer)

Solution (Python):
a,b,c,d=input()
for i in range(2**3):
    op=["-","-","-"]
    for j in range(3):
        if (i>>j&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")
        exit()

Solution (Python):
num_li = list(input())
for i in range(2**3):
    li = ['+']*3
    q = num_li[0]
    for j in range(3):
        if ((i>>j) & 1):
            li[j] = '-'
        q += li[j] + num_li[j+1]
    if eval(q) == 7:
        print('{}=7'.format(q))
        break

Solution (Python):
from itertools import product
A,B,C,D = list(input())
for k in list(product(['+','-'],repeat=3)):
    k = A + k[0] + B + k[1] + C + k[2] + D
    if eval(k) == 7:
        print('{}=7'.format(k))
        break

Solution (Python):
n = input()
for i in range(2**3):
    op =[]
    for j in range(3):
        if i >> j & 1:
            op.append('+')
        else:
            op.append('-')
    formula = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
    if eval(formula) == 7:
        print(formula + '=7')
        exit()

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

for i in range(2**(N-1)):
    tmp = int(S[0])
    sentence = S[0]

    for j in range(N-1):
        flag = (i >> j) & 1

        if flag: 
            tmp += int(S[j+1])
            sentence += "+" + S[j+1]
        else:
            tmp -= int(S[j+1])
            sentence += "-" + S[j+1]

    if tmp == 7:
        print(sentence + "=7")
        exit()

Solution (Python):
s=input()
n=4-1
for i in range(1<<n):
    lst=list(s)
    for j in range(n):
        if ((i>>j)&1):
            lst.insert(2*j+1,"+")
            
        else:
            lst.insert(2*j+1,"-")
    if(eval("".join(lst))==7):
        print(("".join(lst))+"=7")
        break

Solution (Python):
num = input()

for bit in range(2**3):
    op = ["+", "+", "+"]
    for i in range(3):
        if (bit >> i) & 1:
            op[i] = "-"
    if eval(num[0]+op[0]+num[1]+op[1]+num[2]+op[2]+num[3]) == 7:
        print("{}=7".format(num[0]+op[0]+num[1]+op[1]+num[2]+op[2]+num[3]))
        break

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

for i in range(2**3):
  ans = a
  temp=[]
  for j in range(3):
    if i >> j & 1:
      temp.append("+")
    else:
      temp.append("-")
  for i,j in zip([b,c,d],temp):
    if j == "+":
      ans+=i
    else:
      ans-=i
  if ans == 7:
    print(str(a) + temp[0] + str(b) + temp[1] + str(c) + temp[2] +str(d) + "=7")
    break

Solution (Python):
s = input()

def recursum(count, f, sum):
    if count == 3:
        if sum == 7:
            print(f+"=7")
            exit()
    else:
        recursum(count+1, f+"-"+s[count+1], sum-int(s[count+1]))
        recursum(count+1, f+"+"+s[count+1], sum+int(s[count+1]))

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

Solution (Python):
def GSB(x):
	counter=0
	while x!=0:
		counter+=1
		x=x>>1
	return counter


N=[int(x) for x in (list(input()))]
combinations=[int(x) for x in range((2**4))]
for i in combinations:
	checker=[x for x in N]
	j=0
	z=GSB(i)
	while j!=z and i!=0:
		if i&1==1:
			checker[j]*=-1
		i=i>>1
		j+=1
	if sum(checker)==7 and checker[0]>=0:
		checker=checker + [-1]
		for i in range(4):
			if checker[i+1]>=0:
				print(checker[i],end="+")
			else:
				print(checker[i],end="")
		print("=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]))


s = input()

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

Solution (Python):
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    A = list(map(int, list(input())))
    for op in range(1 << 3):
        ans = A[0]
        for i in range(3):
            if op & (1 << i):
                ans += A[i + 1]
            else:
                ans -= A[i + 1]
        if ans != 7: continue
        out = [str(A[0]), None, str(A[1]), None, str(A[2]), None, str(A[3]), "=7"]
        for i in range(3):
            if op & (1 << i):
                out[2 * i + 1] = "+"
            else:
                out[2 * i + 1] = "-"
        print("".join(out))
        return


if __name__ == "__main__":
    main()

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




s = list(input())
l = [int(s[0]), int(s[1]), int(s[2]), int(s[3])]

for i in range(2**3):
    opt = ['+', '+', '+']
    for j in range(3):
        if ((i >> j) & 1):
            opt[j] = '-'
    test = l[0]
    for k in range(3):
        if opt[k] == '+':
            test += l[k+1]
        else:
            test -= l[k+1]
    if test == 7 :
        break
printstr=str(l[0])
for i in range(3):
    printstr+=opt[i]+str(l[i+1])
print(printstr+'=7')

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


s = input()

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

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

ans = A
for x in range(2):
    for y in range(2):
        for z in range(2):
            if x == 0: ans += B; o = "+"
            else:ans -= B; o = "-"
            if y == 0:ans += C; oo = "+"
            else:ans -= C; oo = "-"
            if z == 0:ans += D; ooo = "+"
            else:ans -= D; ooo = "-"
            
            if ans == 7: print("".join(list(map(str,[A,o,B,oo,C,ooo,D,"=7"])))); exit()
            ans = A

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    nums = [int(i) for i in input()]
    
    for i in range(1<<3):
        s = nums[0]
        ans = str(nums[0])
        for j in range(3):
            if (i>>j) & 1:
                s += nums[j+1]
                ans += '+' + str(nums[j+1])
            else:
                s -= nums[j+1]
                ans += '-' + str(nums[j+1])
        if s == 7:
            print(ans+'=7')
            return
if __name__ == '__main__':
    main()

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

Solution (Python):
from itertools import product
a,b,c,d=map(int,input())
for op1,op2,op3 in product((1,-1),repeat=3):
    if a+op1*b+op2*c+op3*d==7:
        x='+'if op1==1else'-'
        y='+'if op2==1else'-'
        z='+'if op3==1else'-'
        print('{}{}{}{}{}{}{}=7'.format(a,x,b,y,c,z,d))
        exit()

Solution (Python):
num=open(0).read()
A=int(num[0])
B=int(num[1])
C=int(num[2])
D=int(num[3])
for i in range(2):
    for j in range(2):
        for k in range(2):
            b=B*(-1)**i
            c=C*(-1)**j
            d=D*(-1)**k
            ans=A+b+c+d
            if ans==7:
                sgn=[i,j,k]
                for l in range(3):
                    if sgn[l]%2==0:
                        sgn[l]='+'
                    else:
                        sgn[l]='-'
print(str(A)+sgn[0]+str(B)+sgn[1]+str(C)+sgn[2]+str(D)+'=7')

Solution (Python):
import sys
s = input()
n = len(s)
ans = 7
for bit in range(2**(n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
            f += s[i + 1]
        else:
            f += "-"
            f += s[i + 1]
    if eval(f)==7:
        print(f+"=7")
        sys.exit()