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):
z=input()
sa,sb,sc,sd=z[0],z[1],z[2],z[3]
a,b,c,d=int(z[0]),int(z[1]),int(z[2]),int(z[3])
if a+b+c+d==7:
    print(sa+'+'+sb+'+'+sc+'+'+sd+'=7')
elif a+b+c-d==7:
    print(sa+'+'+sb+'+'+sc+'-'+sd+'=7')
elif a+b-c+d==7:
    print(sa+'+'+sb+'-'+sc+'+'+sd+'=7')
elif a+b-c-d==7:
    print(sa+'+'+sb+'-'+sc+'-'+sd+'=7')
elif a-b+c+d==7:
    print(sa+'-'+sb+'+'+sc+'+'+sd+'=7')
elif a-b+c-d==7:
    print(sa+'-'+sb+'+'+sc+'-'+sd+'=7')
elif a-b-c+d==7:
    print(sa+'-'+sb+'-'+sc+'+'+sd+'=7')
else:
    print(sa+'-'+sb+'-'+sc+'-'+sd+'=7')

Solution (Python):
S = input()
sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3])
def minus(a, sumS):
    sS = sumS
    ba = bin(a)
    for ia,aa in enumerate(ba[::-1]):
        if aa == 'b':
            break
        elif aa == '1':
            sS -=  2 * int(S[ia+1:ia+2])
    if sS == 7:
        T = ['+', '+', '+', '=7']
        for ia,aa in enumerate(ba[::-1]):
            if aa == '1':
                T[ia] = '-'

        result = ''
        for i in range(len(S)):
            result += S[i] + T[i]
        return result
    else:

        return minus(a+1,sumS)
print(minus(0,sumS))

Solution (Python):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
e = [b,c,d]
l = [[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
for i in range(8):
  ll = l[i]
  now = a
  for j in range(3):
    if ll[j] == 0:
      now += e[j]
    else:
      now -= e[j]
  if now == 7:
    f = []
    for j in range(3):
      if ll[j] == 0:
        f.append('+')
      else:
        f.append('-')
    print( str(a) + f[0] + str(b) + f[1] + str(c) + f[2] + str(d) + '=7' )
    break

Solution (Python):
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=a+op1+b+op2+c+op3+d
      if eval(ans)==7:
        print('{}=7'.format(ans))
        exit()
      else:
        pass

Solution (Python):
import sys
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=a+op1+b+op2+c+op3+d
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

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






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

    temp = Number[0] + op[0] + Number[1] + op[1] + Number[2] + op[2] + Number[3]
    if eval(temp) == 7:
        print(temp + "=7")
        break

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

op1 = '-'
op2 = '-'
op3 = '-'
if A + B + C + D == 7:
  op1 = '+'
  op2 = '+'
  op3 = '+'
elif A + B + C - D == 7:
  op1 = '+'
  op2 = '+'
elif A + B - C + D == 7:
  op1 = '+'
  op3 = '+'
elif A + B - C - D == 7:
  op1 = '+'
elif A - B + C + D == 7:
  op2 = '+'
  op3 = '+'
elif A - B + C - D == 7:
  op2 = '+'
elif A - B - C + D == 7:
  op3 = '+'

print('{}{}{}{}{}{}{}=7'.format(A, op1, B, op2, C, op3, D))

Solution (Python):
s = input()
N = len(s)
sum = 0
for i in range(2**(N-1)):
	sum = int(s[0])
	for n in range(N-1):
		if (i >> n) & 1:
			sum += int(s[n+1])
		else:
			sum -= int(s[n+1])
	if sum == 7:
		print(s[0],end = "")
		for n in range(N-1):
			if (i >> n) & 1:
				print("+",end = "")
			else:
				print("-",end = "")
			print(s[n+1],end = "")
		print("=7")
		exit()

Solution (Python):
s_in = input()

def rec(s,n):
  if n==0:
    if eval(s)==7:
      return s+'=7'
    else:
      return ''
  else:    
    ret_p = rec(s[:n]+'+'+s[n:] ,n-1)
    ret_m = rec(s[:n]+'-'+s[n:] ,n-1)
  if ret_p:
    return ret_p
  if ret_m:
    return ret_m
  else:
    return ''

print(rec(s_in,len(s_in)-1))

Solution (Python):
S =list(input())
A,B,C,D = map(int,S)
a = str(A)
b = str(B)
c = str(C)
d = str(D)

for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0 and j ==0 and k ==0:
                if A + B + C + D ==7:
                    print(a+"+"+b+"+"+c+"+"+d+"=7")
                    exit()
            elif i == 0 and j ==0 and k ==1:
                if A + B + C - D ==7:
                    print(a + "+" + b + "+" + c + "-" + d + "=7")
                    exit()
            elif i == 0 and j ==1 and k ==0:
                if A + B - C + D ==7:
                    print(a + "+" + b + "-" + c + "+" + d + "=7")
                    exit()
            elif i == 0 and j  ==1 and k ==1:
                if A+B-C-D ==7:
                    print(a + "+" + b + "-" + c + "-" + d + "=7")
                    exit()
            elif i == 1 and j == 0 and k == 0:
                if A-B+C+D ==7:
                    print(a + "-" + b + "+" + c + "+" + d + "=7")
                    exit()
            elif i == 1 and j == 0 and k == 1:
                if A-B+C-D ==7:
                    print(a + "-" + b + "+" + c + "-" + d + "=7")
                    exit()
            elif i == 1 and j == 1 and k ==0:
                if A-B-C+D ==7:
                    print(a + "-" + b + "-" + c + "+" + d + "=7")
                    exit()
            elif i == 1 and j == 1 and k ==1:
                if A-B-C-D==7:
                    print(a + "-" + b + "-" + c + "-" + d + "=7")
                    exit()

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


def main():
    abcd = [int(x) for x in list(input().strip())]

    for i in range(8):
        s = abcd[0]
        bs = [int(x) for x in list('{0:03b}'.format(i))]

        for j, b in enumerate(bs, 1):
            if b == 0:
                s -= abcd[j]
            else:
                s += abcd[j]

        if s == 7:
            ans = str(abcd[0])
            for j, b in enumerate(bs, 1):
                ans += '+' if b == 1 else '-'
                ans += str(abcd[j])
            ans += '=7'
            print(ans)
            return


if __name__ == "__main__":
    main()

Solution (Python):
S = input()

for i in range(2 ** (len(S) - 1)):
    op = ['-' for _ in range(len(S)-1)]
    for j in range(len(S)-1):
        if ((i >> j) & 1):
            op[j] = '+'
    
    formula = [f for i in [[n,op_] for n, op_ in zip(S, op + [''])] for f in i] 
    if eval(''.join(formula)) == 7:
        print(''.join(formula)+'=7')
        break

Solution (Python):
s = input()
lst = []
for c in s:
    lst.append(int(c))

for i in range(2**3):
    x = lst[0]
    s = format(i,'b').rjust(3,'0')
    
    for j in range(3):
        if s[j] == '1':
            x += lst[j+1]
        else:
            x -= lst[j+1]
    
    if x==7:
        ss = s
        break

ans = ''
for i in range(3):
    ans += str(lst[i])
    if ss[i] == '1':
        ans += '+'
    else:
        ans += '-'
else:
    ans += str(lst[3]) + '=7'
print(ans)

Solution (Python):
import sys
N=list(input())
A=N[0]
B=N[1]
C=N[2]
D=N[3]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=A+op1+B+op2+C+op3+D
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

Solution (Python):
a, b, c, d = list(input())
op = '+-'
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a + op1 + b + op2 + c + op3 + d
            if eval(ans) == 7:
                print('{}=7'.format(ans))
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
a, b, c, d = list(input())
op = '+-'
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a + op1 + b + op2 + c + op3 + d
            
            if eval(ans) == 7:
                print('{}=7'.format(ans))
                break
        else:
            continue
        break
    else:
        continue
    break

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

a,b,c,d = map(int,list(input())[:4])


def add(x, y):
    return x+y

def sub(x, y):
    return x-y

def printans(a,b,c,d,op):
    ansstr = str(a)
    ansstr += '+' if op[0] == 0 else '-'
    ansstr += str(b)
    ansstr += '+' if op[1] == 0 else '-'
    ansstr += str(c)
    ansstr += '+' if op[2] == 0 else '-'
    ansstr += str(d)
    ansstr += '=7'

    print(ansstr)

ops = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            ops.append((i, j, k))


for op in ops:
    ans = a
    for i,x in enumerate(op):
        if x == 0:
            if i == 0:
                ans = add(ans, b)
            if i == 1:
                ans = add(ans, c)
            if i == 2:
                ans = add(ans, d)
        else:
            if i == 0:
                ans = sub(ans, b)
            if i == 1:
                ans = sub(ans, c)
            if i == 2:
                ans = sub(ans, d)
    

    if ans == 7:
        printans(a,b,c,d,op)
        break

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


for i in range(2**3):
    sum = int(a)
    for j in range(3):
        if (i >> j) & 1:
            sum += int(abcd[3-j])
        else:
            sum -= int(abcd[3-j])

    if sum == 7:
        formula = str(format(i, '03b')).translate(str.maketrans('10', '+-'))
        print(a + formula[0] + b + formula[1] + c + formula[2] + d + '=7')
        break

Solution (Python):
s = list(input())
n = len(s)
for i in range(2 ** (n - 1)):
    ans = int(s[0])
    for j in reversed(range(n - 1)):
        if (i >> j) & 1:
            ans += int(s[j + 1])
        else:
            ans -= int(s[j + 1])
    if ans == 7:
        for j in reversed(range(n - 1)):
            if (i >> j) & 1:
                s.insert(j + 1, '+')
            else:
                s.insert(j + 1, '-')
        print(''.join(s) + '=7')
        exit()

Solution (Python):


def mitsukeru(numlist):
	for i in range(2**3):
		listsum=numlist[0]
		outputstring='{}'.format(numlist[0])
		for j in range(3):
			if ((i >> j) & 1):
				listsum +=numlist[j+1]
				outputstring += '+{}'.format(numlist[j+1])
			else:
				listsum -=numlist[j+1]
				outputstring += '-{}'.format(numlist[j+1])
		if listsum == 7:
			return outputstring + '=7'
	return listsum

listnum= [int(x) for x in list(input())]
print(mitsukeru(listnum))

Solution (Python):
def solve():
    cs = [c for c in input()]
    for i in range(2 ** 3):
        symbols = ["+" if b == "0" else "-" for b in list('{:03b}'.format(i))] + [""]
        formula = "".join([x[0] + x[1] for x in zip(cs, symbols)])
        result = eval(formula)
        if result == 7:
            return formula + "=7"


if __name__ == "__main__":
    print(solve())

Solution (Python):
def solve():
    a, b, c, d = [c for c in input()]
    conversion = {"0": "+", "1": "-"}
    for i in range(2 ** 3):
        b3, b2, b1 = list('{:03b}'.format(i))
        formula = str(a) + conversion[b3] + str(b) + conversion[b2] + str(c) + conversion[b1] + str(d)
        result = eval(formula)
        if result == 7:
            return formula + "=7"


if __name__ == "__main__":
    print(solve())

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

Solution (Python):

abcd = input()
num = [int(i) for i in abcd]
anslist = []
def solve(i,a,seven,ans):
    if i == 3:
        if seven == 7:
            return ans+'=7'
            
            
        else:
            return False

    if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
        return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
    
    if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
        return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))

print(solve(0,num,num[0],str(num[0])))

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

for i in range(1 << operation_cnt):
    operation = ["-"] * operation_cnt
    for j in range(operation_cnt):
        if ((i >> j) & 1):
            operation[j] = "+"

    formula = ""
    for num,operator in zip(N, operation + [""]):
        formula += (num + operator)
    if eval(formula) == 7:
        print(formula + "=7")
        exit()

Solution (Python):
op = [['+', '+', '+'], ['+', '+', '-'], ['+', '-', '+'], ['-', '+', '+'], ['+', '-', '-'], ['-', '+', '-'],
      ['-', '-', '+'], ['+', '-', '-']]

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

for i in range(8):
    s = a[0]
    for j in range(3):
        if op[i][j] == '+':
            s += a[j + 1]
        else:
            s -= a[j + 1]
    if s == 7:
        for k in range(3):
            print(a[k], end='')
            print(op[i][k], end='')
        print(str(a[-1])+'=7')
        exit()

Solution (Python):
N=input()
L=[]

for c in N:
    L.append(int(c))

bb=16
b=bin(bb)
for i in range(16):
    b=bin(bb)
    B=str(b)
    n=L[0]
    for p in range(1,4):
        n+=2*(int(B[-1*p])*L[p])
        n-=L[p]
    if n==7:
        break
    bb+=1
    


def plmi(n):
    if n=="1":
        return "+"
    else:
        return "-"

ans=""

ans+=N[0]
ans+=plmi(B[-1])
ans+=N[1]
ans+=plmi(B[-2])
ans+=N[2]
ans+=plmi(B[-3])
ans+=N[3]
ans+="=7"

print(ans)

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

Solution (Python):
s = input()
op = ["+","-"]
for i in range(2**(len(s)-1)):
    t = s[0]
    for j in range(len(s)-1):
        t += op[(i>>j)&1] + s[j+1]
    if eval(t) == 7:
        ans = t+"=7"
print(ans)

Solution (Python):
S = input()
p = ["+", "-"]

for i in range(2**3):
  t = S[0]
  for j in range(3):
    t += p[i>>j&1] + S[j+1]
  judge = eval(t)
  if judge == 7:
    print(t + "=7")
    break

Solution (Python):
S=input()
n=len(S)-1
for i in range(1<<n):
    op=["-"]*n
    for j in range(n):
        if i&(1<<j):
            op[j]="+"
    f="".join([S[i//2] if i%2==0 else op[i//2] for i in range(2*(n+1)-1)])
    if eval(f)==7:
        print("%s=7"%f)
        quit()

Solution (Python):
def solve():
    s_abcd = read()
    result = think(s_abcd)
    write(result)


def read():
    return read_line(n=4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s_abcd):
    list_int_abcd = list(map(lambda x: int(x), list(s_abcd)))
    max_patterns = 2 ** 3
    expected_answer = 7

    for _ in range(max_patterns):
        formula_string = generate_formula_string_with(list_int_abcd, _)
        if eval(formula_string) == expected_answer:
            return format_formula_string(formula_string, expected_answer)
    raise RuntimeError()


def generate_formula_string_with(list_int_abcd, bit):
    shift = 3
    operator = ['+', '-']
    formula_string = ''
    for i, elem in enumerate(list_int_abcd):
        formula_string += str(elem)
        if i == len(list_int_abcd) - 1:
            continue
        if bit >> (shift - i - 1) & 1:
            formula_string += operator[0]
        else:
            formula_string += operator[1]
    return formula_string


def format_formula_string(formula_string, expected_answer):
    return '{0:s}={1:s}'.format(formula_string, str(expected_answer))


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Solution (Python):
S = input()
length = len(S) - 1
S = list(S)
for i in range(2**length):
	sum=int(S[0])
	MP = []
	if i & 2**0:
		sum += int(S[1])
		MP.append("+")
	else:
		sum -= int(S[1])
		MP.append("-")
	if i & 2**1:
		sum += int(S[2])
		MP.append("+")
	else:
		sum -= int(S[2])
		MP.append("-")
	if i & 2**2:
		sum += int(S[3])
		MP.append("+")
	else:
		sum -= int(S[3])
		MP.append("-")
	if sum == 7:
		print("{0}{1}{2}{3}{4}{5}{6}=7".format(S[0], MP[0], S[1], MP[1], S[2], MP[2], S[3]))
		break

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

Solution (Python):


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    S, = read_h(typ=str)
    ints = [int(i) for i in S]

    for i in range(2**3):
        ops = ['+'] * 3
        for j in range(3):
            if ((i >> j) & 1):
                ops[j] = '-'

        
        

        s = ints[0]
        for op, i in zip(ops, ints[1:]):
            if op == '+':
                s += i
            else:
                s -= i

        if s == 7:
            ans = ''.join([str(i) + op for i, op in zip(ints, ops + [''])] + ['=7'])
            print(ans)
            return


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
li = [i for i in s]
global ans
def cal(left, count, remaining):
    global ans
    if len(remaining) > 0:
        cal(left + "+" + remaining[0], count + int(remaining[0]), remaining[1:])
        cal(left + "-" + remaining[0], count - int(remaining[0]), remaining[1:])
    elif count == 7:
        ans = left

cal(li[0], int(li[0]), li[1:])
print(ans+"=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):
num = input()
n = len(num) - 1

for i in range(2 ** n):
    calc = ["-"] * n
    for j in range(n):
        if ((i >> j) & 1):
            calc[- 1 - j] = "+"
    formula = ""
    for number, c in zip(num, calc):
        formula += number+c
    formula += num[-1]
    if eval(formula) == 7:
        formula += "=7"
        break

print(formula)

Solution (Python):
ABCD = input()

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

Solution (Python):

import sys

abcd = input()

n = len(abcd)-1
xx = abcd
for x in range(2**n):
    j = 0
    abcd = list(abcd)
    for i in range(n):
        if (x>>i)&1:
            abcd.insert(i+j+1, "+")
            j += 1

        else:
            abcd.insert(i+j+1, "-")
            j += 1

    abcd = "".join(abcd)
    sum = eval(abcd)
    if sum==7:
        print(abcd+"=7")
        sys.exit()

    abcd = xx

Solution (Python):
S=input()
for i in range(8):
    s=S[:1]
    for j in range(3):
        s+="+-"[i>>j&1]+S[j+1]
    if eval(s)==7:
        print(s+"=7")
        break

Solution (Python):
import operator

n = input()
operator_list = [operator.add, operator.sub]
operator_list2 = ["+", "-"]
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            if operator_list[i](operator_list[j](operator_list[k](int(n[0]), int(n[1])), int(n[2])), int(n[3])) == 7:
                flag = True
                break
        if flag == True:
            break
    if flag == True:
        break
print(n[0] + operator_list2[k] + n[1] + operator_list2[j] + n[2] + operator_list2[i] + n[3] + "=7")

Solution (Python):
def s(total, que, p_m, ans_str, in_list):
    if que == 0:
        total += in_list[que]
        ans_str += str(in_list[que])
    else:
        total += in_list[que] if p_m else -in_list[que]
        ans_str += ("+" + str(in_list[que])) if p_m else ("-" + str(in_list[que]))
    if que == 3:
        if total == 7:
            print(ans_str + "=7")
            exit()
    else:
        s(total, que + 1, True, ans_str, in_list)
        s(total, que + 1, False, ans_str, in_list)


a = list(map(int, list(input())))
print(s(0, 0, True, "", a))

Solution (Python):
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break

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

op_list = []

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

  op_list.append(op)

f_list = []

for op in op_list:
  f = s[0]
  for i in range(n):
    f += op[i]
    f += s[i+1]
  f_list.append(f)

for f in f_list:
  if eval(f) == 7:
    print(f+"=7")
    exit()

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

opl = []

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

fl = []

for i in opl:
  f = s[0]
  for j in range(n):
    f += i[j]
    f += s[j+1]
  fl.append(f)

for f in fl:
  if eval(f) == 7:
    print(f+"=7")
    exit()

Solution (Python):
N = input()
A, B, C, D = int(N[0]), int(N[1]), int(N[2]), int(N[3])
opes = ['-', '+']
for op1 in opes:
  for op2 in opes:
    for op3 in opes:
      result = 0
      if op1 == '-':
        result += A-B
      else:
        result += A+B
      if op2 == '-':
        result -= C
      else:
        result += C
      if op3 == '-':
        result -= D
      else:
        result += D
      if result == 7:
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
        exit()

Solution (Python):

S = input()

N = []; M=[];
for i in range(4):
    N.append(int(S[i]))
    N.append(-1 * int(S[i]))
    M.append("+")
    M.append("-")
    
def solve(M,N):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                total = N[0]+N[2+i]+N[4+j]+N[6+k]
                if (total == 7):
                    ans = str(N[0])+M[2+i]+str(N[2])+M[4+j]+str(N[4])+M[6+k]+str(N[6])
                    return ans+"=7"

print(solve(M,N))

Solution (Python):
n=input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])
for i in [b,-b]:
  for j in [c,-c]:
    for k in [d,-d]:
      if a+i+j+k==7:
        ii='+'
        jj='+'
        kk='+'
        if i==-b:
          ii='-'
        if j==-c:
          jj='-'
        if k==-d:
          kk='-'
        print(str(a)+ii+str(b)+jj+str(c)+kk+str(d)+'=7')
        exit()

Solution (Python):
import sys

n = [int(i) for i in list(input())]
ops = ['+', '-']
for a in ops:
    for b in ops:
        for c in ops:
            e = '{}{}{}{}{}{}{}'.format(n[0], a, n[1], b, n[2], c, n[3])
            if eval(e) == 7:
                print('{}=7'.format(e))
                sys.exit(0)

Solution (Python):
"Train Ticket"




numbers = list(input())



for mask in range(1 << (len(numbers)-1)):
    fomula = ""
    for i in range(len(numbers)):
        if (mask >> i) & 1:  
            fomula += numbers[i] + "+"
        else:
            fomula += numbers[i] + "-"

    

    if eval(fomula[:-1]) == 7:
        print(fomula[:-1]+"="+"7")
        break

Solution (Python):
N = list(input())
op = "+-"
for i in op:
    for j in op:
        for k in op:
            tmp = N[0]+i+N[1]+j+N[2]+k+N[3]
            if eval(tmp) == 7:
                print(tmp+"=7")
                exit(0)

Solution (Python):
import sys
N = list(map(int, input()))
op = ['+','-']
for i in op:
    tmp = 0 
    ans = []
    for j in op:
        for k in op:
            if i == '+':
                tmp = N[0] + N[1]
                ans.append('+')
            else:
                tmp = N[0] - N[1]
                ans.append('-')

            if j == '+':
                tmp += N[2]
                ans.append('+')
            else:
                tmp -= N[2]    
                ans.append('-')

            if k == '+':
                tmp += N[3]
                ans.append('+')
            else:
                tmp -= N[3]
                ans.append('-')

            if tmp == 7:
                print(str(N[0])+ans[0]+str(N[1])+ans[1]+str(N[2])+ans[2]+str(N[3])+"=7")
                sys.exit()
            else:
                tmp = 0
                ans = []

Solution (Python):
def plus_minus_seq(n):
    if n == 0:
        return ['']
    else:
        seqs = plus_minus_seq(n-1)
        posi = ['+' + seq for seq in seqs]
        nega = ['-' + seq for seq in seqs]
    return posi + nega

A, B, C, D = input()

for op1, op2, op3 in plus_minus_seq(3):
    seq = A+op1+B+op2+C+op3+D
    if eval(seq) == 7:
        print(seq + '=7')
        break

Solution (Python):
import sys

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

def calc(index, result, operation):
    
    if index == 4 and result == 7:
        print(operation + "=7")
        sys.exit()
    elif (index == 4):
        return
        
    calc(index + 1, result + A[index], operation + "+" + str(A[index]))
    calc(index + 1, result - A[index], operation + "-" + str(A[index]))
    
calc(1,A[0],str(A[0]))

Solution (Python):



def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval('{}{}{}{}{}{}{}'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                )) == 7:
                    return '{}{}{}{}{}{}{}=7'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                    )


if __name__ == '__main__':
    S = input()
    print(solve(S))

Solution (Python):
S = [int(a) for a in list(input())]

num = []
def make(B):
    if len(B) == 3:
        num.append(B)
        return
    B1 = B[:]
    B2 = B[:]
    B1.append(1)
    B2.append(-1)
    make(B1)
    make(B2)

make([])

for A in num:
    k = S[0] + S[1]*A[0] + S[2]*A[1] + S[3]*A[2]
    if k == 7:
        break

ans = []
for a in A:
    if a == 1:
        ans.append('+')
    else:
        ans.append('-')

print(str(S[0])+ans[0]+str(S[1])+ans[1]+str(S[2])+ans[2]+str(S[3])+'=7')

Solution (Python):
import sys
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b-c-d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()

Solution (Python):
A, B, C, D = list(input())
a = ['+', '-']

for op1 in a:
  fml_1 = ''
  fml_1 += (op1 + B)
  for op2 in a:
    fml_2 = fml_1
    fml_2 += (op2 + C)
    for op3 in a:
      fml_3 = fml_2
      fml_3 += (op3 + D)
      if eval(fml_3) == 7 - int(A):
        print(A + fml_3 + '=7')
        exit()

Solution (Python):
a,b,c,d=list(input())
for i in range(8):
  op=list(str(bin(i)[2:].zfill(3)).replace('0','-').replace('1','+'))
  siki=a+op[0]+b+op[1]+c+op[2]+d
  ans=eval(siki)
  if ans == 7:
    print(siki+'=7')
    break

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = S()
    for i in range(2):
        if s[i] == s[i + 1] == s[i + 2]:
            print("Yes")
            return
    print("No")
    return


def B():
    return


def C():
    abcd = list(map(int, S()))
    op = itertools.product(range(2), repeat=3)
    for opx in op:
        ans = abcd[0]
        for num, opi in enumerate(opx):
            if opi:
                ans += abcd[num + 1]
            else:
                ans -= abcd[num + 1]
        if ans == 7:
            print(abcd[0],end="")
            for num, opi in enumerate(opx):
                print(["-", "+"][opi] + str(abcd[num + 1]), end="")
            print("=7")
            return
    return


def D():
    return


if __name__ == '__main__':
    C()

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

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

print(ans)

Solution (Python):
def op(x):
    return '+' if x == 1 else '-'
a, b, c, d = map(int, input())

for i in [1, -1]:
    for j in [1, -1]:
        for k in [1, -1]:
            if a + i * b + j * c + k * d == 7:
                print(str(a) + op(i) + str(b) + op(j) + str(c) + op(k) + str(d) + '=7')
                exit()

Solution (Python):



n = int(input())

tmp=[]
tmp.append(n//1000)
n=n%1000
tmp.append(n//100)
n=n%100
tmp.append(n//10)
n=n%10
tmp.append(n)

for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			sum= tmp[0]+i*tmp[1]+j*tmp[2]+k*tmp[3]
			if(sum == 7):
				break

		else:
			continue
		break
	else:
		continue
	break

res=""
res+=str(tmp[0])
if(i==-1):res+="-"
else:res+="+"
res+=str(tmp[1])
if(j==-1):res+="-"
else:res+="+"
res+=str(tmp[2])
if(k==-1):res+="-"
else:res+="+"
res+=str(tmp[3])
res+="=7"


print(res)