Problem:
 Score : 300 points    Problem Statement Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A , B , C and D in this order, each between 0 and 9 (inclusive).  In the formula A  op1  B  op2  C  op3  D  =  7 , replace each of the symbols op1 , op2 and op3 with + or - so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.      Constraints  0≤A,B,C,D≤9  All input values are integers.  It is guaranteed that there is a solution.         Input Input is given from Standard Input in the following format:  ABCD       Output Print the formula you made, including the part =7 .  Use the signs + and - .  Do not print a space between a digit and a sign.        Sample Input 1 1222      Sample Output 1 1+2+2+2=7  This is the only valid solution.       Sample Input 2 0290      Sample Output 2 0-2+9+0=7  0 - 2 + 9 - 0 = 7 is also a valid solution.       Sample Input 3 3242      Sample Output 3 3+2+4-2=7

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

for i in range(2**3):
    W = ["+"]*3
    for j in range(3):
        if (i >> j) & 1:
            W[j] = "-"
    formula = ""
    for k,l in zip(X,W+[""]):
        formula += k+l
    if eval(formula) == 7:
        print(formula+"=7")
        break

Solution (Python):
ticket = [int(i) for i in input()]
sum_list = [[] for i in range(len(ticket))]
sum_list[0] = [ticket[0]]
sign_list = [[] for i in range(len(ticket))]
sign_list[0] = [""]

for i in range(len(ticket)-1):
    for j in range(len(sum_list[i])):
        sum_list[i+1].append(sum_list[i][j] + ticket[i+1])
        sign_list[i+1].append(sign_list[i][j] + "+")
        sum_list[i+1].append(sum_list[i][j] - ticket[i+1])
        sign_list[i+1].append(sign_list[i][j] + "-")

for i in range(2**len(ticket)):
    if sum_list[len(ticket)-1][i] == 7:
        sign = sign_list[len(ticket)-1][i]
        break

for i in range(len(ticket)-1):
    print(str(ticket[i]) + sign[i], end="")
print(str(ticket[-1]) + "=7")

Solution (Python):


def main():
	
	A, B, C, D = map(int, input())

	
	for op in range(0x7):
		a = A
		if ((op & 0x1) == 0):
			a += B
		else:
			a -= B
		if ((op & 0x2) == 0):
			a += C
		else:
			a -= C
		if ((op & 0x4) == 0):
			a += D
		else:
			a -= D
		if a == 7:
			print(
				'%d%s%d%s%d%s%d=7' % (
					A,
					'+' if ((op & 0x1) == 0) else '-',
					B,
					'+' if ((op & 0x2) == 0) else '-',
					C,
					'+' if ((op & 0x4) == 0) else '-',
					D
				)
			)
			break


if __name__ == '__main__':
	main()

Solution (Python):
ABCD = input()

for i in range(2 ** 3):
    s = ABCD[0]
    for j in range(3):
        s += ['-', '+'][(i >> j) & 1] + ABCD[j+1]
    x = eval(s)
    if x == 7:
        print(s+'=7')
        break
    continue

Solution (Python):
import sys
tmp = input()
a = int(tmp[0])
b = int(tmp[1])
c = int(tmp[2])
d = int(tmp[3])
def tonum(a, n):
    if (a == 0):
        return n
    else:
        return - 1 * n
def operand(n):
    if (n == 0):
        return '+'
    else:
        return '-'

def format(a, b, c, d, ab, bc, cd):
    string = str(a) + operand(ab) + str(b) + operand(bc) + str(c) + operand(cd) + str(d)+'=7'
    return string
tmp=0
for i in range(2):
    for j in range(2):
        for k in range(2):
                tmp = a+tonum(i, b)+tonum(j, c)+tonum(k,d)
                if (tmp == 7):
                    print(format(a, b, c, d, i, j, k))
                    sys.exit()

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

A = X[0]
B = X[1]
C = X[2]
D = X[3]

if A+B+C+D==7:
    print("{}+{}+{}+{}=7".format(A,B,C,D))
elif A+B+C-D==7:
    print("{}+{}+{}-{}=7".format(A,B,C,D))
elif A+B-C+D==7:
    print("{}+{}-{}+{}=7".format(A,B,C,D))
elif A+B-C-D==7:
    print("{}+{}-{}-{}=7".format(A,B,C,D))
elif A-B+C+D==7:
    print("{}-{}+{}+{}=7".format(A,B,C,D))
elif A-B+C-D==7:
    print("{}-{}+{}-{}=7".format(A,B,C,D))
elif A-B-C+D==7:
    print("{}-{}-{}+{}=7".format(A,B,C,D))
elif A-B-C-D==7:
    print("{}-{}-{}-{}=7".format(A,B,C,D))

Solution (Python):
a, b, c, d=map(int, input())
p, m='+', '-'
def f(x):
  s=a
  out=str(a)
  if x&1:
    s+=b
    out+=p
  else:
    s-=b
    out+=m
  out+=str(b)
  if (x>>1)&1:
    s+=c
    out+=p
  else:
    s-=c
    out+=m
  out+=str(c)
  if (x>>2)&1:
    s+=d
    out+=p
  else:
    s-=d
    out+=m
  out+=str(d)+'=7'
  return [s, out]

for i in range(8):
  if f(i)[0]==7:
    print(f(i)[1])
    break

Solution (Python):
def dfs(pos, Str, res):
    
    if pos == 4:
        if res == 7:
            print(Str + "=7")
            exit()
        return
    dfs(pos+1, Str + "+" + s[pos], res + int(s[pos]))
    dfs(pos+1, Str + "-" + s[pos], res - int(s[pos]))

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

Solution (Python):
s = input()

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

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

a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
l = [b,c,d]
s = a+b+c+d
ans = 1

if s == 7:
  h_1,h_2,h_3 = "+","+","+"
elif s-b*2 == 7:
  h_1,h_2,h_3 = "-","+","+"
elif s-c*2 == 7:
  h_1,h_2,h_3 = "+","-","+"
elif s-d*2 == 7:
  h_1,h_2,h_3 = "+","+","-"
elif s-b*2-c*2 == 7:
  h_1,h_2,h_3 = "-","-","+"
elif s-b*2-d*2 == 7:
  h_1,h_2,h_3 = "-","+","-"
elif s-c*2-d*2 == 7:
  h_1,h_2,h_3 = "+","-","-"
elif s-b*2-c*2-d*2 == 7:
  h_1,h_2,h_3 = "-","-","-"
else:
  ans = 0

if ans == 0:
  print("")
else:
  ans = "{0}{1}{2}{3}{4}{5}{6}{7}{8}".format(a,h_1,b,h_2,c,h_3,d,"=",7)
  print(ans)

Solution (Python):
import itertools

A, B, C, D = map(int, input())

for op1, op2, op3 in itertools.product([1, -1], [1, -1], [1, -1]):
  if A + op1 * B + op2 * C + op3 * D == 7:
    print('{}{:+}{:+}{:+}=7'.format(A, op1 * B, op2 * C, op3 * D))
    break

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

ops = []
for i in range(2 ** (len(S) -1)):
    op = ["-"] * 3
    for j in range(len(S) - 1):
        if i >> j & 1:
            op[j] = "+"
    ops.append(op)

def fomula(S, op):
    s = list(S)
    count = 1
    for i in range(len(s) - 1):
        s.insert(i+count, op[i])
        count += 1
    fomula = ""
    for k in range(len(s)):
        fomula += s[k]

    return fomula


for i in range(2 ** (len(S) -1)):
    fomul = fomula(S, ops[i])
    if eval(fomul) == 7:
        print(fomul+"=7")
        exit()

Solution (Python):

















import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    slen = len(s)-1
    for bit in range(1 << slen): 
        sum_ = int(s[0])
        ans = s[0]
        for i in range(3):
            if bit & (1 << i):
                sum_ += int(s[i+1])
                ans += "+" + s[i+1]
            else:
                sum_ -= int(s[i+1])
                ans += "-" + s[i+1]
        if sum_ == 7:
            print(ans + "=7")
            exit()
if __name__ == '__main__':
  main()

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

if a+b+c+d==7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a+b+c-d==7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a+b-c+d==7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a-b+c+d==7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a+b-c-d==7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a-b+c-d==7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a-b-c+d==7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a-b-c-d==7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")

Solution (Python):
import sys

a, b, c, d = input()

for i in range(2**3):
    op = ['','','']
    for j in range(3):
        if (i >> j) & 1:
            op[j] = '+'
        else:
            op[j] = '-'
    if eval(a + op[0] + b + op[1] + c + op[2] + d) == 7:
        print(a + op[0] + b + op[1] + c + op[2] + d + "=7")
        sys.exit()

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

a=[[] for _ in range(1<<len(s)-1)]   
for i in range(1<<len(s)-1):
    w=i
    for j in range(len(s)-1):
        b=w%2
        a[i].append(b)
        w//=2

for h in range(1<<len(s)-1):
    y=l[0]+"".join(("+" if a[h][i] else "-")+l[i+1] for i in range(len(a[h])))
    if eval(y)==7:
        print(y+"=7")
        break

Solution (Python):
s=input()
l=list(s)
for k in range(1 << (len(s)-1)):
    x=l[0]+"".join(("+" if (k>>i & 1) else "-")+j for i,j in enumerate(l[1:]))
    if eval(x)==7:
        print(x+"=7")
        break

Solution (Python):
li = list(map(int, input()))
for bit in range(1 << 3):
    ans = li[0]
    op = ["-"] * 3
    for i in range(3):
        if bit & (1 << i):
            ans += li[i+1]
            op[i] = "+"
        else:
            ans -= li[i+1]
    if ans == 7:
        print("{}{}{}{}{}{}{}=7".format(li[0],op[0],li[1],op[1],li[2],op[2],li[3]))
        exit()

Solution (Python):
def dfs(i, f):
    
    if i==3:
        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 = [int(x) for x in input()]
for i in range(1 << len(S)-1):
    s = S[0]
    ans = str(S[0])
    for j in range(len(S)-1):
        if ((i >> j) & 1):
            s += S[j+1]
            ans += "+" + str(S[j+1])
        else:
            s -= S[j+1]
            ans += "-" + str(S[j+1])
    if s == 7:
        print(ans + "=7")
        break

Solution (Python):

import sys
INF=10**9
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()

def main():
    l=list(input())+['7']
    ans=[l[i//2] for i in range(10)]
    ans[-2]=ans[-3]='='
    for i in range(8):
        for j in range(3):
            if (i>>j)&1:
                ans[j*2+1]='+'
            else:
                ans[j*2+1]='-'
        if eval(''.join(ans)):
            del ans[-2]
            print(''.join(ans))
            exit()

if __name__ == '__main__':
    main()

Solution (Python):

import sys
INF=10**9
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()

def main():
    l=list(map(int,list(input())))
    for i in range(8):
        tmp=l[:]
        for j in range(3):
            if (i>>j)&1:
                tmp[j+1]*=-1
        if sum(tmp)==7:
            print(tmp[0],end='')
            for x in tmp[1:]:
                if x<0:
                    print(x,end='')
                else:
                    print('+',x,sep='',end='')
            print('=7')
            exit()

if __name__ == '__main__':
    main()

Solution (Python):


A = input()
numbers = []
for i in range(len(A)):
  numbers.append(int(A[i]))
n = len(A)-1 
for i in range(2**n):
  tmp = numbers[0]
  ans = str(numbers[0])
  for j in range(n):
    if (i >> j) & 1:
      tmp += numbers[j+1]
      ans += "+"
      ans += str(numbers[j+1])
    else:
      tmp -= numbers[j+1]
      ans += "-"
      ans += str(numbers[j+1])
  if tmp == 7: 
    print(ans+"=7")
    break

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

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="")
elif a-b-c-d==7:
  print(a,"-",b,"-",c,"-",d,"=7",sep="")

Solution (Python):
a,b,c,d=input()
for i,j,k in map(lambda x:format(x,"03b").translate(str.maketrans("01","-+")),range(8)):
 h=a+i+b+j+c+k+d
 if eval(h)==7:print(h+"=7");break

Solution (Python):
s="".join;*i,l=input()
for t in map(lambda x: format(x,"03b").translate(str.maketrans("01","-+")),range(8)):
 h=s(map(s,zip(i,t)))+l
 if eval(h)==7:print(h+"=7");break

Solution (Python):
s = "".join
*i, l = input()
for t in map(lambda x: format(x, "03b").translate(str.maketrans("01","-+")), range(8)):
    h = s(map(s, zip(i, t))) + l
    if eval(h) == 7:
        print(h+"=7")
        break

Solution (Python):
S=input()
N=len(S)
A=[int(i) for i in S]
D=["+" for i in range(N-1)]
output=S[0]
for i in range(2**N):
  C=A
  B=D
  for j in range(N-1):
    if ((i>>j)&1):
      C[j+1]= -1*int(str(S[j+1]))
      B[j]=  "-"
    else:
      C[j+1]= int(str(S[j+1]))
      B[j]=  "+"
  
  if sum(C) ==7:
    for i in range(1,N):
      output += B[i-1] + str(S[i])
    print(output+"=7")
    break

Solution (Python):


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

n = len(l)
for i in range(2**(n-1)):
    op = ['+']*(n-1)
    for j in range(n):
        if i >> j & 1:
            op[j] = '-'
    if eval(l[0] + op[0] + l[1] + op[1] + l[2] + op[2] + l[3]) == 7:
        print(l[0] + op[0] + l[1] + op[1] + l[2] + op[2] + l[3], '=7', sep='')
        break

Solution (Python):
















S = input()
A,B,C,D = map(int,list(S))
numlis = [B,C,D]

for bitlines in range(0,1<<3):
    ans = [A]
    num = A
    for target in range(3):
        if bitlines>>target & 1:
            num += numlis[target]
            ans = ans+["+",numlis[target]]
        else:
            num -= numlis[target]
            ans = ans+["-",numlis[target]]
    if num ==7:
        ans.append("=7")
        print(*ans,sep="")
        exit()

Solution (Python):
import itertools

def solve(S):
    bit_list = list(itertools.product([0, 1], repeat=3))
    
    for pattern in bit_list:
        count = int(S[0])
        ans = S[0]
        for i in range(3):
            if pattern[i] == 0:
                count += int(S[i+1])
                ans += "+" + S[i+1]
            else:
                count -= int(S[i+1])
                ans += "-" + S[i+1]
        
        if count == 7:
            print(ans + "=7")
            break
    

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

Solution (Python):


a,b,c,d=list(input())
op=['+','-']

for op1 in op:
    for op2 in op:
        for op3 in op:
            res=a+op1+b+op2+c+op3+d
            if eval(res)==7:
                print(res+'=7')
                exit()

Solution (Python):
import itertools

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

for i in itertools.product(["+", "-"], repeat = 3):
    
    x = a + i[0] + b + i[1] + c + i[2] + d
    if eval(x) == 7:
        break

print(x + "=7")

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

if sumn == 7:
    print(n[0]+"+"+n[1]+"+"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*d == 7:
    print(n[0]+"+"+n[1]+"+"+n[2]+"-"+n[3]+"=7")
elif sumn - 2*c == 7:
    print(n[0]+"+"+n[1]+"-"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*b == 7:
    print(n[0]+"-"+n[1]+"+"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*b - 2*c == 7:
    print(n[0]+"-"+n[1]+"-"+n[2]+"+"+n[3]+"=7")
elif sumn - 2*b - 2*d == 7:
    print(n[0]+"-"+n[1]+"+"+n[2]+"-"+n[3]+"=7")
elif sumn - 2*c - 2*d == 7:
    print(n[0]+"+"+n[1]+"-"+n[2]+"-"+n[3]+"=7")
elif sumn - 2*b - 2*c - 2*d == 7:
    print(n[0]+"-"+n[1]+"-"+n[2]+"-"+n[3]+"=7")

Solution (Python):

















mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    slen = len(s) - 1
    a = s[0]
    for bit in range(1 << slen): 
        sum = int(a) 
        ans = a 
        
        for i in range(3):
            if bit & (1 << i):
                sum += int(s[i+1])
                ans += "+" + s[i+1]
            else:
                sum -= int(s[i+1])
                ans += "-" + s[i+1]
        if sum == 7:
            print(ans+"=7")
            exit()


if __name__ == '__main__':
  main()

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

for i in range(2):
  for j in range(2):
    for k in range(2):
      f= a + op[i] + b + op[j] +c + op[k] +d
      if eval(f) == 7:
        print(f + "=7")
        exit()

Solution (Python):
import sys


def dfs(i, s, val, formula):
    if (i == len(s) - 1):
        if val == 7:
            print(formula + "=7")
            sys.exit()
            return formula
        else:
            return None

    dfs(i + 1, s, val + int(s[i + 1]), formula + "+" + s[i + 1])
    dfs(i + 1, s, val - int(s[i + 1]), formula + "-" + s[i + 1])
    return None


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

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

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

for bit in range(1 << 3):
    SUM = int(ABCD[0])
    for i in range(3):
        if (bit >> i) & 1:
            SUM += int(ABCD[i + 1])
        else:
            SUM -= int(ABCD[i + 1])
    if SUM != 7: continue
    ans = ABCD[0]
    for i in range(3):
        ans += "+" if (bit >> i) & 1 else "-"
        ans += ABCD[i + 1]
    print(ans + "=7")
    exit()

Solution (Python):
A,B,C,D=map(int, list(input()))
L=["+","-"]

for a in L:
  for b in L:
    for c in L:
      now=A
      if a=="+":
        now+=B
      else:
        now-=B
      if b=="+":
        now+=C
      else:
        now-=C
      if c=="+":
        now+=D
      else:
        now-=D
      
      if now==7:
        print(str(A)+a+str(B)+b+str(C)+c+str(D)+"=7")
        exit()

Solution (Python):
L = [int(x) for x in input()]
A, B, C, D = L[0], L[1], L[2], L[3]

if A+B+C+D == 7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A-B+C+D == 7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B-C+D == 7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D == 7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D == 7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B+C-D == 7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B-C-D == 7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B-C-D == 7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Solution (Python):
from itertools import product

A, B, C, D = map(int, input())

for p in product((1, -1), repeat=3):
    cnt = A
    for s, i in zip(p, (B, C, D)):
        cnt += s * i
    if cnt == 7:
        ans = str(A)
        for s, i in zip(p, (B, C, D)):
            ans += ('+' if s > 0 else '-') + str(i)
        ans += '=7'
        print(ans)
        exit()

print('-1')

Solution (Python):
a=list(input().rstrip())

for i in range(8):
    s = list("-".join(a))

    for j in range(0, 3):
        if i&(1<<j):
            s[1+j+j]="+"
    if eval(''.join(s))==7:
        print(''.join(s)+"=7")
        exit()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    
    
    L = input()
    L = [int(c) for c in L]



    n = len(L)-1
    
    for i in range(2 ** n):
        ans=L[0]
        cnt=L[0]
        s=''

        """        
        10進数表記　2進数表記
        0           000
        1           001
        2           010
        3           011
        4           100
        5           101
        6           110
        7           111
        """

        for j in range(n):  
            if ((i >> j) & 1):  
                cnt+=L[-j-1]
                s='+'+str(L[-j-1])+s
            else:
                cnt-=L[-j-1]
                s='-'+str(L[-j-1])+s

        if cnt==7:
            print(str(L[0])+s+'=7')
            break



resolve()

Solution (Python):
L=input()
if int(L[0])+int(L[1])+int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])+int(L[1])+int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])+int(L[1])-int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])+int(L[1])-int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])+int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])+int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])-int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])-int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

M = list(input())

S = [int(s) for s in M]
L = [0, 1] 
num = 3 
bit_list = list(product(["+", "-"], repeat=num))

tmp = 0
for b in bit_list:
    ans = 0
    
    for i, o in enumerate(b):
        
        if o == "+":
            if i == 0:
                ans = S[i] + S[i+1]
            else:
                ans += S[i+1]
        else:
            if i == 0:
                ans = S[i] - S[i+1]
            else:
                ans -= S[i+1]
    
    if ans == 7:
        tmp = b
        break
ans = ""
for i, c in enumerate(tmp):
    ans += M[i]
    ans += c
ans += M[-1] + "=7"
print(ans)

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

a = list(input())
kipp(0,a[0])

Solution (Python):
import itertools
a,b,c,d = list(input())
for i in itertools.product(["+", "-"], repeat=3):
  x = a + i[0] + b + i[1] + c + i[2] + d
  if eval(x) == 7:break
print(x+"=7")

Solution (Python):
def resolve():
  x = input()
  a = int(x[0])
  b = int(x[1])
  c = int(x[2])
  d = int(x[3])
  for i in range(2):
    ans1 = str(a)
    sum1 = a
    if i == 0:
      sum1 -= b
      ans1 += "-" + str(b)
    else:
      sum1 += b
      ans1 += "+" + str(b)
    for j in range(2):
      ans2 = ans1
      sum2 = sum1
      if j == 0:
        sum2 -= c
        ans2 += '-' + str(c)
      else:
        sum2 += c
        ans2 += '+' + str(c)
      for k in range(2):
        sum3 = sum2
        ans3 = ans2
        if k == 0:
          sum3 -= d
          ans3 += '-' + str(d)
        else:
          sum3 += d
          ans3 += '+' + str(d)
        if sum3 == 7:
          print(ans3 + "=7")
          return
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
a = input()
for bit in range(1<<3):
    ans1 = int(a[0])
    ans = []
    for i in range(3):
        mask = 1<<i
        if mask&bit:
            ans.append('+')
            ans1 += int(a[i+1])
        else:
            ans.append('-')
            ans1 -= int(a[i+1])
            
    if ans1==7:
        break
ans.append('=7')
d = []
for i in range(4):
    d.append(a[i])
    d.append(ans[i])
print(''.join(d))

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

ans_c=[['+','+','+'],['+','+','-'],['+','-','+'],['-','+','+'],['+','-','-'],['-','+','-'],['-','-','+'],['-','-','-'],]

for i in ans_c:
  num=l[0]
  for j in range(3):
    if i[j]=='+':
      num+=l[j+1]
    else:
      num-=l[j+1]
  if num==7:
    print(str(l[0])+i[0]+str(l[1])+i[1]+str(l[2])+i[2]+str(l[3])+'=7')
    exit()

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

def f():
    for pm in itertools.product(range(2), repeat = 3):
        ans = N[0]
        lst = []
        for i in range(3):
            if pm[i] == 1:
                ans += N[i + 1]
                lst.append("+")
            else:
                ans -= N[i + 1]
                lst.append("-")
        if ans == 7:
            for i in range(3):
                print(N[i], end = "")
                print(lst[i], end = "")
            print(N[-1], end = "")
            print("=7")
            return 0

f()

Solution (Python):
from itertools import product
S = input()
for x in product(("+","-"),repeat=3):
    if eval(S[0]+x[0]+S[1]+x[1]+S[2]+x[2]+S[3])==7:
        print(S[0]+x[0]+S[1]+x[1]+S[2]+x[2]+S[3]+"=7")
        break

Solution (Python):
S = input()

def solve(n,S,idx):
    if len(n) == 7:
        if eval(n) == 7:
            n += "=7"
            print(n)
            exit()
        return

    solve(n+"+"+S[idx], S,idx+1)
    solve(n+"-"+S[idx], S,idx+1)

solve(S[0], S, 1)

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

for p in range(1<<3):
    t = int(a[0])
    ans = a[0]
    for i in range(1,4):
        if p&(1<<(i-1)):
            t+=int(a[i])
            ans += '+' + a[i]
        else:
            t-=int(a[i])
            ans += '-' + a[i]
    if t==7:
        print(ans+'=7')
        break

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

for case in range(8):
    ans = str(S[0])
    ans_val = S[0]
    case_tmp = case
    for i in range(3):
        if case_tmp % 2 > 0:
            ans_val += S[i + 1]
            ans += '+{}'.format(S[i + 1])
        else:
            ans_val -= S[i + 1]
            ans += '-{}'.format(S[i + 1])
        case_tmp >>= 1
    
    if ans_val == 7: break
    else: continue
else:
    ans = 'kanipanman'

print(ans + '=7')

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

    a = int(abcd[0])
    b = int(abcd[1])
    c = int(abcd[2])
    d = int(abcd[3])
    if (a + b + c + d == 7):
        print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    elif (a + b + c - d == 7):
        print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    elif (a + b - c + d == 7):
        print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    elif (a + b - c - d == 7):
        print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    elif (a - b + c + d == 7):
        print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    elif (a - b + c - d == 7):
        print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    elif (a - b - c + d == 7):
        print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    elif (a - b - c - d == 7):
        print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    S = input()
    for bit in range(1 << 3):
        calc_v = int(S[0])
        ans = [S[0]]
        for i in range(3):
            if bit & (1 << i):
                calc_v += int(S[i+1])
                ans.append("+")
                ans.append(S[i+1])
            else:
                calc_v -= int(S[i+1])
                ans.append("-")
                ans.append(S[i+1])
        if calc_v == 7:
            return print("".join(ans)+"=7")


if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d = map(int,input())
    l = [b,c,d]
    for k in range(1<<3):
        s = a
        ans = []
        for i in range(3):
            if k&(1<<i):
                ans.append("+")
                s += l[i]
            else:
                ans.append("-")
                s -= l[i]
        if s == 7:
            k = [a]
            for i in range(3):
                k.append(ans[i])
                k.append(l[i])
            k.append("=7")
            print(*k,sep="")
            return
    return


if __name__ == "__main__":
    solve()

Solution (Python):
a,b,c,d = input()
for x in '-+':
    for y in '-+':
        for z in '-+':
            f = a+x+b+y+c+z+d
            v = eval(f)
            if v==7:
                print(f+'=7')
                exit()

Solution (Python):
n = [int(x) for x in input()]
op_cnt = len(n) - 1

tmp = 0
for i in range(2**op_cnt):
    tmp = n[0]
    for j in range(op_cnt):
        if (i >> j) & 1:
            tmp += n[j+1]
        else:
            tmp -= n[j+1]
    if tmp == 7:
        print(
            "{}{}{}{}{}{}{}=7".format(
                n[0], "+" if (i >> 0) & 1 else "-",
                n[1], "+" if (i >> 1) & 1 else "-",
                n[2], "+" if (i >> 2) & 1 else "-",
                n[3]
            )
        )
        exit()

Solution (Python):
import io
import sys

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

import itertools

A, B, C, D = list(read().rstrip().decode('utf-8'))

for operators in itertools.product(['+', '-'], repeat=3):
    op1, op2, op3 = operators
    eq = A + op1 + B + op2 + C + op3 + D
    x = eval(eq)
    if x == 7:
        break

answer = eq + "=7"
print(answer)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    num = [0] * 4
    for i in range(4):
        num[i] = int(s[i])

    for bit in range(1 << 3):
        x = num[0]
        for i in range(3):
            if bit >> i & 1:
                x += num[i + 1]
            else:
                x -= num[i + 1]
        if x == 7:
            res = ""
            for j in range(3):
                res += str(num[j])
                if bit >> j & 1:
                    res += "+"
                else:
                    res += "-"
            res += str(num[3])
            res += "=7"
            print(res)
            sys.exit()


if __name__ == '__main__':
    main()

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

sym = ["+", "-"]

for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            S = A + B * (-1) ** op1 + C * (-1) ** op2 + D * (-1) ** op3
            if S == 7:
                print("".join(map(str, [A, sym[op1], B, sym[op2], C, sym[op3], D, "=", 7])))
                exit()