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

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

Solution (Python):

import itertools
def main():
    number = input()
    for prod in list(itertools.product([0, 1], repeat=3)):
        ans = number[0]
        sum = int(ans)
        for i, p in enumerate(prod):
            if p == 0:
                sum += int(number[i+1])
                ans += '+' + number[i+1]
            else:
                sum -= int(number[i+1])
                ans += '-' + number[i+1]
        if sum == 7:
            print(ans + '=7')
            return
                
if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d = input()
for i in range(2**3):
    ch = ["+","+","+"]
    for j in range(3):
        if (i >> j & 1):
            ch[j] = "-"
    if eval(a+ch[0]+b+ch[1]+c+ch[2]+d) == 7:
        print(a+ch[0]+b+ch[1]+c+ch[2]+d,"=7", sep = "")
        break

Solution (Python):
import itertools
s = input()
p = itertools.product(['+','-'], repeat = 3)
for i in p:
    ev = '{}{}{}{}{}{}{}'.format(s[0],i[0],s[1],i[1],s[2],i[2],s[3])
    if eval(ev) == 7:
        print(ev+'=7')
        break

Solution (Python):
A,B,C,D = input()
op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      ans = A+i+B+j+C+k+D
      if eval(ans)==7:
        print(ans+"=7")
        exit()

Solution (Python):
import sys
num = list(input())
op1 = "+"
for x in range(2):
  op2 = "+"
  for y in range(2):
    op3 = "+"
    for z in range(2):
      fml = (num[0]+op1+num[1]+op2+num[2]+op3+num[3])
      if eval(fml) == 7:
        print(num[0]+op1+num[1]+op2+num[2]+op3+num[3]+"=7")
        sys.exit()
      op3 = "-"
    op2 = "-"
  op1 = "-"

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

b=int(tic[1])
c=int(tic[2])
d=int(tic[3])

a=int(tic[0])
B=[b,-b]
C=[c,-c]
D=[d,-d]

ans=0
ans2=tic[0]

for i in range(2):
  for j in range(2):
    for k in range(2):
      ans=a+B[i]+C[j]+D[k]
      if ans==7:
        b=B[i]
        c=C[j]
        d=D[k]
ans=[b,c,d]

for an in ans:
  if an >= 0:
    ans2 += '+'+str(an)
  else:
    ans2 += str(an)
    
ans2 += '=7'

print(ans2)

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

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):
s = list(input())

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a + b + c + d ==7:
    print("{0}+{1}+{2}+{3}=7".format(a, b, c, d))
elif a - b + c + d ==7:
    print("{0}-{1}+{2}+{3}=7".format(a, b, c, d))
elif a + b - c + d ==7:
    print("{0}+{1}-{2}+{3}=7".format(a, b, c, d))
elif a + b + c - d ==7:
    print("{0}+{1}+{2}-{3}=7".format(a, b, c, d))
elif a - b - c + d ==7:
    print("{0}-{1}-{2}+{3}=7".format(a, b, c, d))
elif a + b - c - d ==7:
    print("{0}+{1}-{2}-{3}=7".format(a, b, c, d))
elif a - b + c - d ==7:
    print("{0}-{1}+{2}-{3}=7".format(a, b, c, d))
elif a - b - c - d ==7:
    print("{0}-{1}-{2}-{3}=7".format(a, b, c, d))

Solution (Python):
S = input()
A = [int(s) for s in S]
for i in range(8):
    ii = i
    Sum = A[0]
    for j in range(3):
        if (i >> j) & 1:
            Sum += A[j+1]
        else:
            Sum -= A[j+1]
    if Sum == 7:
        Ans = str(A[0])
        for j in range(3):
            if (i >> j) & 1:
                Ans += "+"
            else:
                Ans += "-"
            Ans += str(A[j+1])
        Ans += "=7"
        print(Ans)
        break

Solution (Python):
n_str = list(input())
n = [int(i) for i in n_str]
l = len(n)-1
for i in range(2 ** l):
    sum = n[0]
    op_list = []
    for j in range(l):
        if (i >> j) & 1:
            sum += n[j+1]
            op_list.append('+')
        else:
            sum -= n[j+1]
            op_list.append('-')
    
    if sum == 7:
        print(n_str[0]+op_list[0]+n_str[1]+op_list[1]+n_str[2]+op_list[2]+n_str[3]+'=7')
        exit()

Solution (Python):
a, b, c, d = map(int, list(input()))
if a-b-c-d==7 :
    print(f"{a}-{b}-{c}-{d}=7")
elif a-b-c+d==7 :
    print(f"{a}-{b}-{c}+{d}=7")
elif a-b+c-d==7 :
    print(f"{a}-{b}+{c}-{d}=7")
elif a-b+c+d==7 :
    print(f"{a}-{b}+{c}+{d}=7")
elif a+b-c-d==7 :
    print(f"{a}+{b}-{c}-{d}=7")
elif a+b-c+d==7 :
    print(f"{a}+{b}-{c}+{d}=7")
elif a+b+c-d==7 :
    print(f"{a}+{b}+{c}-{d}=7")
elif a+b+c+d==7 :
    print(f"{a}+{b}+{c}+{d}=7")

Solution (Python):
a,b,c,d = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

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

for i in range(8):
    k = a[0]
    b = []
    for j in range(3):
        if ((i >> j) & 1):
            k += a[j+1]
            b.append("+")
        else:
            k -= a[j+1]
            b.append("-")
    if k == 7:
        break

ans = ""
for i in range(3):
    ans += str(a[i]) + b[i]
ans += str(a[3]) + "=7"

print(ans)

Solution (Python):
from itertools import product
ABCD = input()
for op in product('+-',repeat=len(ABCD)-1):
  n = int(ABCD[0])
  for i in range(1,len(ABCD)):
    if op[i-1] == '+':
      n += int(ABCD[i])
    else:
      n -= int(ABCD[i])
  if n == 7:
    print(ABCD[0],end='')
    for i in range(1,len(ABCD)):
      print(op[i-1]+ABCD[i],end='')
    print('=7')
    break

Solution (Python):
S = input()
ans = ""
for i in range(2**(len(S)-1)):
    total = int(S[0])
    for j in range(1, len(S)):
        if (i >> j-1) & 1:
            total += int(S[j])
        else:
            total -= int(S[j])
    if total == 7:
        for j in range(len(S)-1):
            ans += S[j]
            if i >> j & 1:
                ans += "+"
            else:
                ans += "-"
        ans += S[-1]
        break
print(ans + "=7")

Solution (Python):

ABCD=list(map(int,input()))
for i in range(2**4):
    sm = ABCD[0]
    ans = [str(sm)]
    for j in range(1,4):
        bit = i & 1
        if bit:
            sm += ABCD[j]
            ans.append('+')
            ans.append(str(ABCD[j]))
        else:
            sm -= ABCD[j]
            ans.append('-')
            ans.append(str(ABCD[j]))
        i = i >> 1
    ans.append('=7')
    if sm == 7:
        print(''.join(ans))
        exit()

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

ans=""
for i in range(1<<3):
    num=n[0]
    num += n[1] if (i>>0)&1 else -n[1]
    num += n[2] if (i>>1)&1 else -n[2]
    num += n[3] if (i>>2)&1 else -n[3]
    if num==7:
        ans=str(n[0])
        ans+= "+" if (i>>0)&1 else "-"
        ans+= str(n[1])
        ans+= "+" if (i>>1)&1 else "-"
        ans+= str(n[2])
        ans+= "+" if (i>>2)&1 else "-"
        ans+=str(n[3])+"=7"

print(ans)

Solution (Python):
ABCD = input()

for bit in range(1<<3):
    f = ABCD[0]
    ans = int(ABCD[0])
    for i in range(3):
        if bit & (1<<i):
            f += '+'
            ans += int(ABCD[i+1])
        else :
            f += '-'
            ans -= int(ABCD[i+1])
        f += ABCD[i+1]
    if ans == 7:
        break
print(f+'=7')

Solution (Python):
import sys
import math


def calc(operation,target,src):
    if operation == 0:
        return target - src
    return target + src

def operation(int_operation):
    if int_operation == 0:
        return "-"
    return "+"

nums=list(input())


answer=7


for i in [0,1]:
    for j in [0,1]:
        for k in [0,1]:
            chalange = int(nums[0])
            chalange = calc(i,chalange,int(nums[1]))
            chalange = calc(j,chalange,int(nums[2]))
            chalange = calc(k,chalange,int(nums[3]))
            if chalange == answer:
                print(nums[0] + operation(i) + nums[1] + operation(j) + nums[2] + operation(k) + nums[3] + "=7" )
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):

s = input()
a = [int(c) for c in s]

for i in range(2 ** 3):
    ptn = []
    num = a[0]

    for j in range(3):
        if (i >> j) & 1:
            ptn.append("+")
            num += a[j + 1]

        else:
            ptn.append("-")
            num -= a[j + 1]
    
    if num == 7:
        print("{}{}{}{}{}{}{}=7".format(a[0], ptn[0], a[1], ptn[1], a[2], ptn[2], a[3]))
        break

Solution (Python):
a,b,c,d=input()
for i in range(2**3):
    l=["-","-","-"]
    for j in range(3):
        if (i>>j&1):
            l[j]="+"
    if eval(a+l[0]+b+l[1]+c+l[2]+d)==7:
        print(a+l[0]+b+l[1]+c+l[2]+d+"=7")
        exit()

Solution (Python):

ABCD = input()

for i in range(8):
	binary = format(i, 'b').zfill(3)
	sum = int(ABCD[0])
	ans = ABCD[0]
	
	for j in range(3):
		s = ABCD[j + 1]
		
		if binary[j] == '1':
			sum += int(s)
			ans += '+' + s
		else:
			sum -= int(s)
			ans += '-' + s
	
	if sum == 7:
		ans += '=7'
		print(ans)
		break

Solution (Python):
import sys
N = list(input())
for bit in range(2 ** 3):
    op = ['-'] * 3
    for i in range(3):
        if (bit & (1 << i)):
            op[i] = '+'
    E = N[0] + op[0] + N[1] + op[1] + N[2] + op[2] + N[3]
    if eval(E) == 7:
        print(E + '=7')
        sys.exit()

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] = "+"
    op += [""]
            
    formura = ""
    for i,j in zip(n,op):
        formura += i+j
    if eval(formura) == 7:
        print(formura + "=7")
        break

Solution (Python):
ABCD = list(i for i in input())

for i in range(2**3):
    box = []
    for k in range(3):
        if ((i>>k) & 1):
            box.append("+")
        else:
            box.append("-")
    if eval("{0}{4}{1}{5}{2}{6}{3}".format(*ABCD,*box)) == 7:
        print("{0}{4}{1}{5}{2}{6}{3}=7".format(*ABCD,*box))
        break

Solution (Python):
a,b,c,d=input()
for i in range(2**3):
    l=["-","-","-"]
    for j in range(3):
        if (i>>j&1):
            l[j]="+"
    if eval(a+l[0]+b+l[1]+c+l[2]+d)==7:
        print(a+l[0]+b+l[1]+c+l[2]+d+"=7")
        break

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

import itertools

A=(1,-1)

def e(x):
	if x==1:
		return '+'
	else:
		return '-'

for v in itertools.product(A,repeat=3):
	s=a+b*v[0]+c*v[1]+d*v[2]
	if s==7:
		print(L[0]+e(v[0])+L[1]+e(v[1])+L[2]+e(v[2])+L[3]+'=7')
		exit()

Solution (Python):
import itertools
L = input()
L = [int(x) for x in list(str(L))]
P = [0]*3
sum = L[0]
A = (1,-1)
for a in itertools.product(A,repeat=3):
	for i in range(3): 
		sum += a[i]*L[i+1]
		if a[i] == 1:
			P[i] = '+'
		else:
			P[i] = '-'
	if sum == 7:
		print(L[0],P[0],L[1],P[1],L[2],P[2],L[3],'=7',sep = '')
		break
	sum = L[0]

Solution (Python):
from itertools import product 

T = input()

for pm in product(["+", "-"], repeat = 3):
  if eval(T[0]+pm[0]+T[1]+pm[1]+T[2]+pm[2]+T[3]) == 7:
    print(T[0]+pm[0]+T[1]+pm[1]+T[2]+pm[2]+T[3]+"=7")
    exit()

Solution (Python):

num = list(input())
A=int(num[0])
B=int(num[1])
C=int(num[2])
D=int(num[3])
ans=0
for i in range(1<<3):
    if( (i>>2) & 1 == 1):
        ans = A+B
        op1 = "+"
    else:
        ans = A-B
        op1 = "-"
    if((i>>1)&1 == 1):
        ans += C
        op2 = "+"
    else:
        ans -= C
        op2 = "-"
    if((i>>0) & 1 == 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

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

for i in range(8):
    log = []
    x = t[0]
    for s in range(3):
        if i>>s&1:
            x += t[s+1]
            log.append("+")
        else:
            x -= t[s+1]
            log.append("-")
    if x == 7:
        print(str(t[0])+log[0]+str(t[1])+log[1]+str(t[2])+log[2]+str(t[3])+"=7")
        break

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

for i in range(1<<3):
    form = ""
    for j in range(3):
        form += s[j]
        if i & 1<<j:
            form += "+"
        else:
            form += "-"
    form += s[-1]
    if eval(form) == 7:
        print(form + "=7")
        exit()

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

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

Solution (Python):
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product


ABCD = input()
for p in product((0, 1), repeat=3):
    A, B, C, D = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3])
    total = 0
    if (p[0] == 0):
        total = A + B
    else:
        total = A - B
    if (p[1] == 0):
        total += C
    else:
        total -= C
    if (p[2] == 0):
        total += D
    else:
        total -= D
    if total == 7:
        break
if p[0] == 0:
    op1 = "+"
else:
    op1 = '-'
if p[1] == 0:
    op2 = "+"
else:
    op2 = '-'
if p[2] == 0:
    op3 = "+"
else:
    op3 = '-'
print("{}{}{}{}{}{}{}=7".format(A, op1, B, op2, C, op3, D))

Solution (Python):
s = input()

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

Solution (Python):
x = input()
a = int(x[0])
bcd = list(map(int, [x[1], x[2], x[3]]))

for j in range(8):
    n = []
    op = []
    for i in range(3):
        if (j >> i) & 1:
            n.append(bcd[i])
            op.append("+")
        else:
            n.append(-bcd[i])
            op.append("-") if bcd[i] == 0 else op.append("")
    if a + sum(n) == 7:
        print(f"{a}{op[0]}{n[0]}{op[1]}{n[1]}{op[2]}{n[2]}=7")
        break

Solution (Python):

    
s = input()
num = len(s) - 1

for i in range(2**num):
    op = ['-']*num
    
    for j in range(num):
        if(i>>j)&1:
            op[num-j - 1] = '+'
    formula = ''
    for op_n, op_m in zip(s,op+['']):
        formula += op_n + op_m
    if eval(formula)==7:
        print(formula+ '=7')
        break

Solution (Python):
n = input()
op_cnt = len(n) - 1 
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  
    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
digits = input()
op_cnt = len(digits) - 1
for i in range(op_cnt ** 2):
    op = ["-"] * 3
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[-j] = "+"
    
    formula = ""
    for p_n, p_o in zip(digits, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
def solve():
    n = input()
    for i in range(2 ** 3):
        op = ['+', '+', '+']
        for j in range(3):
            if (i >> j) & 1:
                op[j] = '-'
        f = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
        if eval(f) == 7:
            print(f+'=7')
            exit()





if __name__ == "__main__":
    solve()

Solution (Python):
ABCD = list(input())
ope = ['+', '-']
for i in range(2**3):
    f = ABCD[0]
    for j in range(3):
        if i >> j & 1:
            f += '+'
        else:
            f += '-'
        f += ABCD[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()

Solution (Python):

import itertools

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

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

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

def eval(opt, x, y):
    if opt == "-":
        return x - y
    else:
        return x + y


for opt1, opt2, opt3 in itertools.product(["-", "+"], repeat=3):
    if eval(opt3, eval(opt2, eval(opt1, A, B), C), D) == 7:
        print("{}{}{}{}{}{}{}=7".format(str(A), opt1, str(B), opt2, str(C), opt3, str(D)))
        exit(0)

Solution (Python):
s = input()

n = 3
for i in range(2**n):
    ans = s[0]
    sum = int(s[0])
    for j in range(3):
        if 1 & (i >> j):
            ans += f'+{s[j+1]}'
            sum += int(s[j+1])
        else:
            ans += f'-{s[j+1]}'
            sum -= int(s[j+1])
    if sum == 7:
        print(f'{ans}=7')
        exit()

Solution (Python):
def solve():
    s = [int(x) for x in input()]

    def dfs(i, x, a):
        if i == 4:
            if x == 7:
                return a + "=7"
            else:
                return False
        res1 = dfs(i + 1, x + s[i], a + "+" + str(s[i]))
        res2 = dfs(i + 1, x - s[i], a + "-" + str(s[i]))
        return res1 or res2

    res = dfs(1, s[0], str(s[0]))
    print(res)


solve()

Solution (Python):
S = input()

op = ['+','+','+']

for bit in range(2**3):
  sum = int(S[0])
  for i in range(3):
    if (bit >> i) & 1:
      sum += int(S[i+1])
      op[i] = '+'
    else:
      sum -= int(S[i+1])
      op[i] = '-'

  if sum == 7:
    print(f'{S[0]}{op[0]}{S[1]}{op[1]}{S[2]}{op[2]}{S[3]}=7')
    break

Solution (Python):
num = input()

for mask in range(1 << 3):
    tmp = int(num[0])
    ans_str = num[0]
    for i in range(3):
        if mask >> i & 1 == 1:
            tmp += int(num[i + 1])
            ans_str += '+' + num[i + 1]
        else:
            tmp -= int(num[i + 1])
            ans_str += '-' + num[i + 1]
    if tmp == 7:
        print(ans_str + '=7')
        exit()

Solution (Python):
N = input()
num_list = list(N)
op = ["+", "-"]
flag = False
for i in range(len(op)):
    for j in range(len(op)):
        for k in range(len(op)):
            eq = num_list[0] + op[i] + num_list[1] + \
                op[j] + num_list[2] + op[k] + num_list[3]
            ans = eval(eq)
            if ans == 7:
                flag = True
                break
        if flag == True:
            break
    if flag == True:
        break
print(eq + "=" + str(ans))

Solution (Python):
l = list(input())
for i in range(8):
  s = int(l[0])
  b = bin(i)[2:].zfill(3)
  op = ["", "", ""]
  for j in range(len(b)):
    if b[j] == "0":
      s += int(l[j+1])
      op[j] = "+"
    else:
      s -= int(l[j+1])
      op[j] = "-"
  if s == 7:
    print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+"=7")
    break

Solution (Python):
a,*l=input()
for i in range(8):
  f=a
  for j in [0,1,2]: f+='-+'[i>>j&1]+l[j]
  if eval(f)==7: print(f+'=7'); exit()

Solution (Python):
a,*l=input()
for i in range(8):
  f=a
  for j in range(3):
    f+='-+'[i>>j&1]+l[j]
  if eval(f)==7: print(f+'=7'); exit()

Solution (Python):


S = input()
n = len(S) - 1
TOTAL = 7
for i in range(1 << n):
    x = S[0]
    for j in range(n):
        if i & 1 << j:
            x += "+"
        else:
            x += "-"
        x += S[j + 1]
    if eval(x) == TOTAL:
        print(f"{x}={TOTAL}")
        break
    else:
        continue
    break

Solution (Python):
a,b,c,d = input()
for i in range(2**3):
    ku = ["+", "+", "+"]
    for j in range(len(ku)):
        if(i>>j)&1:
           ku[j]= "-"
    if eval(a+ku[0]+b+ku[1]+c+ku[2]+d) == 7:
     print(a+ku[0]+b+ku[1]+c+ku[2]+d+"=7")
     break

Solution (Python):
import sys,math,collections,itertools
input = sys.stdin.readline

a,b,c,d =list(input().rstrip())
op_lis = itertools.product('+-',repeat=3)
for op in op_lis:
    if eval(a+op[0]+b+op[1]+c+op[2]+d) == 7:
        print(a+op[0]+b+op[1]+c+op[2]+d+'=7')
        exit()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans,p,m = '','+','-'
    n = input().rstrip('\n')
    for i in range(2**3):
        ans = [n[0], p, n[1], p, n[2], p, n[3]]
        for j in range(3):
            if i>>j&1:
                ans[2*j+1] = m
        if eval(''.join(ans)) == 7:
            break
    ans = ''.join(ans) + '=7'
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input().rstrip("\n"))))
    
    for i in range(2**3):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product
s = list(input())
n = len(s)

pattern = list(product(['+', '-'], repeat=n-1))

for i in range(2 ** (n-1)):
    formula = s[0]
    for j, k in zip(pattern[i], s[1:]):
        formula += (j + k)
    if eval(formula) == 7:
        print("{}=7".format(formula))
        break

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

A = N // 1000
B = (N - 1000 * A) // 100
C = (N - 1000 * A - 100 * B) // 10
D = N % 10

for i in range(2):
  for j in range(2):
    for k in range(2):
      ans = A
      if i==1:
        op1 = '+'
        ans += B
      else:
        op1 = '-'
        ans -= B
      if j==1:
        op2 = '+'
        ans += C
      else:
        op2 = '-'
        ans -= C
      if k==1:
        op3 = '+'
        ans += D
      else:
        op3 = '-'
        ans -= D
      if ans==7:
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
        break
    else:
      continue
    break
  else:
    continue
  break

Solution (Python):
A = input()
op_cnt = len(A)-1
for j in range(2**op_cnt):
  op = ['-'] * op_cnt
  for k in range(op_cnt):
    if (j>>k) & 1:
      op[op_cnt - 1 - k] = '+'
      
  formula = ''
  for p_n, p_o in zip(A, op + ['']):
    formula += (p_n + p_o)
  if eval(formula) == 7:
    print(formula + '=7')
    break

Solution (Python):
S = input()

for i in range(2**3):
    exp = []
    for j in range(4):
        exp.append(S[j])
        if j == 3:
            None
        elif ((i >> j) & 1):
            exp.append('+')
        else:
            exp.append('-')
    
    a = 0
    neg = False
    for j in range(len(exp)):
        if exp[j] == '-':
            neg = True
        elif exp[j] == '+':
            neg = False
        else:
            if neg:
                a -= int(exp[j])
            else:
                a += int(exp[j])
    
    if a == 7:
        print(''.join(exp)+'=7')
        break

Solution (Python):









import sys
input = sys.stdin.readline


def F(S, i):
    if i == len(S):
        if eval(''.join(S)) == 7:
            print(''.join(S) + "=7")
            return True
        else:
            return False

    S1 = S.copy()
    S1.insert(i, "+")
    if F(S1, i + 2):
        return True
    S2 = S.copy()
    S2.insert(i, "-")
    if F(S2, i + 2):
        return True
    return False


S = list(input().rstrip('\n'))
F(S, 1)

Solution (Python):
a,b,c,d = open(0).read().rstrip()

from itertools import product
for o,p,q in product(['-','+'],repeat=3):
    state = a+o+b+p+c+q+d
    if eval(state) == 7:
        print(state+'=7')
        break

Solution (Python):
ABCD = input()
a, b, c, d = map(int, list(ABCD))
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):
S = input()

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

Solution (Python):
a, b, c, d = map(str, list(input()))
data = ["+", "-"]
for x in range(2):
    for y in range(2):
        for z in range(2):
            if eval(a + data[x] + b + data[y] + c + data[z] + d) == 7:
                print("{}{}{}{}{}{}{}{}{}".format(a, data[x], b, data[y], c, data[z], d, "=", "7"))
                exit()

Solution (Python):
S = input()
if int(S[0])+int(S[1])+int(S[2])+int(S[3])==7:
    print(f'{S[0]}+{S[1]}+{S[2]}+{S[3]}=7')
elif int(S[0])+int(S[1])+int(S[2])-int(S[3])==7:
    print(f'{S[0]}+{S[1]}+{S[2]}-{S[3]}=7')
elif int(S[0])+int(S[1])-int(S[2])+int(S[3])==7:
    print(f'{S[0]}+{S[1]}-{S[2]}+{S[3]}=7')
elif int(S[0])-int(S[1])+int(S[2])+int(S[3])==7:
    print(f'{S[0]}-{S[1]}+{S[2]}+{S[3]}=7')
elif int(S[0])+int(S[1])-int(S[2])-int(S[3])==7:
    print(f'{S[0]}+{S[1]}-{S[2]}-{S[3]}=7')
elif int(S[0])-int(S[1])+int(S[2])-int(S[3])==7:
    print(f'{S[0]}-{S[1]}+{S[2]}-{S[3]}=7')
elif int(S[0])-int(S[1])-int(S[2])+int(S[3])==7:
    print(f'{S[0]}-{S[1]}-{S[2]}+{S[3]}=7')
else:
    print(f'{S[0]}-{S[1]}-{S[2]}-{S[3]}=7')

Solution (Python):
a=input()
l=[int(a[0]),int(a[1]),int(a[2]),int(a[3])]

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

    
    if l[0]+(op[0]*l[1])+(op[1]*l[2])+(op[2]*l[3])==7: 
        options=[]
        for option in op:
            if option ==1:
                options.append('+')
            else:
                options.append("-")
        print('{}{}{}{}{}{}{}=7'.format(l[0],options[0],l[1],options[1],l[2],options[2],l[3]))
        break

Solution (Python):
s=input()
a,b,c,d=[int(s[i]) for i in range(4)]
for i in range (2**3):
    res=a
    ans=[str(a)]
    for j in range (3):
        if i >> j &1:
            res+=int(s[j+1])
            ans+=["+",s[j+1]]
        else:
            res-=int(s[j+1])
            ans+=["-",s[j+1]]
    if res==7:
        ans+=["=7"]
        print("".join(ans))
        break

Solution (Python):
N = str(input())
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[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):
num_=input()
op_=len(num_)-1
for i in range(2**op_):
  op=["-"]*op_
  for j in range(op_):
    if ((i>>j)&1):
      op[op_-1-j]="+"
  formula=""
  op.append("")
  for p_num,p_op in zip(num_,op):
    formula+=p_num+p_op
  if eval(formula)==7:
    print(formula+"=7")
    break

Solution (Python):
n = input()
m = len(n)-1
for i in range(2**m):
  op = ['-'] * m
  for j in range(m):
    if ((i>>j) & 1):
      op[m -1 - j] = '+'
  formula = ''
  for p, q in zip(n, op+['']):
    formula += (p+q)
  if eval(formula) == 7:
    print(formula + '=7')
    exit()

Solution (Python):









import sys
input = sys.stdin.readline


def cal(Sn, opt):
    ans = Sn[0]
    for i in range(3):
        if opt[i] == '+':
            ans += Sn[i+1]
        else:
            ans -= Sn[i+1]
    return ans


S = list(input().rstrip('\n'))
Sn = [int(i) for i in S]
op = ['+', '-']
opL = [(i, j, k) for i in op for j in op for k in op]

for opt in opL:
    if cal(Sn, opt) == 7:
        break

ans = ''
for i in range(3):
    ans += S[i] + opt[i]
ans += S[3] + '=7'
print(ans)

Solution (Python):








import sys
S = sys.stdin.readline().rstrip()
A,B,C,D = [int(c) for c in S]

def calc(s,i,ops):
    
    if i == 4:
        if s == 7:
            print(S[0]+ops[0]+S[1]+ops[1]+S[2]+ops[2]+S[3]+"=7")
            exit(0)
        else:
            return
    calc(s+int(S[i]),i+1,ops+["+"])
    calc(s-int(S[i]),i+1,ops+["-"])

calc(int(S[0]),1,[])

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    NUM = list(input().rstrip())
    NUM_I = [int(i) for i in NUM]
    ps = [1, 1, 1]

    for i in range(8):
        for j in range(3):
            if (i >> j) & 1:
                ps[j] = -1
                
                
            else:
                ps[j] = 1
            ans = NUM_I[0] + ps[0]*NUM_I[1] + ps[1]*NUM_I[2] + ps[2]*NUM_I[3]
            if ans == 7:
                ps_s = ['+' if i>0 else '-' for i in ps]
                
                ans_s = [NUM[0]]
                for i in range(3):
                    ans_s.append(ps_s[i])
                    ans_s.append(NUM[i+1])
                ans_s.append('=7')
                print(''.join(ans_s))
                return

if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit

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

x = ['+', '-']


def cul(x, y, z):
    if z == 0:
        return x + y
    else:
        return x - y


for i in range(8):
    op = [0, 0, 0]
    for j in range(3):
        op[j] = i >> j & 1
    if cul(cul(cul(a, b, op[0]), c, op[1]), d, op[2]) == 7:
        print(a, x[op[0]], b, x[op[1]], c, x[op[2]], d, '=7', sep='')
        exit()

Solution (Python):
def a(t,i):
    if i==l:
        if eval(t)==7:
            print(t+'=7')
            exit()
        return
    a(t+'+'+s[i+1],i+1)
    a(t+'-'+s[i+1],i+1)

s = input()
l = len(s)-1
a(s[0],0)

Solution (Python):


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

total = 7

n = 3

k = 0
for i in range(2 ** n):
  
    way = a
    for j in range(n):
        if ((i >> j) & 1):
            way += "+"
            way += (abcd[j + 1])
        else:
            way += "-"
            way += (abcd[j + 1])
    
    ans = eval(way)
    
    if ans == 7:
      
      print(way + "=7")
      k = 1
      break
if k != 1:
    print("No")