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):
S = input()
s = [int(c) for c in S]
def to_s(a):
  if a>=0:
    return "+"+str(a)
  return str(a)

for b in [-s[1],s[1]]:
  for c in [-s[2],s[2]]:
    for d in [-s[3],s[3]]:
      if s[0]+b+c+d == 7:
        print(S[0]+to_s(b)+to_s(c)+to_s(d)+"=7")
        exit()

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

def pm_hantei(n,l_pm):
  return "+"*(l_pm[n]==0)+"-"*(l_pm[n]==1)


j=2**(4-1)
for k in range(j):
  b_str = format(k,"0{}b".format(4-1))
  l_pm = [ int(b_str[i]) for i in range(len(b_str)) ]
  wa = a + b*(-1)**(l_pm[0]) + c*(-1)**(l_pm[1]) + d*(-1)**(l_pm[2])
  

  if wa == 7:
    print("{}{}{}{}{}{}{}=7".format(a,pm_hantei(0,l_pm),b,pm_hantei(1,l_pm),c,pm_hantei(2,l_pm),d ) )
    break
  else:
    continue

Solution (Python):
s=list(input())
a=["+"]*3
d=[]
for ss,aa in zip(s,a):
    d.append(ss)
    d.append(aa)
d.append(s[-1])
import copy
for i in range(2**3):
    dd=copy.deepcopy(d)
    for j in range(3):
        if ((i>>j)&1):
            dd[2*j+1]="-"
    st="".join(dd)
    if eval(st)==7:
        print("{}{}".format(st,"=7"))
        exit()

Solution (Python):



Num = input()
ABCD = [Num[0], Num[1], Num[2], Num[3]]


opt_list = []
for i in range(8):
    opt = [0, 0, 0]
    for j in range(3):
        if ((i>>j)&1):
            opt[3-j-1] = 1
    opt_list.append(opt)


for opt in opt_list:
    math_formula = ""
    for i in range(3):
        if opt[i]==1:
            math_formula += ABCD[i] + "+"
        else:
            math_formula += ABCD[i] + "-"
    math_formula += ABCD[3]
    if eval(math_formula)==7:
        print(math_formula+"=7")
        break

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

def dfs(i,s,sum):
    if i==3:
        if sum==7:
            print(s+'=7')
            exit()
    else:
        dfs(i+1,s+'-'+str(l[i+1]),sum-l[i+1])
        dfs(i+1,s+'+'+str(l[i+1]),sum+l[i+1])
    return -1

dfs(0,str(l[0]),l[0])

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

n=3
for i in range(2**n):
    s = str(l[0])
    sum_s = l[0]
    for j in range(n):
        
        if (i>>j)&1:
            s+='+'+str(l[j+1])
            sum_s+=l[j+1]
        
        else:
            s+='-'+str(l[j+1])
            sum_s-=l[j+1]

    if sum_s==7:
        print(s+'=7')
        exit()

Solution (Python):
S = str(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A+B+C+D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7")
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 = str(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
if A+B+C+D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=" + "7")
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):
nums=[int(i) for i in input()]
ops=[1,-1]
ans=-1
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      if nums[0]+op1*nums[1]+op2*nums[2]+op3*nums[3]==7:
        ans=''+str(nums[0])
        ans+='+' if op1==1 else '-'
        ans+=str(nums[1])
        ans+='+' if op2==1 else '-'
        ans+=str(nums[2])
        ans+='+' if op3==1 else '-'
        ans+=str(nums[3])
        ans+='=7'
print(ans)

Solution (Python):
if __name__ == "__main__":
    s = input()

    op = ['+1', '-1']

    for i in op:
        for j in op:
            for k in op:
                if int(s[0]) + int(s[1])*int(i) + int(s[2])*int(j) + int(s[3])*int(k) == 7:
                    print(s[0] + i[0] + s[1] + j[0] +
                          s[2] + k[0] + s[3] + '=7')
                    exit()

Solution (Python):
def solve():
    n = list(input())
    n = [ord(c) - ord('0') for c in n]
    sign = ['-', '+']

    for i in range(2):
        for j in range(2):
            for k in range(2):
                t = n[0]
                t += n[1] * (i * 2 - 1)
                t += n[2] * (j * 2 - 1)
                t += n[3] * (k * 2 - 1)
                if t == 7:
                    print('{}{}{}{}{}{}{}=7'.format(n[0], sign[i], n[1], sign[j], n[2], sign[k], n[3]))
                    return


if __name__ == "__main__":
    solve()

Solution (Python):
A, B, C, D = list(input())
import itertools

for ops in itertools.product(["+", "-"], repeat=3):
  eq = A + ops[0] + B + ops[1] + C + ops[2] + D
  x = eval(eq)
  if x == 7: break

print(eq + "=7")

Solution (Python):

tmp = list(input())

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

if a + b + c + d == 7:
    print(str(a) + '+' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
    exit()
if a + b + c - d == 7:
    print(str(a) + '+' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
    exit()
if a + b - c + d == 7:
    print(str(a) + '+' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
    exit()
if a - b + c + d == 7:
    print(str(a) + '-' + str(b) + '+' + str(c) + '+' + str(d) + '=7')
    exit()
if a + b - c - d == 7:
    print(str(a) + '+' + str(b) + '-' + str(c) + '-' + str(d) + '=7')
    exit()
if a - b + c - d == 7:
    print(str(a) + '-' + str(b) + '+' + str(c) + '-' + str(d) + '=7')
    exit()
if a - b - c + d == 7:
    print(str(a) + '-' + str(b) + '-' + str(c) + '+' + str(d) + '=7')
    exit()
if a - b - c - d == 7:
    print(str(a) + '-' + str(b) + '-' + str(c) + '-' + str(d) + '=7')
    exit()

Solution (Python):

num = list(map(int, list(input())))
for bit in range(1 << 3):
    res = num[0]
    ans = str(num[0])
    for i in range(3):
        res += (-1)**(bit >> i & 1) * num[i+1]
        ans += ('-' if bit >> i & 1 else '+') + str(num[i+1])
    if res == 7:
        print(ans + '=7')
        exit()

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 fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
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

abcd = list(STR())
for i in range(4):
    abcd[i] = int(abcd[i])
op = ['+', '-']
ops = ['+', '+', '+']
for ops[0] in op:
    for ops[1] in op:
        for ops[2] in op:
            tmp = abcd[0]
            for i in range(3):
                if ops[i] == '+':
                    tmp += abcd[i+1]
                else:
                    tmp -= abcd[i+1]
                if tmp == 7:
                    ans = str(abcd[0])
                    for i in range(3):
                        ans += ops[i] + str(abcd[i+1])
                    ans += '=7'
                    print(ans)
                    exit()

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

flag = False
for i in range(2**4):
    state = []
    for j in range(4):
        state.append((i >> j) & 1)
    
    ans = 0
    for i,s in enumerate(state):
        if s:
            ans += ABCD[i]
        else:
            ans -= ABCD[i]
    
    if ans == 7:
        ans = ""
        for i,s in enumerate(state):
            if s:
                ans += "+"
            else:
                ans += "-"
            ans += str(ABCD[i])
        if ans[0] == "+" or ans[:2] == "-0":
            ans = ans[1:]
        print(ans+"=7")
        exit()

Solution (Python):
def main():
    S = input()
    op = ['+', '-']

    def calc(cur):
        ret = int(S[0])
        for i in range(3):
            if cur[i] == "+":
                ret += int(S[i+1])
            else:
                ret -= int(S[i+1])
        return ret
    for i in range(1 << 3):
        cur = []
        for j in range(3):
            if i & (1 << j):
                cur.append(op[0])
            else:
                cur.append(op[1])
        if calc(cur) == 7:
            print("".join(S[i]+cur[i] for i in range(3)) + S[3] + "=7")
            return


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

for fl in itertools.product([0,1],repeat=3):
    cnt = s[0]
    for i,t in enumerate(fl):
        if t==0:
            cnt += s[i+1]
        else:
            cnt -= s[i+1]
    if cnt == 7:
        L = str(s[0])
        for i,t in enumerate(fl):
            if t==0:
                L += '+' + str(s[i+1])
            else:
                L += '-' + str(s[i+1])
        print(L + '=7')
        break

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

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

Solution (Python):
import itertools

s = input()
final = ""
gr = list(itertools.product('+-', repeat=3))
for c in gr:
    ans = int(s[0])
    for i in range(1, 4):
        if c[i-1] == "+":
            ans += int(s[i])
        else:
            ans -= int(s[i])
    if ans == 7:
        final = s[0] + c[0] + s[1] + c[1] + s[2] + c[2] + s[3] + "=7"

print(final)

Solution (Python):


def main():
    S = input()
    size = len(S)

    for bit in range(1 << (size-1)):
        exp = S[0]
        for i in range(size-1):
            if (bit & (1 << i)):
                exp += '+'
            else:
                exp += '-'
            exp += S[i+1]
        if eval(exp) == 7:
            print(exp + '=7')
            break

if __name__ == '__main__':
    main()

Solution (Python):
_ = "_"


def solve(f):
    if _ in f:
        a = solve(f.replace(_, '+', 1))
        b = solve(f.replace(_, '-', 1))
        if a is not None:
            return a
        if b is not None:
            return b
    else:
        if eval(f) is 7:
            return f
        else:
            return None


s = _.join(input())
print(solve(s) + '=7')

Solution (Python):
n = list(input())
li = list()
for i in range(2**3):
    op = ["-"]*3
    for j in range(3):
        if ((i>>j)&1):
            op[2-j] = "+"
    ans = n[0]+op[0]+n[1]+op[1]+n[2]+op[2]+n[3]
    if (eval(ans) == 7):
        print(ans+"=7")
        break

Solution (Python):

A, B, C, D = input()
for i in range(2**3):
    op = ['+']*3
    for j in range(3):
        if (i >> j) & 1:
            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' )
        break

Solution (Python):
import itertools

abcd = input()
memo = list(itertools.product(['+', '-'], repeat=3))

for i in range(2 ** 3):
    cnt = int(abcd[0])
    for j in range(3):
        if memo[i][j] == '+':
            cnt += int(abcd[j + 1])
        else:
            cnt -= int(abcd[j + 1])
    if cnt == 7:
        print(abcd[0] + memo[i][0] + abcd[1] + memo[i][1] + abcd[2] + memo[i][2] + abcd[3] + '=7')
        break

Solution (Python):
def main():
    n = [int(x) for x in 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 += (str(p_n) + p_o)
        
        if eval(formula) == 7:
            print(formula + "=7")
            break


if __name__ == "__main__":
    main()

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(N[0]+"+"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c+d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b-c+d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b+c-d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c+d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c-d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a+b-c-d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c-d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()

Solution (Python):
a = input()

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

    sum = a[0] + N[0] + a[1] + N[1] + a[2] + N[2] + a[3]
    if eval(sum) == 7:
        print(sum + "=7")
        exit()

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):
s=input()
for i in range(8):
  e=bin(i)[2:].zfill(3).replace("0","+").replace("1","-")+"="
  x="".join("".join(c )for c in zip(s,e))[:-1]
  if eval(x)==7:print(x+"=7");exit()

Solution (Python):
import sys

S = input()

N = len(S)-1

for i in range(2**N):
    op = ["+"]*N

    for j in range(N):
        if (i>>j)&1:
            op[j] = "-"
    s = ""
    
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[N]
    if 7==eval(s):
        print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+"=7")
        sys.exit()

Solution (Python):
s = input()

n = len(s) - 1
ans = 0
for i in range(1 << n):
    exp = s[0]
    for j in range(n):
        if i & (1 << j):
            exp += "+"
        else:
            exp += "-"
        exp += s[j + 1]
    if eval(exp) == 7:
        ans = exp

ans += "=7"
print(ans)

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


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

Solution (Python):
def main():
    s = str(input())
    n = len(s)
    for i in range(2**(n-1)):
        op = ["+"]*(n-1)
        for j in range(n-1):
            if ((i >> j) & 1):
                op[j] = "-"
        formula = ""
        for p_s , p_o in zip(s, op+[""]):
            formula += p_s + p_o
        if (eval(formula)==7):
            print(formula+"=7")
            return
main()

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

Solution (Python):
def main():
    s = str(input())
    n = len(s)
    for i in range(2**(n-1)):
        op = ["+"]*(n-1)
        for j in range(n-1):
            if ((i >> j) & 1):
                op[j] = "-"
        formula = ""
        for p_s , p_o in zip(s, op+[""]):
            formula += p_s + p_o
        if (eval(formula)==7):
            print(formula+"=7")
            return
main()

Solution (Python):
num = input()
pm_cnt = len(num)  - 1

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

  ans = ""

  for p_n, p_o in zip(num, pm + [""]):
    ans += (p_n + p_o)
  if eval(ans) == 7:
    print(ans + "=7")
    break

Solution (Python):
abcd = input()
n = len(abcd) - 1
form_list = []
for i in range(2 ** n):
    form = abcd[0]
    for j in range(n):
        if ((i >> j) & 1):
            form += "+" + abcd[j + 1]
        else:
            form += "-" + abcd[j + 1]
    form_list.append(form)

flag = False
for formula in form_list:
    if eval(formula) == 7:
        
        flag = True
        break
if flag:
    print(formula + "=7")

Solution (Python):
nums = input()


for i in range(8):
    operands = []
    sum_num = int(nums[0])
    for j in range(3):
        if i >> j & 1:
            sum_num += int(nums[j+1])
            operands.append("+")
        else:
            sum_num -= int(nums[j+1])
            operands.append("-")
    if sum_num == 7:
        result = []
        operands.append("")
        for num, operand in zip(nums, operands):
            result.append(num)
            result.append(operand)
        print("".join(result) + "=7")
        break

Solution (Python):
def main():
    
    
    ABCD = input()
    A = int(ABCD[0])
    B = int(ABCD[1])
    C = int(ABCD[2])
    D = int(ABCD[3])
    op_max = format(7,"03b")
    for i in range(int(op_max,2)+1):
        res = A
        now = format(i,"03b")
        op_s = []
        for j in range(len(now)):
            if now[j] == "0":
                op_s.append("+")
            elif now[j] == "1":
                op_s.append("-")
        if op_s[0] == "+":
            res += B
        elif op_s[0] == "-":
            res -= B
        if op_s[1] == "+":
            res += C
        elif op_s[1] == "-":
            res -= C
        if op_s[2] == "+":
            res += D
        elif op_s[2] == "-":
            res -= D
        if res == 7:
            print(str(A)+op_s[0]+str(B)+op_s[1]+str(C)+op_s[2]+str(D)+"=7")
            exit()


if __name__ == "__main__":
    main()

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter


M = list(input())
N = [int(m) for m in M]

ans_list = [N[0],'+',N[1],'+',N[2],'+',N[3],'=',7]

for i in range(1<<3):
    tmp = N[0]
    for j in range(3):
        if i & (1<<j):
            tmp += N[j+1]
            ans_list[j*2+1] = '+'
        else:
            tmp -= N[j+1]
            ans_list[j*2+1] = '-'
    if tmp == 7:
        ans_maped = map(str,ans_list)
        ans = ''.join(ans_maped)
        print(ans)
        break

Solution (Python):
s=list(map(int,list(input())))
if s[0]+s[1]+s[2]+s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"+"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]+s[1]+s[2]-s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"+"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]+s[1]-s[2]+s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"-"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]+s[1]-s[2]-s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"-"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]-s[1]+s[2]+s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"+"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]-s[1]+s[2]-s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"+"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]-s[1]-s[2]+s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"-"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]-s[1]-s[2]-s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"-"+str(s[2])+"-"+str(s[3])+"=7")

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

dict = {1: "+", -1: "-"}

for k in [1, -1]:
    for l in [1, -1]:
        for m in [1, -1]:
            if a + (k * b) + (l * c) + (m * d) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, dict[k], b, dict[l], c, dict[m], d))
                exit()

Solution (Python):
s = list(input())
s = [int(i) for i in s]
for i in range(0, 8):
    t = str(s[0])
    a = s[0]
    c = format(i, '03b')
    for j in range(3):
        if c[j] == "0":
            a -= s[j+1]
            t += "-"+str(s[j+1])
        else:
            a += s[j+1]
            t += "+"+str(s[j+1])
    if a == 7:
        print(t+"=7")
        break

Solution (Python):
S = input()
ans = ""
for b in range(2**(3)):
    ans = ""
    for i,s in enumerate(S):
        ans += s
        if b & 1 << i:
            ans += "+"
        else:
            ans += "-"
    ans = ans[:-1]
    if eval(ans)==7:
        print("{}=7".format(ans))
        break

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

enzan = ["+","-"]

for a in enzan:
    for b in enzan:
        for c in enzan:
            ans = s[0] + a + s[1] + b + s[2] + c + s[3]
            if eval(ans) == 7:
                print(ans+"=7")
                exit()

Solution (Python):
def op(a,b,n):
  if n == 0:
    return a+b
  else:
    return a-b
def p(n):
  if n == 0:
    return '+'
  else:
    return '-'
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
for i in range(2):
  for j in range(2):
    for k in range(2):
      s1 = op(a,b,i)
      s2 = op(s1,c,j)
      tmp = op(s2,d,k)
      if tmp == 7:
        ans = str(a) + p(i) + str(b) + p(j) + str(c) + p(k) + str(d) +"=7"
        print(ans)
        exit()

Solution (Python):



from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

def pin(type=int):
    return map(type,input().split())
     


                
def resolve():
    a=list(input())
    A=["+","-"]
    temp=""
    for i in A:
        for j in A:
            for k in A:
                temp=a[0]+i+a[1]+j+a[2]+k+a[3]
                if eval(temp)==7:
                    print(temp+"=7")
                    return
        


"""


"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1222"""
        output = """1+2+2+2=7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """0290"""
        output = """0-2+9+0=7"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3242"""
        output = """3+2+4-2=7"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Solution (Python):
s = list(input())
a, b, c, d = map(int, s)
op = ['+', '+', '+']

sums = a + b + c + d

for i in range(2):
    for j in range(2):
        for k in range(2):
            if sums - (2 *b * i + 2* c * j + 2* d * k) == 7:
                if i == 1:
                    op[0] = '-'
                if j == 1:
                    op[1] = '-'
                if k == 1:
                    op[2] = '-'
                print('{}{}{}{}{}{}{}=7'.format(a, op[0], b, op[1], c, op[2], d))
                exit()

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

    formula = str(n[0])
    for op, num in zip(ops, n[1:]):
        formula += op + str(num)

    if eval(formula) == 7:  
        print(formula + "=7")
        exit()

Solution (Python):
import sys

A, B, C, D = list(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", sep="")
                sys.exit()

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

import math



def p_m(num):
  if math.floor(num)%2 == 0:
    return '+'
  else :
    return '-'

for i in range(8):
  if a + ( (-1)**(math.floor(i/4)) )*b + ((-1)**(math.floor(i/2)))*c + ((-1)**(math.floor(i)))*d == 7:

    break

print(str(a)+p_m(i/4)+str(b)+p_m(i/2)+str(c)+p_m(i)+str(d)+'=7')

Solution (Python):
import sys

A, B, C, D = list(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", sep="")
                sys.exit()

Solution (Python):
ABCD=input()
A=ABCD[0]
B=ABCD[1]
C=ABCD[2]
D=ABCD[3]
for i in range((len(ABCD)-1)**2):
    aida=["-"]*(len(ABCD)-1)
    for j in range(len(ABCD)-1):
        if ((i>>j)&1):
            aida[len(ABCD)-2-j]="+"
    ks=A+aida[0]+B+aida[1]+C+aida[2]+D
    if eval(ks)==7:
        print(ks+"=7")
        exit()

Solution (Python):
import sys

ABCD = input()
for n in range(2 ** (len(ABCD) - 1)):
    value = ""
    for i in range(len(ABCD) - 1):
        value += ABCD[i]
        if n & (2 ** i) != 0:
            value += "+"
        else:
            value += "-"
    value += ABCD[-1]
    if eval(value) == 7:
        print(value + "=7")
        sys.exit()

Solution (Python):
x=list(map(int,input()))
if x[0]+x[1]+x[2]+x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"+"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if x[0]-x[1]+x[2]+x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"+"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if x[0]-x[1]-x[2]+x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"-"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if  x[0]+x[1]-x[2]+x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"-"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if x[0]+x[1]+x[2]-x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"+"+str(x[2])+"-"+str(x[3])+"=7")
  exit()
if x[0]-x[1]+x[2]-x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"+"+str(x[2])+"-"+str(x[3])+"=7")
  exit()
if x[0]-x[1]-x[2]-x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"-"+str(x[2])+"-"+str(x[3])+"=7")
  exit()
if  x[0]+x[1]-x[2]-x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"-"+str(x[2])+"-"+str(x[3])+"=7")
  exit()

Solution (Python):
a = list(input())
op = ['-'] * 3
for i in range(2**3):
    ans = int(a[0])
    for j in range(3):
        if 1 & (i>>j):
            ans += int(a[3-j])
            op[2-j] = '+'
        else:
            ans -= int(a[3-j])
            op[2-j] = '-'
    if ans == 7:
        break
print(a[0] + op[0] + a[1] + op[1] + a[2] + op[2] +a[3] + "=7")

Solution (Python):
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = []

for i in range(2):
    for j in range(2):
        for k in range(2):
            if(A+B*op**i+C*op**j+D*op**k == 7):
                sign.append(i)
                sign.append(j)
                sign.append(k)

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "+"
    else:
        sign[n] = "-"

print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")

Solution (Python):



'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import sys
input = sys.stdin.readline

s = input()
a,b,c,d=[int(s[i]) for i in range(4)]
op = -1
ans = []
for i in range(2):
    for j in range(2):
        for m in range(2):
            if (a+b*op**i+c*op**j+d*op**m)==7:
                ans.append(i)
                ans.append(j)
                ans.append(m)
for i in range(3):
    if ans[i]==0:
        ans[i]="+"
    else:
        ans[i]="-"
print(s[0]+ans[0]+s[1]+ans[1]+s[2]+ans[2]+s[3]+"=7")

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


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

Solution (Python):
num = list(map(int,list(str(input()))))

for i in range(2**3):
  temp = 0
  
  for j in range(len(num)):
    if j == 0:
      temp = num[j]
      ans = str(num[j])
      continue
    
    if ((i >> j-1)&1):
      temp = temp + num[j]
      ans = ans + "+" + str(num[j])
      
    elif not ((i >> j-1)&1):
      temp = temp - num[j]
      ans = ans + "-" + str(num[j])
      
  if temp == 7:
    ans = ans + "=7"
    print(ans)
    break

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

op = ['-','+']
for i in range(8):
  o = format(i, '03b')
  if o[0] == str(0):
    s = a-b
  else:
    s = a+b
  if o[1] == str(0):
    s = s-c
  else:
    s = s+c
  if o[2] == str(0):
    s = s-d
  else:
    s = s+d
  if s == 7:
    print(str(a)+op[int(o[0])]+str(b)+op[int(o[1])]+str(c)+op[int(o[2])]+str(d)+'=7')
    break

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

if ns[0] + ns[1] + ns[2] + ns[3] == 7:
    print("{}+{}+{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] + ns[1] + ns[2] - ns[3] == 7:
    print("{}+{}+{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] + ns[1] - ns[2] + ns[3] == 7:
    print("{}+{}-{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] + ns[1] - ns[2] - ns[3] == 7:
    print("{}+{}-{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] + ns[2] + ns[3] == 7:
    print("{}-{}+{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] + ns[2] - ns[3] == 7:
    print("{}-{}+{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] - ns[2] + ns[3] == 7:
    print("{}-{}-{}+{}=7".format(ns[0], ns[1], ns[2], ns[3]))
elif ns[0] - ns[1] - ns[2] - ns[3] == 7:
    print("{}-{}-{}-{}=7".format(ns[0], ns[1], ns[2], ns[3]))