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):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter

def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)



b = input()                                  






a = []
for i in range(4):
    a.append(int(b[i]))
if a[0] + a[1] + a[2] + a[3] == 7: c = [b[0],'+',b[1],'+',b[2],'+',b[3],'=7']
if a[0] + a[1] + a[2] - a[3] == 7: c = [b[0],'+',b[1],'+',b[2],'-',b[3],'=7']
if a[0] + a[1] - a[2] + a[3] == 7: c = [b[0],'+',b[1],'-',b[2],'+',b[3],'=7']
if a[0] + a[1] - a[2] - a[3] == 7: c = [b[0],'+',b[1],'-',b[2],'-',b[3],'=7']
if a[0] - a[1] + a[2] + a[3] == 7: c = [b[0],'-',b[1],'+',b[2],'+',b[3],'=7']
if a[0] - a[1] + a[2] - a[3] == 7: c = [b[0],'-',b[1],'+',b[2],'-',b[3],'=7']
if a[0] - a[1] - a[2] + a[3] == 7: c = [b[0],'-',b[1],'-',b[2],'+',b[3],'=7']
if a[0] - a[1] - a[2] - a[3] == 7: c = [b[0],'-',b[1],'-',b[2],'-',b[3],'=7']
print(''.join(c))

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

for state in range(1 << (len(ticket)-1)):
    fomula = ticket[0] + ''.join(('+' if state >> i & 1 else '-') + x for i, x in enumerate(ticket[1:]))
    if eval(fomula) == 7:
        print(fomula + ''.join('=7'))
        exit()

Solution (Python):
s = input()

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

one = -1
flg = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			if a + b*one**i + c*one**j + d*one**k == 7:
				flg = True
				break
		if flg:
			break
	if flg:
		break
                
if i == 0 :
	i_flg = "+"
else:
	i_flg = "-"

if j == 0 :
	j_flg = "+"
else:
	j_flg = "-"

if k == 0 :
	k_flg = "+"
else:
	k_flg = "-"

print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')

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

for i in range(8):
    ch = S[0]
    for j in range(3):
        if int(i/(2**j)) % 2 == 0:
            ch += S[j+1]
        else:
            ch -= S[j+1]
    if ch == 7:
        print(S[0],end='')
        for j in range(3):
            if int(i/(2**j)) % 2 == 0:
                print('+',end='')
            else:
                print('-',end='')
            print(S[j+1],end='')
        print('=7')
        break

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = input()

N = [int(i) for i in N]

def dfs(l):
    if len(l) == 3:
        
        result = N[0]
        for idx, op in enumerate(l):
            if op:
                result += N[idx+1]
            else:
                result -= N[idx+1]
        if result == 7:
            s = str(N[0])
            for n in range(len(l)):
                if l[n]:
                    s += "+"
                else:
                    s += "-"
                s += str(N[n+1])
            s += "=7"
            print(s)
            exit()
        return
    dfs(l + [0])
    dfs(l + [1])
dfs([])

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

if a + b + c + d == 7:
  print(a, "+", b, "+", c, "+", d, "=", 7, sep='')
elif a + b + c - d == 7:
  print(a, "+", b, "+", c, "-", d, "=", 7, sep='')
elif a + b - c + d == 7:
  print(a, "+", b, "-", c, "+", d, "=", 7, sep='')
elif a + b - c - d == 7:
  print(a, "+", b, "-", c, "-", d, "=", 7, sep='')
elif a - b + c + d == 7:
  print(a, "-", b, "+", c, "+", d, "=", 7, sep='')
elif a - b + c - d == 7:
  print(a, "-", b, "+", c, "-", d, "=", 7, sep='')
elif a - b - c + d == 7:
  print(a, "-", b, "-", c, "+", d, "=", 7, sep='')
else:
  print(a, "-", b, "-", c, "-", d, "=", 7, sep='')

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

for op1,op2,op3 in [("+","+","+"),("+","+","-"),("+","-","+"),("+","-","-"),("-","+","+"),("-","+","-"),("-","-","+"),("-","-","-")]:
    if eval(A+op1+B+op2+C+op3+D) == 7:
        print(A+op1+B+op2+C+op3+D+"=7")
        break

Solution (Python):
def solve():
    S=list(input())
    for i in range(8):
        ans=int(S[0])
        for j in range(3):
            if (i & (1 << j)) != 0:
                ans+=int(S[j+1])
            else:
                ans-=int(S[j+1])
        if ans==7:
            ans=S[0]
            for j in range(3):
                if (i & (1 << j)) != 0:
                    ans+='+'
                else:
                    ans+='-'
                ans+=S[j+1]
            return ans+'=7'

print(solve())

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

Solution (Python):

S=input()

show=""
def dfs(op):
    if len(op)==3:
        count=int(S[0])
        for i in range(3):
            if op[i]=='+':
                count+=int(S[i+1])
            elif op[i]=='-':
                count-=int(S[i+1])
        if count==7:
            show=S[0]
            for i in range(3):
                show+=op[i]+S[i+1]
            show+="=7"
            return show
        else:
            return ""
    s1=dfs(op+'+')
    s2=dfs(op+'-')
    if len(s1)>len(s2):
        return s1
    else:
        return s2

print(dfs(""))

Solution (Python):
import itertools

a,b,c,d = input()
pm = ['+','-']
for pm1,pm2,pm3 in itertools.product(pm,repeat=3):
    ans = a+pm1+b+pm2+c+pm3+d
    if eval(ans) == 7:
        print(ans+'=7')
        break

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

for i in range(8):
    pq = str(S[0])
    ans = int(S[0])
    l = bin(i)[2:].zfill(3)
    for j in range(3):
        if l[j] == '1':
            ans += int(S[j+1])
            pq += '+'+str(S[j+1])
        else:
            ans -= int(S[j+1])
            pq += '-'+str(S[j+1])
    if ans == 7:
        pq += '=7'
        print(pq)
        exit()

Solution (Python):
a = [int(item) for item in input().rstrip()]

for i in range(2**3):
    val = a[0]
    for j in range(3):
        if i & 1<<j:
            val += a[j+1] 
        else:
            val -= a[j+1] 
    if val == 7:
        print(a[0], end="")
        if i & 1:
            print("+", end="")
        else:
            print("-", end="")
        print(a[1], end="")
        if i & 1<<1:
            print("+", end="")
        else:
            print("-", end="")
        print(a[2], end="")
        if i & 1<<2:
            print("+", end="")
        else:
            print("-", end="")
        print(a[3], end="")
        print("=7")
        exit()

print("Wrong input")

Solution (Python):


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

ans = ""

def dfs(i, num, s):
    global ans
    if i == len(abcd):
        if num == 7:
            s += "=7"
            ans = s
        return

    dfs(i + 1, num + abcd[i], s + "+" + str(abcd[i]))
    dfs(i + 1, num - abcd[i], s + "-" + str(abcd[i]))

    return

dfs(1,abcd[0],str(abcd[0]))

print(ans)

Solution (Python):
S = input()

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

Solution (Python):
a=input()
for op1 in ["+","-"]:
  for op2 in ["+","-"]:
    for op3 in ["+","-"]:
      if eval(a[0]+op1+a[1]+op2+a[2]+op3+a[3])==7:
        ans=a[0]+op1+a[1]+op2+a[2]+op3+a[3]+"=7"
print(ans)

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

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

Solution (Python):
s = list(str(input()))
flag = False
a1 = int(s[0])

for i in range(2):
    if i == 0:
        a2 = a1 + int(s[1])
        t1 = "+"
    else:
        a2 = a1 - int(s[1])
        t1 = "-"
    for j in range(2):
        if j == 0:
            a3 = a2 + int(s[2])
            t2 = "+"
        else:
            a3 = a2 - int(s[2])
            t2 = "-"
        for r in range(2):
            if r == 0:
                if a3 + int(s[3])!=7:
                    continue
                else:
                    print(s[0] + t1 + s[1] + t2 + s[2] + "+" + s[3] + "=7")
                    flag = True
                    break
            else:
                if a3 - int(s[3])!=7:
                    continue
                else:
                    print(s[0] + t1 + s[1] + t2 + s[2] + "-" + s[3] + "=7")
                    flag = True
                    break
        if flag:
            break
    if flag:
        break

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

p1 = "+"
p2 = "+"
p3 = "+"
flag = False

for op1 in [0,1]:
    for op2 in [0,1]:
        for op3 in [0,1]:
            if  A + (-1)**op1*B + (-1)**op2*C + (-1)**op3*D == 7:
                flag = True
                break
        if flag == True:
            break
    if flag == True:
        break

if op1 == 1:
    p1 = "-"
if op2 == 1:
    p2 = "-"
if op3 == 1:
    p3 = "-"

output = str(A)+p1+str(B)+p2+str(C)+p3+str(D)+"=7"

print(output)

Solution (Python):
s = input()

for i in range(1<<3):
  x = int(s[0])
  y = s[0]
  for j in range(3):
    if ((i>>j)&1) == 0:
      x += int(s[j+1])
      y += "+" + s[j+1]
    else:
      x -= int(s[j+1])
      y += "-" + s[j+1]
  if x == 7:
    print(y+"=7")
    break

Solution (Python):
str_t = input()
lis_t = [int(num) for num in str_t]
lis_op = ['','','']

def dfs(lis_op,cnt,s):
    if cnt == 3:
        return s == 7
    elif dfs(lis_op,cnt+1,s+lis_t[cnt+1]):
        lis_op[cnt] = '+'
        return True
    elif dfs(lis_op,cnt+1,s-lis_t[cnt+1]):
        lis_op[cnt] = '-'
        return True
    else:
        return False
    
if dfs(lis_op,0,lis_t[0]):
    print(str_t[0] + lis_op[0] + str_t[1] + lis_op[1] +str_t[2] + lis_op[2] + str_t[3] + "=7")

Solution (Python):
s = input()
for i in range((1<<3)):
    x = int(s[0])
    y = s[0]
    for j in range(3):
        if ((i>>j)&1) == 0:
            x += int(s[j+1])
            y += '+' + s[j+1]
        else:
            x -= int(s[j+1])
            y += '-' + s[j+1]
    if x == 7:
        print(y+"=7")
        break;

Solution (Python):
n = str(input())
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
ans = a
for bit in range(8):
    if bit & (1<<2):
    	ans += b
    	op1 = '+'
    else:
        ans -= b
        op1 = '-'
    if bit & (1<<1):
        ans += c
        op2 = '+'
    else:
        ans -= c
        op2 = '-'
    if bit & 1:
        ans += d
        op3 = '+'
    else:
        ans -= d
        op3 = '-'
    if ans == 7:
        print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + "=7")
        break
    ans = a

Solution (Python):
str = input()

n1 = int(str[0])
n2 = int(str[1])
n3 = int(str[2])
n4 = int(str[3])

if n1 + n2 + n3 + n4 == 7:
  print(str[0]+"+"+str[1]+"+"+str[2]+"+"+str[3]+"=7")
elif n1 - n2 + n3 + n4 == 7:
  print(str[0]+"-"+str[1]+"+"+str[2]+"+"+str[3]+"=7")
elif n1 + n2 - n3 + n4 == 7:
  print(str[0]+"+"+str[1]+"-"+str[2]+"+"+str[3]+"=7")
elif n1 + n2 + n3 - n4 == 7:
  print(str[0]+"+"+str[1]+"+"+str[2]+"-"+str[3]+"=7")
elif n1 - n2 - n3 + n4 == 7:
  print(str[0]+"-"+str[1]+"-"+str[2]+"+"+str[3]+"=7")
elif n1 - n2 + n3 - n4 == 7:
  print(str[0]+"-"+str[1]+"+"+str[2]+"-"+str[3]+"=7")
elif n1 + n2 - n3 - n4 == 7:
  print(str[0]+"+"+str[1]+"-"+str[2]+"-"+str[3]+"=7")
elif n1 - n2 - n3 - n4 == 7:
  print(str[0]+"-"+str[1]+"-"+str[2]+"-"+str[3]+"=7")

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


def getOp(i,a,b,c,d):
    if i == 0:
        return ["+","+","+",a+b+c+d]
    elif i == 1:
        return ["+","+","-",a+b+c-d]
    elif i == 2:
        return ["+","-","+",a+b-c+d]
    elif i == 3:
        return ["+","-","-",a+b-c-d]
    elif i == 4:
        return ["-","+","+",a-b+c+d]
    elif i == 5:
        return ["-","+","-",a-b+c-d]
    elif i == 6:
        return ["-","-","+",a-b-c+d]
    elif i == 7:
        return ["-","-","-",a-b-c-d]
    else:
        return


for n in range(7):
    ls = getOp(n,A,B,C,D)
    if ls[3] == 7:
        result = n;

l = getOp(result,A,B,C,D)
print(str(A)+l[0]+str(B)+l[1]+str(C)+l[2]+str(D)+"=7")

Solution (Python):
n = int(input())

a = n // 1000
b = (n // 100) % 10
c = (n // 10) % 10
d = n % 10

for o1 in range(2):
    for o2 in range(2):
        for o3 in range(2):
            e = a
            if o1 == 0:
                e += b
            else:
                e -= b
            if o2 == 0:
                e += c
            else:
                e -= c
            if o3 == 0:
                e += d
            else:
                e -= d
            if e == 7:
                if o1 == 0:
                    op1 = "+"
                else:
                    op1 = "-"
                if o2 == 0:
                    op2 = "+"
                else:
                    op2 = "-"
                if o3 == 0:
                    op3 = "+"
                else:
                    op3 = "-"
                print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + "=7")
                exit(0)

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

for op1 in ['+', '-']:
    if op1 == '+':
        s1 = n[0] + n[1]
    else:
        s1 = n[0] - n[1]

    for op2 in ['+', '-']:
        if op2 == '+':
            s2 = s1 + n[2]
        else:
            s2 = s1 - n[2]

        for op3 in ['+', '-']:
            if op3 == '+':
                s3 = s2 + n[3]
            else:
                s3 = s2 - n[3]
            
            if s3 == 7:
                print('{}{}{}{}{}{}{}=7'.format(n[0], op1, n[1], op2, n[2], op3, n[3]))
                break
            else:
                continue
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
n = input()
res = [n[0]]
for i in range(1,4):
    ans = []
    for x in res:
        ans.append(x+'+'+n[i])
        ans.append(x+'-'+n[i])
    res = ans
for j in res:
    if eval(j) == 7:
        print(j+'=7')
        break

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

a = input()
dfs(0, a[0], int(a[0]))

Solution (Python):
N = [int(x) for x in input()]
for i in range(1<<3):
    ans = N[0]
    li=[]
    for j in range(3):
        if((i>>j &1)==1):
            li+=['+']
            ans+=N[j+1]
        else:
            li+=['-']
            ans-=N[j+1]
    if(ans == 7):
        for j in range(3):
            print(str(N[j])+li[j],end='')
        print(str(N[3])+'=7')
        break

Solution (Python):
def calc(a, op, b):
	if op == "+":
		return a + b
	else:
		return a - b
s = input()
A, B, C, D = [int(c) for c in s]
ops = ["+", "-"]
ans = ""
for op1 in ops:
	for op2 in ops:
		for op3 in ops:
			if calc(calc(calc(A, op1, B), op2, C), op3, D) == 7:
				ans = str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7"

print(ans)

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

for i in range(1 << len(l) - 1):
    output = ['']
    for j in range(len(l) - 1):
        if ((i >> j) & 1) == 1:
            output.append('+')
        else:
            output.append('-')
    
    s = ''.join([b + a for a, b in zip(l, output)])
    
    
    if eval(s) == 7:
        print(s+'=7')
        break

Solution (Python):
n = list(input())
ans = []
op1 = ''
op2 = ''
op3 = ''
for i in range(8):
    lis = list(bin(i)[2:].zfill(3))
    temp = int(n[0])
    if lis[0] == '0':
        temp += int(n[1])
        op1 = '+'
    else:
        temp -= int(n[1])
        op1 = '-'
    if lis[1] == '0':
        temp += int(n[2])
        op2 = '+'
    else:
        temp -= int(n[2])
        op2 = '-'
    if lis[2] == '0':
        temp += int(n[3])
        op3 = '+'
    else:
        temp -= int(n[3])
        op3 = '-'
    if temp == 7:
        break
print('%s=7' % (n[0]+op1+n[1]+op2+n[2]+op3+n[3]))

Solution (Python):
B=input()
A=[]
for i in B:
    A.append(i)



for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            if(eval(A[0]+i+A[1]+j+A[2]+k+A[3])==7):
                print(A[0]+i+A[1]+j+A[2]+k+A[3]+"=7")
                exit()

Solution (Python):


abcd = list(input())
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]


n = 3
arr = [0] * n
for i in range(2 ** n):
    for j in range(n):
        if((1&i>>j) == 1):
            arr[j] = 1
        else:
            arr[j] = 0
    
    ia,ib,ic,id = int(a),int(b),int(c),int(d)
    if arr[0] == 0 and arr[1] == 0 and arr[2] == 0:
        if ia + ib + ic + id == 7:
            print(a + "+" + b + "+" + c + "+" + d + "=7")
            break
    if arr[0] == 1 and arr[1] == 0 and arr[2] == 0:
        if ia - ib + ic + id == 7:
            print(a + "-" + b + "+" + c + "+" + d + "=7")
            break
    if arr[0] == 0 and arr[1] == 1 and arr[2] == 0:
        if ia + ib - ic + id == 7:
            print(a + "+" + b + "-" + c + "+" + d + "=7")
            break
    if arr[0] == 1 and arr[1] == 1 and arr[2] == 0:
        if ia - ib - ic + id == 7:
            print(a + "-" + b + "-" + c + "+" + d + "=7")
            break
    if arr[0] == 0 and arr[1] == 0 and arr[2] == 1:
        if ia + ib + ic - id == 7:
            print(a + "+" + b + "+" + c + "-" + d + "=7")
            break
    if arr[0] == 1 and arr[1] == 0 and arr[2] == 1:
        if ia - ib + ic - id == 7:
            print(a + "-" + b + "+" + c + "-" + d + "=7")
            break
    if arr[0] == 0 and arr[1] == 1 and arr[2] == 1:
        if ia + ib - ic - id == 7:
            print(a + "+" + b + "-" + c + "-" + d + "=7")
            break
    if arr[0] == 1 and arr[1] == 1 and arr[2] == 1:
        if ia - ib - ic - id == 7:
            print(a + "-" + b + "-" + c + "-" + d + "=7")
            break

Solution (Python):
a=input()
alist=list(a)
s=[int(i) for i in alist]
sa=[str(i) for i in alist]
p='+'
m='-'
if s[0]+s[1]+s[2]+s[3]==7:
    print(sa[0]+p+sa[1]+p+sa[2]+p+sa[3]+'=7')
elif s[0]-s[1]+s[2]+s[3]==7:
    print(sa[0]+'-'+sa[1]+'+'+sa[2]+'+'+sa[3]+'=7')
elif s[0]+s[1]-s[2]+s[3]==7:
    print(sa[0]+'+'+sa[1]+'-'+sa[2]+'+'+sa[3]+'=7')
elif s[0]+s[1]+s[2]-s[3]==7:
    print(sa[0]+'+'+sa[1]+'+'+sa[2]+'-'+sa[3]+'=7')
elif s[0]-s[1]-s[2]+s[3]==7:
    print(sa[0]+'-'+sa[1]+'-'+sa[2]+'+'+sa[3]+'=7')
elif s[0]-s[1]+s[2]-s[3]==7:
    print(sa[0]+'-'+sa[1]+'+'+sa[2]+'-'+sa[3]+'=7')
elif s[0]+s[1]-s[2]-s[3]==7:
    print(sa[0]+'+'+sa[1]+'-'+sa[2]+'-'+sa[3]+'=7')
elif s[0]-s[1]-s[2]-s[3]==7:
    print(sa[0]+'-'+sa[1]+'-'+sa[2]+'-'+sa[3]+'=7')

Solution (Python):
n = input()

ops_list = ['+++', '++-', '+-+', '-++', '+--', '-+-', '--+', '---']

for ops in ops_list:
    expression = '{}{}{}{}{}{}{}'.format(n[0], ops[0], n[1], ops[1], n[2], ops[2], n[3])
    if eval(expression) == 7:
        print('{}=7'.format(expression))
        break

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

def calc(n1, op, n2):
    if op == '+':
        return n1 + n2
    else:
        return n1 - n2

ops = ['+', '-']

for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            if calc(calc(calc(N[0], op1, N[1]), op2, N[2]), op3, N[3]) == 7:
                break
        else:
            continue
        break
    else:
        continue
    break
print('{}{}{}{}{}{}{}=7'.format(N[0], op1, N[1], op2, N[2], op3, N[3]))

Solution (Python):
def DepthFirst_search(S,pre):
    global out
    
    
    if len(S) == 1 :
        if pre + int(S[0]) == 7:
            out = out + '+{}'.format(int(S[0])) + '=7'
            return True
        if pre - int(S[0]) == 7:
            out = out + '-{}'.format(int(S[0])) + '=7'
            return True
        return False

    pre += int(S[0])
    if DepthFirst_search(S[1:len(S)],pre):
        
        out = '+' + S[0] + out
        return True
    pre -= 2*int(S[0])
    if DepthFirst_search(S[1:len(S)],pre):
        
        out = '-' + S[0] + out
        return True
    return False
out = ''
pre = 0
S = input()
DepthFirst_search(S,pre)

print(out[1:])

Solution (Python):
import itertools
s = list(input())
s = list(map(int,s))
op = [['+','-'],['+','-'],['+','-']]
op_comb = list(itertools.product(*op))

for i in range(8):
  ans = s[0]
  tmp = list(op_comb[i])
  for j in range(3):
    if(tmp[j] == '+'):
      ans = ans + s[j+1]
    else:
      ans = ans - s[j+1]
  if(ans == 7):
    break
  
ans_str = str(s[0])+tmp[0]+str(s[1])+tmp[1]+str(s[2])+tmp[2]+str(s[3])
ans_str += '=7'
print(ans_str)

Solution (Python):
s = str(input())
ans = 0
for i in range(1 << (len(s)-1)):
    si = s[0]
    for j in range(len(s)-1):
        if i & (1 << j):
            si += "+"+s[j+1]
        else:
            si += "-"+s[j+1]
    if eval(si) == 7:
        break

print(si+"=7")

Solution (Python):
from itertools import product


def solve(string):
    s = [0] * 7
    for i, _s in enumerate(string):
        s[2 * i] = _s
    for op in product("+-", repeat=3):
        for i, o in enumerate(op):
            s[2 * i + 1] = o
        if eval("".join(s)) == 7:
            return "".join(s) + "=7"


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

Solution (Python):
def main():
    s=input()
    a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3])
    now0=a
    for op1 in [-1,1]:
        now1=now0+op1*b
        for op2 in [-1,1]:
            now2=now1+op2*c
            for op3 in [-1,1]:
                now3=now2+op3*d
                if now3==7:
                    return [a,b,c,d],[op1,op2,op3]
d,p=main()
ans=str(d[0])
for i in range(3):
    if p[i]==-1:ans+='-'
    elif p[i]==1:ans+='+'
    ans+=str(d[i+1])
ans+='=7'
print(ans)

Solution (Python):
s = input()
n = len(s)
o = ['+' for i in range(n - 1)]
os = ''
for i in range(2 ** (n-1)):
    for j in range(n):
        if ((i >> j) & 1):
            o[j] = '-'
    for k in range(len(o)):
        if k == 0:
            p = int(s[k])
            os += s[k]
            pass
        if o[k] == '+':
            p += int(s[k + 1])
            os += '+'
            os += s[k+1]
        elif o[k] == '-':
            os += '-'
            os += s[k+1]
            p -= int(s[k+1])
    if p == 7:
        print(os + '=7')
        break
    os = ''
    o = ['+' for i in range(n-1)]

Solution (Python):
import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("=7")
    exit(0)

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

def excute(b, c):
    if (c == 0):
        return  b
    else:
        return  b*(-1)

def combart(a):
    if (a == 0):
        return '+'
    else:
        return '-'
        
for i in range(8):
    flag = '{:03b}'.format(i)
    
    sum = int(s[0])

    for j in range(3):
        sum += excute(s[j+1], int(flag[j]))
        
    if (sum == 7):
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(s[0], combart(int(flag[0])), s[1], combart(int(flag[1])), s[2], combart(int(flag[2])), s[3]))
        sys.exit(0)

Solution (Python):
def main():
    s = [int(i) for i in input()]
    op = {'+':1, '-':-1}
    for a in op:
        for b in op:
            for c in op:
                if s[0] + op[a] * s[1] + op[b] * s[2] + op[c] * s[3] == 7:
                    return (str(s[0]) + a + str(s[1]) + b + str(s[2]) + c + str(s[3]) + '=7')

        
if __name__ == '__main__':
    print(main())

Solution (Python):
N = [int(i) for i in input()] 

flag = ["","",""]

for i in range(1 << len(N)-1):
	result = N[0]
	for j in range(len(N)-1):
		if ((i >> j) & 1) == 1:
			result += N[j+1]
			flag[j] = "+"
		else:
			result -= N[j+1]
			flag[j] = "-"

	if result == 7:
		break

print("%d%s%d%s%d%s%d=7" %(N[0],flag[0],N[1],flag[1],N[2],flag[2],N[3]))

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




N = len(S) 

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

Solution (Python):
from itertools import product

A,B,C,D = list(input())

for X in product(['+','-'], repeat=3):
  s=A
  for x, y in zip(X,[B,C,D]):
    s += x + y
  if eval(s)==7:
    print(s+'=7')
    exit()

Solution (Python):
S = input()
LIST = [int(_) for _ in S]
pra_fla = []
for _ in range(2**3):
    lis = ['-' for fl in range(3)]
    for x in range(3):
        if (_ >> x)&1:
            lis[x] = '+'
    pra_fla.append(lis)

ans_lis = []
for x in pra_fla:
    pre = []
    x.append('')
    for y in range(4):
        pre.append(LIST[y])
        pre.append(x[y])
    ans_lis.append(pre)
flag = 0 
for x in ans_lis:
    ans = 0
    ans_str = ''
    for y in x:
        
        ans_str += str(y) 
        if y == '+':
            flag = 1
        elif y == '-':
            flag = 2
        elif y == '':
            flag = 0
        else:
            if flag == 1 or flag == 0:
                ans += y
            elif flag == 2:
                ans -= y
            flag = 0
    if ans == 7:
        break
ans_str += '=7'
print(ans_str)

Solution (Python):
a = input()

for i in range(8):
   f = a[0]
   for j in range(3):
        f += "+-"[(i>>j)%2]
        f += a[j+1]
   if eval(f) == 7:
        print(f + "=7")
        exit()

Solution (Python):


def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

abcd = digit_list(input())

for i in range(8):
    num = abcd[0]
    formula = str(abcd[0])
    if i % 2:
        num += abcd[1]
        formula += "+"
        formula += str(abcd[1])
    else:
        num -= abcd[1]
        formula += "-"
        formula += str(abcd[1])
    if (i >> 1) % 2:
        num += abcd[2]
        formula += "+"
        formula += str(abcd[2])
    else:
        num -= abcd[2]
        formula += "-"
        formula += str(abcd[2])
    if (i >> 2) % 2:
        num += abcd[3]
        formula += "+"
        formula += str(abcd[3])
    else:
        num -= abcd[3]
        formula += "-"
        formula += str(abcd[3])
    if num == 7:
        formula += "=7"
        print(formula)
        break

Solution (Python):

import copy
import numpy as np
import random

nums = list(input())
nums = [int(i) for i in nums]

def make2digits(n):
    digits = []
    for i in range(3):
        if n % 2 == 1:
            digits.append(1)
        else:
            digits.append(0)
        n = n//2
    return digits

for i in range(8):
    count = nums[0]
    choices = make2digits(i)
    
    for j in range(len(choices)):
        if choices[j]==0:
            count -= nums[j+1]
        else:
            count += nums[j+1]
    
    if count == 7:
        ans_choice = choices
        break


plusminus = ["-","+"]
ans = ""
nums = [str(i) for i in nums]
for i in range(3):
    ans = ans + nums[i] + plusminus[ans_choice[i]]

ans = ans+nums[-1]+"=7"
print(ans)

Solution (Python):
L = list(map(int, input()))
X = [""] * 3
for i in range(8):
    a = L[0]
    for j in range(3):
        if i >> j & 1:
            a += L[j + 1]
        else:
            a -= L[j + 1]
    
    if a == 7:
        for k in range(3):
            if i >> k & 1:
                X[k] = "+"
            else:
                X[k] = "-"
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(L[0], X[0], L[1], X[1], L[2], X[2], L[3]))
        exit()

Solution (Python):
a,b,c,d = list(input())
a,b,c,d = int(a), int(b), int(c), int(d)
mark = {"+":1,"-":-1}
e = 0
for i, i_ in mark.items():
    for j, j_ in mark.items():
        for k, k_ in mark.items():
            if (e==0)&(a + i_ * b + c * j_ + d * k_ == 7):
                ans = str(a)+i+str(b)+j+str(c)+k+str(d)+"=7"
                print(ans)
                e = 1
                break

Solution (Python):
A, B, C, D = [c for c in input()]
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = A+op1+B+op2+C+op3+D
            if eval(s) == 7:
                print(s+"=7")
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
a,b,c,d = map(int,list(input()))
for i in range(2):
    if i==0:
        ans=a+b
    else:
        ans=a-b
    r1=ans
    for j in range(2):
        ans=r1
        if j==0:
            ans+=c
        else:
            ans-=c
        r2=ans
        for k in range(2):
            ans=r2
            if k==0:
                ans+=d
            else:
                ans-=d
            if ans==7:
                ret=[i,j,k]
                for i in range(len(ret)):
                    if ret[i]==0:
                        ret[i]='+'
                    else:
                        ret[i]='-'
                print('{}{}{}{}{}{}{}=7'.format(a,ret[0],b,ret[1],c,ret[2],d))
                exit()

Solution (Python):
import itertools

A, B, C, D = input()  
op = ('+', '-')
ans_str = ''
for op1, op2, op3 in itertools.product(op, repeat=3):  
    ans_str = A + op1 + B + op2 + C + op3 + D
    if eval(ans_str) == 7:
        ans_str += '=7'
        break
print(ans_str)