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):
n = int(input())
s = []
for i in range(4):
	s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()

def sgn(i):
	if i==0:
		return 1
	else:
		return -1

x = []
m = 0

for i in range(2):
	for j in range(2):
		for k in range(2):
			m +=1
			x.append(s[0]+s[1]*sgn(i)+s[2]*sgn(j)+s[3]*sgn(k))

z = x.index(7)
u = []
for i in range(3):
	u.append(z//(2**i)-(z//(2**(i+1)))*2)
u.reverse()

def ppp(i):
	if i==0:
		return "+"
	else:
		return "-"
print(s[0],ppp(u[0]),s[1],ppp(u[1]),s[2],ppp(u[2]),s[3],"=7",sep="")

Solution (Python):
s = input()
for a in '+-':
    for b in '+-':
        for c in '+-':
            t = s[0]+a+s[1]+b+s[2]+c+s[3]
            if eval(t)==7:
                print(t+'=7')
                exit()

Solution (Python):
O = ["+","-"]
I = list(input())
for o1 in O :
    for o2 in O :
        for o3 in O :
            f = I[0]+o1+I[1]+o2+I[2]+o3+I[3]
            if eval(f) == 7 :
                print(f+"=7")
                exit()

Solution (Python):
L = list(input())
O = ["+","-"]
for o1 in O :
    for o2 in O :
        for o3 in O :
            f = L[0]+o1+L[1]+o2+L[2]+o3+L[3]
            if eval(f) == 7 :
                print(f+"=7")
                exit()

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = lc()
for i in range(8):
    cur = int(n[0])
    ans = n[0]
    for j in range(2,-1,-1):

        if (i>>j)&1 == 1:
            cur += int(n[3-j])
            ans = ans + "+" + n[3-j]
        else:
            cur -= int(n[3-j])
            ans = ans + "-" + n[3-j]
        
        
    if cur == 7:
        ans = ans + "=" + "7"
        break

print(ans)

Solution (Python):
L = list((input()))
A = L[0]
B = L[1]
C = L[2]
D = L[3]
a = int(L[0])
b = int(L[1])
c = int(L[2])
d = int(L[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))
else :
    print("{}-{}-{}-{}=7".format(a,b,c,d))

Solution (Python):
w = input()

op = ["+", "-"]
for op1 in op:
    for op2 in op:
        for op3 in op:
            if eval(w[0] + op1 + w[1] + op2 + w[2] + op3 + w[3]) == 7:
                print(w[0] + op1 + w[1] + op2 + w[2] + op3 + w[3] + "=7")
                exit()

Solution (Python):
S = input()
for a in '+-':
    for b in '+-':
        for c in '+-':
            f = S[0]+a+S[1]+b+S[2]+c+S[3]
            if eval(f) == 7:
                print(f + '=7')
                exit()

Solution (Python):
list_s = list(str(input()))
for i in range(4):
    list_s[i] = int(list_s[i])

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = 0
            if i == 0:
                ans += list_s[0] + list_s[1]
            else:
                ans += list_s[0] - list_s[1]
            if j == 0:
                ans += list_s[2]
            else:
                ans -= list_s[2]
            if k == 0:
                ans += list_s[3]
            else:
                ans -= list_s[3]
            if ans == 7:
                break
        else:
            continue
        break
    else:
        continue
    break
list_sgn = ["+","-"]
print(str(list_s[0]) + list_sgn[i] + str(list_s[1]) + list_sgn[j] + str(list_s[2]) + list_sgn[k] + str(list_s[3]) + "=7")

Solution (Python):
input_str = input()

for i in range(8):
    calc_str = input_str[0]
    opmaker = str(format(i, 'b')).zfill(3)
    for j, c in enumerate(opmaker):
        if c == '0':
            calc_str += '-'
        else:
            calc_str += '+'
        calc_str += input_str[j+1]
    if eval(calc_str) == 7:
        print(calc_str + '=7')
        exit()

Solution (Python):

ABCD=str(input())
op='+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans_str=ABCD[0]+op[i]+ABCD[1]+op[j]+ABCD[2]+op[k]+ABCD[3]
            ans=eval(ans_str)
            if ans==7:
                print(ans_str+'=7')
                exit()

Solution (Python):
ABCD = list(input())
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
L = []
L.append(A+B+C+D)
L.append(A+B+C-D)
L.append(A+B-C+D)
L.append(A-B+C+D)
L.append(A+B-C-D)
L.append(A-B+C-D)
L.append(A-B-C+D)
L.append(A-B-C-D)
for i in range(len(L)) :
    if L[i] == 7 :
        if i == 0 or i == 1 or i == 2 or i == 4 :
            p1 = "+"
        else :
            p1 = "-"
        if i == 0 or i == 1 or i == 3 or i == 5 :
            p2 = "+"
        else :
            p2 = "-"
        if i == 0 or i == 2 or i == 3 or i == 6 :
            p3 = "+"
        else :
            p3 = "-"
        break
print("{}{}{}{}{}{}{}=7".format(A,p1,B,p2,C,p3,D))

Solution (Python):
import itertools

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

def plusMinus(zeroIchi):
    if zeroIchi ==0:
        return "-"
    else:
        return "+"

listN = [0, 1]
for i in itertools.product(listN, repeat=4):
    sum=a
    if i[0] == 0:
        sum-=b
    else:
        sum+=b
    if i[1] == 0:
        sum-=c
    else:
        sum+=c
    if i[2] == 0:
        sum-=d
    else:
        sum+=d
    if sum == 7:
        print(str(a)+plusMinus(i[0])+str(b)+plusMinus(i[1])+str(c)+plusMinus(i[2])+str(d)+"=7")
        break

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

def func(m):
    x1 = m[0] + m[1] + m[2] + m[3]
    if x1 == 7:
        return ("{}+{}+{}+{}=7".format(m[0],m[1],m[2],m[3]))
    x2 = m[0] + m[1] + m[2] - m[3]
    if x2 == 7:
        return ("{}+{}+{}-{}=7".format(m[0],m[1],m[2],m[3]))
    x3 = m[0] + m[1] - m[2] - m[3]
    if x3 == 7:
        return ("{}+{}-{}-{}=7".format(m[0],m[1],m[2],m[3]))
    x4 = m[0] + m[1] - m[2] + m[3]
    if x4 == 7:
        return ("{}+{}-{}+{}=7".format(m[0],m[1],m[2],m[3]))
    x5 = m[0] - m[1] - m[2] + m[3]
    if x5 == 7:
        return ("{}-{}-{}+{}=7".format(m[0],m[1],m[2],m[3]))
    x6 = m[0] - m[1] - m[2] - m[3]
    if x6 == 7:
        return ("{}-{}-{}-{}=7".format(m[0],m[1],m[2],m[3]))
    x7 = m[0] - m[1] + m[2] - m[3]
    if x7 == 7:
        return ("{}-{}+{}-{}=7".format(m[0],m[1],m[2],m[3]))
    x8 = m[0] - m[1] + m[2] + m[3]
    if x8 == 7:
        return ("{}-{}+{}+{}=7".format(m[0],m[1],m[2],m[3]))

print(func(n))

Solution (Python):
ABCD=int(input())
A=(ABCD//1000)
B=(ABCD//100)-(A*10)
C=(ABCD//10)-(A*100)-(B*10)
D=ABCD-(A*1000)-(B*100)-(C*10)

if (A+B+C+D)==7:
  print('%d+%d+%d+%d=7' %(A,B,C,D))
  exit()
if (A+B+C-D)==7:
  print('%d+%d+%d-%d=7' %(A,B,C,D))
  exit()
if (A+B-C+D)==7:
  print('%d+%d-%d+%d=7' %(A,B,C,D))
  exit()
if (A+B-C-D)==7:
  print('%d+%d-%d-%d=7' %(A,B,C,D))
  exit()
if (A-B+C+D)==7:
  print('%d-%d+%d+%d=7' %(A,B,C,D))
  exit()
if (A-B-C+D)==7:
  print('%d-%d-%d+%d=7' %(A,B,C,D))
  exit()
if (A-B+C-D)==7:
  print('%d-%d+%d-%d=7' %(A,B,C,D))
  exit()
if (A-B-C-D)==7:
  print('%d-%d-%d-%d=7' %(A,B,C,D))
  exit()

Solution (Python):
a, b, c, d = [int(i) for i in input()]
ops = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"]

for op in ops:
    s = a
    for i, n in enumerate([b, c, d]):
        op = list(op)
        if op[i] == "+":
            s += n
        else:
            s -= n
    if s == 7:
        print(str(a) + op[0] + str(b) + op[1] + str(c) + op[2] + str(d) + "=7")
        break

Solution (Python):
S=input()
op=["+","-"]
for a in op:
    for b in op:
        for c in op:
            f=S[0]+a+S[1]+b+S[2]+c+S[3]
            if eval(f)==7:
                print(f+"=7")
                exit()

Solution (Python):
A, B, C, D = input()
ops = ('+', '-')

for op1 in ops:
	for op2 in ops:
		for op3 in ops:
			if eval(A+op1+B+op2+C+op3+D+'==7'):
				print(A+op1+B+op2+C+op3+D+'=7')
				exit()

Solution (Python):
A,B,C,D = map(int,list(input()))
op = ["+","-"]
def check():
    ans = ""
    for i in range(2):
        for q in range(2):
            for k in range(2):
                op1,op2,op3 = op[i],op[q],op[k]
                if op1 == "+":
                    ans = A + B
                else:
                    ans = A - B
                if op2 == "+":
                    ans += C
                else:
                    ans -= C
                if op3 == "+":
                    ans += D
                else:
                    ans -= D
                if ans == 7:
                    return "{0}{1}{2}{3}{4}{5}{6}=7".format(A,op1,B,op2,C,op3,D)
print(check())

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


for i in range(0, 2):
    for j in range(0, 2):
        for k in range(0, 2):
            ans = ''
            if i == 0:
                AB = A + B
                ans += str(A) + '+' + str(B)
            else:
                AB = A - B
                ans += str(A) + '-' + str(B)
            if j == 0:
                ABC = AB + C
                ans += '+' + str(C)
            else:
                ABC = AB - C
                ans += '-' + str(C)
            if k == 0:
                ABCD = ABC + D
                ans += '+' + str(D)
            else:
                ABCD = ABC - D
                ans += '-' + str(D)
            if ABCD == 7:
                ans += '=7'
                print(ans)
                quit()

Solution (Python):


def main():
    import itertools
    nums = [int(c) for c in input()]
    ops = itertools.product(["+","-"], repeat=3)
    for op in ops:
        s = "{}{}{}{}{}{}{}".format(nums[0], op[0],
                                    nums[1], op[1],
                                    nums[2], op[2],
                                    nums[3])
        if eval(s) == 7:
            print(s + "=7")
            exit()


if __name__ == '__main__':
    main()

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

ops = {'+', '-'}

for op1 in ops:
    if op1 == '+': ab = a+b
    else: ab = a-b
    
    for op2 in ops:
        if op2 == '+': abc = ab+c
        else: abc = ab-c
        
        for op3 in ops:
            if op3 == '+': abcd = abc+d
            else: abcd = abc-d

            if abcd == 7:
                a, b, c, d = map(str, [a, b, c, d])
                print(a+op1+b+op2+c+op3+d+'=7')
                exit()

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

for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            tmp = a
            if op1 == '+':
                tmp += b
            else:
                tmp -= b

            if op2 == '+':
                tmp += c
            else:
                tmp -= c

            if op3 == '+':
                tmp += d
            else:
                tmp -= d

            if tmp == 7:
                ans = '{0}{1}{2}{3}{4}{5}{6}=7'.format(a, op1, b, op2, c, op3, d)

print(ans)

Solution (Python):
import itertools
S = input()
opt_list = list(itertools.product([0, 1], repeat=3)) 
res_opt = ['+', '+', '+']
for opt in opt_list:
    tmp = int(S[0])
    for i in range(3):
        if opt[i] == 0:
            tmp += int(S[i + 1])
            res_opt[i] = '+'
        else:
            tmp -= int(S[i + 1])
            res_opt[i] = '-'
    
    if tmp == 7:
        res = S[0] + res_opt[0] + S[1] + res_opt[1] + S[2] + res_opt[2] + S[3] + '=7'
        
print(res)

Solution (Python):
s=input()
op=["+","-"]
tolal=0
for i in op:
    for j in op:
        for k in op:
                total=eval("{}{}{}{}{}{}{}".format(s[0],i,s[1],j,s[2],k,s[3]))
                if total ==7:
                    print("{}{}{}{}{}{}{}=7".format(s[0],i,s[1],j,s[2],k,s[3]))
                    exit()

Solution (Python):
t = list(map(int,input()))
p = ['+','+','+']
q = ['','','']
for i in range(8):
    if i & 1:
        c = t[0] + t[1]
        p[0] = '+'
    else:
        c = t[0] - t[1]
        p[0] = '-'
    if i & (1<<1):
        c += t[2]
        p[1] = '+'
    else:
        c -= t[2]
        p[1] = '-'
    if i & (1<<2):
        c += t[3]
        p[2] = '+'
    else:
        c -= t[3]
        p[2] = '-'
    if c == 7:
        q[0] = p[0]
        q[1] = p[1]
        q[2] = p[2]
print(str(t[0]) + q[0] + str(t[1]) + q[1] + str(t[2]) + q[2] + str(t[3]) + '=7')

Solution (Python):
from itertools import product

num = list(map(int, list(input())))
flag = False

for i in product(("+", "-"), repeat=3):
    
    calc = num[0]
    for j, opt in enumerate(list(i)):
        if opt == "+":
            calc += num[j+1]
        else:
            calc -= num[j+1]

        if calc == 7:
            print("{}{}{}{}{}{}{}=7".format(num[0], i[0], num[1], i[1], num[2], i[2], num[3]))
            flag = True
            break

    if flag:
        break

Solution (Python):
a=input()
op=['+','-']
 
for i in op:
    for j in op:
        for k in op:
            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):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval(A + a + B + b + C + c + D) == 7:
                    print(A + a + B + b + C + c + D + "=7")
                    return


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
def ope(x,y,n,s):
    if n % 2 == 0:
        return x+y, str(s) + '+' + str(y)
    else:
        return x-y, str(s) + '-' + str(y)
for i in range(8):
    X1, S1 = ope(A,B,i,A)
    j = int(i/2)
    X2, S2 = ope(X1,C,j,S1)
    k = int(j/2)
    X3, S3 = ope(X2,D,k,S2)
    if X3 == 7:
        print(S3 + '=7')
        break

Solution (Python):
ABCD=list(map(int, list(input())))
for i in range(1<<3):
    tmp=list(map(int, list(str(bin(i))[2:].zfill(3))))
    a=ABCD[0]
    for j in range(3):
        if tmp[j]:
            a+=ABCD[j+1]
        else:
            a-=ABCD[j+1]
    if a==7:
        print(ABCD[0], end="")
        for j in range(3):
            print("+" if tmp[j] else "-", end="")
            print(ABCD[j+1], end="")
        print("=7")
        exit(0)

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval(A + a + B + b + C + c + D) == 7:
                    print(A + a + B + b + C + c + D + "=7")
                    return


if __name__ == '__main__':
    main()

Solution (Python):
import itertools
S=list(input())
T=list(itertools.product(["+","-"],repeat=3))
for seq in T:
    tmp=""
    for i in range(3):
        tmp+=S[i]+seq[i]
    tmp=tmp+S[3]
    if eval(tmp)==7:
        print(tmp+"=7")
        exit()
print("Baka!")

Solution (Python):
abcd=input()

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

Solution (Python):
from itertools import product

X = [int(x) for x in input()]

for ptn in product([-1, 1], repeat=3):
    if X[0] + ptn[0] * X[1] + ptn[1] * X[2] + ptn[2] * X[3] == 7:
        ptn = ['+' if s == 1 else '-' for s in ptn]
        print('{}{}{}{}{}{}{}=7'.format(X[0], ptn[0], X[1], ptn[1], X[2],
                                        ptn[2], X[3]))
        break

Solution (Python):
abcd = input()
for i in range(1 << 4):
    exp = ''
    for j in range(3):
        op = '+' if i & (1 << j) else '-'
        exp += abcd[j] + op
    exp += abcd[3]
    if eval(exp) == 7:
        print(exp + '=7')
        break

Solution (Python):
x = input()
for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            eq = x[0] + op1 + x[1] + op2 + x[2] + op3 + x[3]
            if eval(eq) == 7:
                print(eq + '=7')
                exit()

Solution (Python):
n = input()

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

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):
from itertools import product

a, b, c, d = list(map(int, input()))
for s in product('+-', repeat=3):
    f = '{}{}{}{}{}{}{}'.format(a,s[0],b,s[1],c,s[2],d)
    if eval(f)==7:
        print(f+'=7')
        break

Solution (Python):
from itertools import permutations, combinations,combinations_with_replacement,product
a=list(product(['+','-'],repeat=3))
s=list(input())
for i in a:
    ans=s[0]+i[0]+s[1]+i[1]+s[2]+i[2]+s[3]
    if eval(ans)==7:
        print(ans+'=7')
        break

Solution (Python):
a = b = c = d = 0
[a,b,c,d] = list(map(int,list((input()))))
for i in range(8):
    bin_padded = bin(i)[2:].zfill(3)
    temp = list(bin_padded)
    op = [-1,-1,-1]
    for j in range(3):
        if temp[j] == '1':
            op[j] = 1
    if (a + op[0] * b + op[1] * c +  op[2] * d) == 7:
        opch = ['-', '-', '-']
        for k in range(3):
            if op[k] == 1:
                opch[k] = '+'
        ans = str(a)+opch[0]+str(b)+opch[1]+str(c)+opch[2]+str(d)+'=7'
        print(ans)
        exit()

Solution (Python):
from itertools import product
N = input()
X = []

for i in range(4):
  X.append(int(N[i]))

for ops in product((1,-1), repeat=3):
  calc = X[0] + X[1]*ops[0] + X[2]*ops[1] + X[3]*ops[2]
  if calc == 7:
    opstr = [""] * 3
    for i in range(3):
      opstr[i] = '+' if ops[i] == 1 else '-'
    print(N[0] + opstr[0] + N[1] + opstr[1] + N[2] + opstr[2] + N[3] + "=7")
    break

Solution (Python):


S = input()
a = list(S)
A = int(a[0])
B = int(a[1])
C = int(a[2])
D = int(a[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 = list(map(int, input()))

for pattern in product('+-', repeat=3):
    f = '{}{}{}{}{}{}{}'.format(A, pattern[0], B, pattern[1], C, pattern[2], D)
    if eval(f) == 7:
        print(f+'=7')
        break

Solution (Python):
def sarch(B, C, D):
    return a + B * b + C * c + D * d == 7

def ansprint(B, C, D):
    print(str(a) + B + str(b) + C + str(c) + D + str(d) + "=7")

def figstr(B, C, D):
    BB = "-"
    CC = "-"
    DD = "-"
    if B == 1:
        BB = "+"
    if C == 1:
        CC = "+"
    if D == 1:
        DD = "+"
    ansprint(BB, CC, DD)

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

if sarch(1, 1, 1):
    figstr(1, 1, 1)
elif sarch(1, -1, 1):
    figstr(1, -1, 1)
elif sarch(1, 1, -1):
    figstr(1, 1, -1)
elif sarch(-1, 1, 1):
    figstr(-1, 1, 1)
elif sarch(-1, -1, 1):
    figstr(-1, -1, 1)
elif sarch(1, -1, -1):
    figstr(1, -1, -1)
elif sarch(-1, 1, -1):
    figstr(-1, 1, -1)
elif sarch(-1, -1, -1):
    figstr(-1, -1, -1)

Solution (Python):
from itertools import product

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

for pattern in product('+-', '+-', '+-'):
    f = '{}{}{}{}{}{}{}'.format(A, pattern[0], B, pattern[1], C, pattern[2], D)

    if eval(f) == 7:
        print(f+'=7')
        break

Solution (Python):

A_list = [int(x) for x in list(input())]
OP_list = ["","",""]
answer = ""



def solve(current, current_sum):
    if current == 4:
        return current_sum == 7
    
    if solve(current + 1 , current_sum + A_list[current]):
        OP_list[current-1] = "+"
        return True
    
    if solve(current + 1 , current_sum - A_list[current]):
        OP_list[current-1] = "-"
        return True
    
    return False

solve(1,A_list[0])
answer = str(A_list[0]) + OP_list[0] + str(A_list[1]) + OP_list[1] + str(A_list[2]) + OP_list[2] + str(A_list[3]) + "=7"
print (answer)

Solution (Python):
t = list(map(int, list(input())))
t.append(7)
op = []

def dfs(x, i):
    if i == 4 or len(op) == 3:
        if x == 7:
            op.append('=')
            ans = ''
            for j in range(5):
                if j == 4:
                    ans += str(t[j])
                else:
                    ans += str(t[j]) + op[j]
            print(ans)
            exit()
        return

    i += 1
    op.append('+')
    dfs(x + t[i], i)
    op.pop()

    op.append('-')
    dfs(x - t[i], i)
    op.pop()
    i -= 1
    return

dfs(t[0], 0)

Solution (Python):
import sys
t = list(map(int, list(input())))
t.append(7)
op = []

def dfs(x, i):
    if i == 4 or len(op) == 3:
        if x == 7:
            op.append('=')
            ans = ''
            for j in range(5):
                if j == 4:
                    ans += str(t[j])
                else:
                    ans += str(t[j]) + op[j]
            print(ans)
            sys.exit(0)
        return

    i += 1
    op.append('+')
    dfs(x + t[i], i)
    op.pop()

    op.append('-')
    dfs(x - t[i], i)
    op.pop()
    i -= 1

    return

dfs(t[0], 0)

Solution (Python):
a=list(input())
for i in range(1<<3):
    ans=""
    ans+=a[0]
    for j in range(3):
        if i&(1<<j):
            ans+="+"
        else:
            ans+="-"
        ans+=a[j+1]
    temp=eval(ans)
    if temp==7:
        print(ans+"=7")
        exit()

Solution (Python):
import sys

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

signs = ['+' , '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+signs[i]+B+signs[j] + C + signs[k] + D
            if eval(ans) == 7:
                print(ans + '=7')
                sys.exit()

Solution (Python):
from itertools import product
input_int_list = list(map(int, input()))

for operator_comb in product(range(2), repeat = len(input_int_list)-1):
    sum_value = input_int_list[0]
    formula_str = str(input_int_list[0])
    for i, operator in enumerate(operator_comb):
        if operator == 0:
            sum_value += input_int_list[i+1]
            formula_str += '+' + str(input_int_list[i+1])
        else:
            sum_value -= input_int_list[i+1] 
            formula_str += '-' + str(input_int_list[i+1])
    if sum_value == 7:
        print(formula_str + '=7')
        break

Solution (Python):
input_list = [int(data) for data in list(input())]
for i in [1, -1]:
    op1 = ''
    if i == 1:
        op1 = '+'
    else:
        op1 = '-'
    for j in [1, -1]:
        op2 = ''
        if j == 1:
            op2 = '+'
        else:
            op2 = '-'
        for k in [1, -1]:
            op3 = ''
            if k == 1:
                op3 = '+'
            else:
                op3 = '-'
            if input_list[0] + i * input_list[1] + j * input_list[2] + k * input_list[3] == 7:
                print(str(input_list[0]) + op1 + str(input_list[1]) + op2 + str(input_list[2]) + op3 + str(input_list[3]) + '=7')
                exit()

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

def cal(a, b, opx):
    if opx == "+":
        return a + b
    else:
        return a - b

op = ["+", "-"]
result = ""
for op1 in op:
    for op2 in op:
        for op3 in op:
            if cal(cal(cal(A, B, op1),C,  op2), D, op3) == 7:
                print(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7")
                exit()

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

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

for flag in itertools.product([0,1], repeat=3):
	tmp = li[0]
	for i,fl in enumerate(flag):
		if fl:
			tmp += li[i+1]
		else:
			tmp -= li[i+1]

	if tmp == 7:
		ans = ''
		for i in range(3):
			ans = ans + str(li[i])
			if flag[i]:
				ans = ans + '+'
			else:
				ans = ans + '-'
		ans = ans + str(li[3]) + '=7'
		break

print(ans)

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

for i in range(2):
  for j in range(2):
    for k in range(2):
      answer = A
      answer = answer + B if i == 0 else answer - B
      answer = answer + C if j == 0 else answer - C
      answer = answer + D if k == 0 else answer - D
      if answer == 7:
        o1 = '+' if i == 0 else '-'
        o2 = '+' if j == 0 else '-'
        o3 = '+' if k == 0 else '-'
        print('{}{}{}{}{}{}{}=7'.format(A,o1,B,o2,C,o3,D))
        sys.exit()

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

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

"""
Created on Fri Aug 10 03:26:19 2018

@author: Yuki
"""

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

def calc(num1, num2, op):
    if op=='+':
        return num1 + num2
    else:
        return num1 - num2
flag = False
for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            if calc(calc(calc(A, B, op1), C, op2), D, op3)==7:
                flag = True
            if flag:
                break
        if flag:
            break
    if flag:
        break
print(s[0]+op1+s[1]+op2+s[2]+op3+s[3]+'=7')

Solution (Python):
l = list(input())
for a in ["+", "-"]:
    for b in ["+", "-"]:
        for c in ["+", "-"]:
            if eval(l[0]+a+l[1]+b+l[2]+c+l[3]) == 7:
                print(l[0]+a+l[1]+b+l[2]+c+l[3]+"=7")
                exit()

Solution (Python):
d = input()
for a in '+-':
    for b in '+-':
        for c in '+-':
            s = d[0] + a + d[1] + b + d[2] + c + d[3]
            if eval(s)==7:
                print(s+'=7')
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
n = input()


for i in range(1<<(len(n)-1)):
    num = int(n[0])
    ope =[]
    for j in range(0,len(n)-1):
        if i & (1 << j):
            num += int(n[j+1])
            ope.append('+')
        else:
            num -= int(n[j+1])
            ope.append('-')
    if num == 7:
        for k in range(len(n)):
            if k == len(n) -1:
                print(n[k],"=7",sep="",end="")
            else:
                print(n[k],end="")
                print(ope[k],end="")

        break

Solution (Python):
a, b, c, d = input()
op = ["+", "-"]
for i in op:
  for j in op:
    for k in op:
      result = a + i + b + j + c + k + d
      if eval(result) == 7:
        print(result + "=7")
        exit()

Solution (Python):


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

op = ["+", "-"]

for op1 in op:
    for op2 in op:
        for op3 in op:
            ret = a
            if op1=="+":
                ret += b
            else:
                ret -= b
            if op2=="+":
                ret += c
            else:
                ret -= c
            if op3=="+":
                ret += d
            else:
                ret -= d
            if ret==7:
                print(a,op1,b,op2,c,op3,d,"=7",sep="")
                exit()

Solution (Python):



if __name__ == '__main__':
    v = input()
    d = len(v) - 1

    for bit in range(1 << d):
        expr_i = v[0]
        sum_i = int(v[0])
        for i in range(d):
            if bit & (1 << i) != 0:
                expr_i += '+' + v[i + 1]
                sum_i += int(v[i + 1])
            else:
                expr_i += '-' + v[i + 1]
                sum_i -= int(v[i + 1])

        if sum_i == 7:
            expr_i += '=7'
            print(expr_i)
            exit(0)

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

l = [a]
l2 = []
for x in l:
    
    l2.append(x+b)
    l2.append(x-b)
l = l2
l2 = []
for x in l:
    
    l2.append(x+c)
    l2.append(x-c)
l = l2

l2 = []
for x in l:
    
    l2.append(x+d)
    l2.append(x-d)
l = l2

k = l.index(7)
if k <= 3:
    w1 = '+'
else:
    w1 = '-'

if k == 0 or k == 1 or k == 4 or k == 5:
    w2 = '+'
else:
    w2 = '-'
    
if k%2 == 0:
    w3 = '+'
else:
    w3 = '-'
    
print(s[0] + w1 + s[1] + w2 + s[2] + w3+ s[3] +'=7')