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

import itertools
import sys
sys.setrecursionlimit(10**6)

a, b, c, d = [int(i) for i in str(input())]

for i, j, k in itertools.product([1, -1], repeat=3):
    if a+b*i+c*j+d*k == 7:
        break

if i == 1:
    i = "+"
else:
    i = "-"
if j == 1:
    j = "+"
else:
    j = "-"
if k == 1:
    k = "+"
else:
    k = "-"

print("{}{}{}{}{}{}{}=7".format(a, i, b, j, c, k, d))

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



def calc(x,y,op):
    if op == '+':
        return x+y
    else:
        return x-y


op_l = ['+','-']
for op1 in op_l:
    for op2 in op_l:
        for op3 in op_l:
            x = calc(calc(calc(a,b,op1),c,op2),d, op3)
            if x == 7:
                ans = str(a)+op1+str(b)+op2+str(c)+op3+str(d)+"=7"
                break
print(ans)

Solution (Python):
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

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

Solution (Python):
s = input()

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

Solution (Python):
a, b ,c, d = input()
S = '+-'
for i in S:
    for j in S:
        for k in S:
            left = a + i + b + j + c + k + d
            if eval(left) == 7:
                print(left + '=7')
                exit()

Solution (Python):

def add(i, b):
    if i:
        return "-" + str(b)
    else:
        return "+" + str(b)
def main():
    S = input()
    a, b, c, d = int(S[0]), int(S[1]), int(S[2]), int(S[3])
    ans = ""
    for i in range(2):
        for j in range(2):
            for k in range(2):
                if a + (-1)**i * b + (-1)**j * c + (-1)**k * d == 7:
                    ans += str(a)
                    ans += add(i, b)
                    ans += add(j, c)
                    ans += add(k, d)
                    ans += "=7"
                    print(ans)
                    return
main()

Solution (Python):
S = list(map(int, list(input())))
ans = ""
for bit in range(2**3):
    temp = S[0]

    for i in range(3):

        if bit & (1<<i):
            temp +=S[i+1]
        else:
            temp -= S[i+1]

    if temp == 7:
        for i in range(3):
            ans += str(S[i])

            if bit & (1 << i):
                ans += "+"
            else:
                ans += "-"
        ans += str(S[3]) + "=7"
        print(ans)
        break

Solution (Python):


def main():
    S = list(input())

    for i in range(8):
        s = S[0]
        tmp = int(s)

        for j in range(3, 0, -1):
            t = S[4-j]
            if i & 1 << j - 1:
                tmp += int(t)
                s += '+' + t
            else:
                tmp -= int(t)
                s += '-' + t

        if tmp == 7:
            print(s, '=7', sep='')
            break

if __name__ == "__main__":
    main()

Solution (Python):
a,b,c,d=list(input())
a,b,c,d=int(a),int(b),int(c),int(d)
op=["+","-"]
for i in range(2):
  for j in range(2):
    for k in range(2):
      if i == 0:
        if j == 0:
          if k == 0:
            ans = a+b+c+d
          else:
            ans = a+b+c-d
        else:
          if k == 0:
            ans = a+b-c+d
          else:
            ans = a+b-c-d
      else:
        if j == 0:
          if k == 0:
            ans = a-b+c+d
          else:
            ans = a-b+c-d
        else:
          if k == 0:
            ans = a-b-c+d
          else:
            ans = a-b-c-d
      if ans == 7:
        print(str(a)+op[i]+str(b)+op[j]+str(c)+op[k]+str(d)+"=7")
        quit()

Solution (Python):









import os
import sys




def main():
    L = input()
    if int(L[0]) + int(L[1]) + int(L[2]) + int(L[3]) == 7:
        print("{}+{}+{}+{}=7".format(L[0], L[1], L[2], L[3]))

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

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

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

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

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

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

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




if __name__ == "__main__":
    main()

Solution (Python):
s = input()
for bit in range(1 << 3):
    f = s[0]
    ans = int(s[0])
    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i+1])
            f += "+"
        else:
            ans -= int(s[i+1])
            f += "-"
        f += s[i+1]
    if ans == 7:
        f += "=7"
        print(f)
        break

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

for i in range(2**(len(s)-1)):
    f =['']*(len(s)-1)
    siki=''
    for j in range(len(s)-1):
        if(i>>j & 1):
            f[j] = '+'
        else:
            f[j] = '-'
    for k in range(len(s)-1):
        siki += s[k] + f[k]
    siki += s[-1]
    if eval(siki)==7:
        siki += '=7'
        print(siki)
        break

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

def Calc(a,b,s):
  if s=='+':
    return a+b
  else:
    return a-b

for i in range(2**3):
    b=['+','+','+']
    for j in range(3):
        if (i >> j) & 1:
            b[j]='-'
    aplusb=Calc(int(li[0]),int(li[1]),b[0])
    abplusc=Calc(aplusb,int(li[2]),b[1])
    calc=Calc(abplusc,int(li[3]),b[2])
    
    if calc==7:
      print(str(li[0])+b[0]+str(li[1])+b[1]+str(li[2])+b[2]+str(li[3])+'=7')
      break

Solution (Python):
a, b, c, d = input()
op = [0] * 3

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

Solution (Python):
s = input()

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

Solution (Python):
import sys
a,b,c,d = input()
a,b,c,d = int(a),int(b),int(c),int(d)
op=["-","+"]
for i in op:
  for j in op:
    for k in op:
      if i=="-":
        now=a-b
      else:
        now=a+b
      
      if j=="-":
        now=now-c
      else:
        now=now+c
      
      if k=="-":
        now=now-d
      else:
        now=now+d
      
      if now==7:
        print(str(a)+i+str(b)+j+str(c)+k+str(d)+"="+"7")
        sys.exit()
      else:
        now=0

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):
s = input()
ans1=s[0]

def solve(i,tmp,ans):
  global ans1
  if i==3:
    if tmp==7:
      ans1=ans
      return True
    else:
      return False
  
  if solve(i+1,tmp+int(s[i+1]),ans+"+"+s[i+1]): return True
  if solve(i+1,tmp-int(s[i+1]),ans+"-"+s[i+1]): return True

if solve(0,int(s[0]),ans1):
  print(ans1+"=7")

Solution (Python):
lst = list(input())
for i,num in enumerate(lst):
    lst[i] = int(num)

if lst[0]+lst[1]+lst[2]+lst[3]==7:
    print(str(lst[0])+"+"+str(lst[1])+"+"+str(lst[2])+"+"+str(lst[3])+"=7")
elif lst[0]+lst[1]+lst[2]-lst[3]==7:
    print(str(lst[0])+"+"+str(lst[1])+"+"+str(lst[2])+"-"+str(lst[3])+"=7")
elif lst[0]+lst[1]-lst[2]+lst[3]==7:
    print(str(lst[0])+"+"+str(lst[1])+"-"+str(lst[2])+"+"+str(lst[3])+"=7")
elif lst[0]+lst[1]-lst[2]-lst[3]==7:
    print(str(lst[0])+"+"+str(lst[1])+"-"+str(lst[2])+"-"+str(lst[3])+"=7")
elif lst[0]-lst[1]+lst[2]+lst[3]==7:
    print(str(lst[0])+"-"+str(lst[1])+"+"+str(lst[2])+"+"+str(lst[3])+"=7")
elif lst[0]-lst[1]+lst[2]-lst[3]==7:
    print(str(lst[0])+"-"+str(lst[1])+"+"+str(lst[2])+"-"+str(lst[3])+"=7")
elif lst[0]-lst[1]-lst[2]+lst[3]==7:
    print(str(lst[0])+"-"+str(lst[1])+"-"+str(lst[2])+"+"+str(lst[3])+"=7")
elif lst[0]-lst[1]-lst[2]-lst[3]==7:
    print(str(lst[0])+"-"+str(lst[1])+"-"+str(lst[2])+"-"+str(lst[3])+"=7")

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

def calc(n, a, b):
  if n == 0:
    return a + b
  else:
    return a - b

pm = "+-"
for i in range(2):
  num = calc(i, a, b)
  for j in range(2):
    num2 = calc(j, num, c)
    for k in range(2):
      num3 = calc(k, num2, d)
      if num3 == 7:
        ans = str(a) + pm[i] + str(b) + pm[j] + str(c) + pm[k] + str(d) + "=7"
        print(ans)
        exit()

Solution (Python):
S = input()
N = len(S)
for i in range(2**(N-1)):
    sum = int(S[0])
    f = S[0]
    for j in range(N-1):
        if (i >> j) & 1:
            f += '+'
            sum += int(S[j+1])
        else:
            f += '-'
            sum -= int(S[j+1])
        f += S[j+1]
    
    if sum == 7:
        print('{}=7'.format(f))
        break

Solution (Python):
n = input()
N = [int(i) for i in n]
for i in range(8):
  n = format(i, '03b')
  ans = N[0]
  msg = str(N[0])
  for j in range(3):
    if n[j] == '0':
      ans += N[j+1]
      msg += '+' + str(N[j+1])
    else:
      ans -= N[j+1]
      msg += '-' + str(N[j+1])
  if ans == 7:
    print(msg + "=7")
    break

Solution (Python):
n = input()
N = [int(i) for i in n]
for i in range(8):
  n = format(i, '03b')
  ans = N[0]
  msg = str(N[0])
  for j in range(3):
    if n[j] == '0':
      ans += N[j+1]
      msg += '+' + str(N[j+1])
    else:
      ans -= N[j+1]
      msg += '-' + str(N[j+1])
  if ans == 7:
    print(msg + "=7")
    break

Solution (Python):
n = input()
N = [int(i) for i in n]
for i in range(8):
  n = format(i, '03b')
  ans = N[0]
  msg = str(N[0])
  for j in range(3):
    if n[j] == '0':
      ans += N[j+1]
      msg += '+' + str(N[j+1])
    else:
      ans -= N[j+1]
      msg += '-' + str(N[j+1])
  if ans == 7:
    print(msg + "=7")
    break

Solution (Python):

"""
Created on Mon Sep 21 23:12:36 2020

@author: liang
"""

"""
eval関数
入力 :　式
    eval("2+3")
出力 : 値
    5
"""
S = input()

ans = S[0]
for i in range(8):
    tmp = S[0]
    
    for j in range(3):
        if i>>j&1 == 1:
            tmp += "+" + S[j+1]
        else:
            tmp += "-" + S[j+1]
    
    
    if eval(tmp) == 7:
        
        ans = tmp
        ans += "=7"
        
        break
print(ans)

Solution (Python):


num = list(input())

op = ['+','-']

for op1 in op:
    if op1 == '+':
        res1 = int(num[0]) + int(num[1])
    else:
        res1 = int(num[0]) - int(num[1])
    for op2 in op:
        if op2 == '+':
            res2 = res1 + int(num[2])
        else:
            res2 = res1 - int(num[2])
        for op3 in op:
            if op3 == '+':
                res3 = res2 + int(num[3])
            else:
                res3 = res2 - int(num[3])

            if res3 == 7:
                ans = num[0]+op1+num[1]+op2+num[2]+op3+num[3]+"=7"
                print(ans)
                exit()

Solution (Python):

"""
Created on Mon Sep 21 22:53:14 2020

@author: liang
"""

S = input()

ans = S[0]

for i in range(8):
    tmp = int(S[0])
    lis = list()
    for j in range(3):
        lis.append(i>>j&1)
    for i in range(3):
        if lis[i] == 1:
            tmp += int(S[i+1])
        else:
            tmp -= int(S[i+1])
    
    if tmp == 7:
        for i in range(3):
            if lis[i] == 1:
                ans += "+" + S[i+1]
            else:
                ans += "-" + S[i+1]
        ans += "=7"
        break
    
else:
    print("err")
print(ans)

Solution (Python):
ABCD = input()

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

if 7 == A+B+C+D:
    print(f'{A}+{B}+{C}+{D}=7')
elif 7 == A+B+C-D:
    print(f'{A}+{B}+{C}-{D}=7')
elif 7 == A+B-C-D:
    print(f'{A}+{B}-{C}-{D}=7')
elif 7 == A-B-C-D:
    print(f'{A}-{B}-{C}-{D}=7')
elif 7 == A+B-C+D:
    print(f'{A}+{B}-{C}+{D}=7')
elif 7 == A-B-C+D:
    print(f'{A}-{B}-{C}+{D}=7')
elif 7 == A-B+C+D:
    print(f'{A}-{B}+{C}+{D}=7')
elif 7 == A-B+C-D:
    print(f'{A}-{B}+{C}-{D}=7')

Solution (Python):
def main():
	S = list(str(input()))
	LenP = 3
	ans = 0
	for i in range(2**LenP):
		P = ["-"]*LenP
		for j in range(LenP):
			if i >> j & 1:
				P[j] = "+"
		Res = [None] * (len(S)+len(P))
		Res[1::2],Res[::2] = P,S
		ResEval = "".join(Res)
		if eval(ResEval) == 7:
			ans = ResEval+"=7"
			print(ans)
			break

if __name__ == '__main__':
	main()

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


for i in range(2**(n-1)):
    val = l[0]
    for j in range(n - 1):
        if (i >> j)&1 == 0:
            val += '-'
        elif (i >> j)&1 == 1:
            val += '+'
        
        val += l[j + 1]
    
    num = eval(val)
    if num == 7:
        print(val + '=7')
        break

Solution (Python):
from itertools import permutations, combinations_with_replacement

def calc(op, x, y):
    if op == "+":
        return x + y
    else:
        return x - y

def solve():
    A, B, C, D = map(int, list(input()))
    OP = combinations_with_replacement(["+", "-"], 3)
    for op in OP:
        O = permutations(op)
        s = set(O)
        for o in s:
            op1, op2, op3 = o
            tmp = calc(op3, calc(op2, calc(op1, A, B), C), D)
            if tmp == 7:
                print(f"{A}{op1}{B}{op2}{C}{op3}{D}=7")
                exit()

if __name__ == "__main__":
    solve()

Solution (Python):
n=input()

for i in range(2 ** 3):
    

    co=["-","-","-"]

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

    eq=n[0]+co[0]+n[1]+co[1]+n[2]+co[2]+n[3]


    if eval(eq)==7:
            ans=eq

print(ans,end="")
print("=7")

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

for i in range(2**3+1):
  ans =[X[0]]
  for j in range(3):
    d = X[j+1]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()

Solution (Python):



from math import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














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


INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
abcd = input()
for bit in range(1 << 3):
    first = int(abcd[0])
    ans = abcd[0]
    for i in range(3):
        if bit & (1 << i):
            first += int(abcd[i+1])
            ans += '+'
            ans += abcd[i+1]
        else:
            first -= int(abcd[i+1])
            ans += '-'
            ans += abcd[i+1]
    if first == 7:
        print(ans + '=7')
        exit()

Solution (Python):
from itertools import product


A, B, C, D = list(input())
for x, y, z in product(["+", "-"], repeat=3):
    eqn = A + x + B + y + C + z + D
    if eval(eqn) == 7:
        print(f"{eqn}=7")
        break

Solution (Python):
x = list(map(str, input()))
for i in range(2**3):
  op = ["-","-","-"]
  for j in range(3):
    if (i & 1<<j):
      op[j] = "+"
  if eval(x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]) == 7:
    print(x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]+"=7")
    break

Solution (Python):
num = str(input())
op = ['+', '-']

for i in range(2**3):
    ans = int(num[0])
    t_op = []
    for j in range(3):
        if (i >> j)&1:
            ans -= int(num[j+1])
            t_op.append('-')
        else:
            ans += int(num[j+1])
            t_op.append('+')
    if ans == 7:
        ans_l = [num[0], t_op[0], num[1], t_op[1], num[2], t_op[2], num[3], '=7']
        print(*ans_l,sep='')
        break

Solution (Python):
ABCD = input()
for p in range(1 << 3):
    v = int(ABCD[0])
    ans = ABCD[0]
    for i in range(3):
        if p & (1 << i):
            v -= int(ABCD[i + 1])
            ans += '-' + ABCD[i + 1]
        else:
            v += int(ABCD[i + 1])
            ans += '+' + ABCD[i + 1]
    if v == 7:
        print(ans + '=7')
        exit()

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

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(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()
a, b, c, d = map(int, s)
A, B, C, D = map(str, s)
x = "=7"
if a + b + c + d == 7:
    print(A + "+" + B + "+" + C + "+"+D + x)
elif a - b + c + d == 7:
    print(A + "-" + B + "+" + C + "+"+D + x)
elif a + b - c + d == 7:
    print(A + "+" + B + "-" + C + "+"+D + x)
elif a + b + c - d == 7:
    print(A + "+" + B + "+" + C + "-" + D + x)
elif a - b - c + d == 7:
    print(A + "-" + B + "-" + C + "+" + D + x)
elif a - b + c - d == 7:
    print(A + "-" + B + "+" + C + "-" + D + x)
elif a + b - c - d == 7:
    print(A + "+" + B + "-" + C + "-" + D + x)
elif a - b - c - d == 7:
    print(A + "-" + B + "-" + C + "-" + D + x)

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

Solution (Python):
s = list(str(input()))
import itertools
for p in itertools.product(('+', '-'), repeat=3):
    temp = [0]*7
    for i in range(4):
        temp[2*i] = s[i]
    for i in range(3):
        temp[2*i+1] = p[i]
    
    temp = ''.join(temp)
    if eval(temp) == 7:
        print(temp+'=7')
        exit()

Solution (Python):

s=list(input())
a=s[0]
b=s[1]
c=s[2]
e=s[3]

for i in range(8):
    d=0
    x=[a,b,c,e]
    for j in range(3):
        if (i >> j)&1:
            x.insert(-j-1-d,'+')
            d+=1
        else:
            x.insert(-1-j-d,'-')
            d+=1
    q="".join(x)
    f=int(a)
    g=int(b)
    h=int(c)
    k=int(e)
    if q[1]=="-":
        g=-g
    if q[3]=="-":
        h=-h
    if q[5]=="-":
        k=-k
    if f+g+h+k==7:
        ans=q+"=7"
        print(ans)
        exit()

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

n = len(S)-1
for i in range(2 ** n):
    out = S[0]
    op = []
    for j in range(n):
        if (i>>j) & 1:
            out += S[j+1]
            op.append("+")
        else:
            out -= S[j+1]
            op.append("-")
    if out == 7:
        print(S[0], end='')
        for i in range(n):
            print(op[i], end='')
            print(S[i+1], end='')
        print("=7")
        exit()

Solution (Python):

import sys
num = input()

for i in range(2**3):
    ope = ''
    for j in range(3):
        if i >> j & 1:
            ope += '+'
        else:
            ope += '-'
    if eval(num[0]+ope[0]+num[1]+ope[1]+num[2]+ope[2]+num[3]) == 7:
        print(num[0]+ope[0]+num[1]+ope[1]+num[2]+ope[2]+num[3]+'=7')
        sys.exit()

Solution (Python):

numbers = list(map(int, list(input())))
seven="=7"

for i in range(1<<3):
    pms = []
    for j in range(3):
        if (i>>j)&1:
            pms.append(1)
        else:
            pms.append(0)
    result = numbers[0]
    result_str = str(numbers[0])
    for j, pm in enumerate(pms):
        j+=1
        if pm:
            result+=numbers[j]
            result_str+="+%d"%(numbers[j])
        else:
            result-=numbers[j]
            result_str+="-%d"%(numbers[j])
    if result==7:
        print(result_str+seven)
        break

Solution (Python):
S = input()
l = len(S) - 1
for i in range(2 ** l):
    op = ["-"] * l
    for j in range(l):
        if ((i >> j) & 1):
            op[l - 1 - j] = "+"
    formula = ""
    for j in range(l):
        formula+=S[j]
        if op[j]=="+":
            formula+="+"
        else:
            formula+="-"
    formula+=S[l]
    if eval(formula)==7:
        print(formula+"=7")
        break

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

Solution (Python):

abcd = input()
ABCD = []
for i in range(len(abcd)):
    ABCD.append(abcd[i])




for i in range(2**3):
    op = []

    
    for j in range(3):
        
        if ((i >> j) & 1):
            op.append("+")
        else:
            op.append("-")
    
    

    
    
    
    
    
    
    
    
    
    
    

    
    tmp = [None] * (len(ABCD)+len(op))
    
    tmp[::2] = ABCD
    tmp[1::2] = op
    
    
    
    ans = ""
    for i in tmp:
        ans += i
    
    if eval(ans) == 7:
        print(ans + "=7")
        exit()

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




for i in range(2**3):
  ans = int(X[0])
  list = []
  for j in range(3):
    if (i>>j & 1) == 1:
      ans += int(X[j+1])
      list.append("+")
    else:
      ans -= int(X[j+1])
      list.append("-")
  if ans == 7:
    break

ans = X[0]
for i in range(3):
  ans += list[i]
  ans += X[i+1]
print(ans+"=7")

Solution (Python):
a, b, c, d = [c for c in input()]
candids = []
for i in range(8):
    candid = []
    for k in range(3):
        if i >> k & 1 > 0:
            candid.append("+")
        else:
            candid.append("-")
        
    candids.append(candid)

for op1, op2, op3 in candids:
    if eval(a+op1+b+op2+c+op3+d) == 7:
        print (a+op1+b+op2+c+op3+d+"=7")
        break

Solution (Python):
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),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")
  
else:
  print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")

Solution (Python):


A = input()
n = len(A)-1
for i in range(2**n):
  pn = ['-']*n
  for j in range(n):
    if ((i>>j)&1):
      pn[n-1-j] = '+'
  ans = A[0]+pn[0]+A[1]+pn[1]+A[2]+pn[2]+A[3]
  
  if eval(ans) == 7:
    print(ans+'=7')
    break

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

for x in range(2**3):
    ans = p[0]
    for y in range(3):
        if (x>>y)&1:
            ans += p[y+1]
        else:
            ans -= p[y+1]
    if ans == 7:
        kotae = format(x,"

kotae = kotae[2:]
for z in range(3):
    print(str(p[z]),end="")
    if kotae[-z-1] == str(1):
        print("+",end="")
    else:
        print("-",end="")

print(str(p[3]) + "=7" )

Solution (Python):
ABCD = input().strip()
for i in range(8):
    ope = [{0:'+', 1:'-'}[(i>>j) & 1] for j in range(3)]
    fomula = ABCD[0] + ope[0] + ABCD[1] + ope[1] + ABCD[2] + ope[2] + ABCD[3]
    if eval(fomula) == 7:
        print(f'{fomula}=7')
        break

Solution (Python):
s = input()


for i in range(1 << 3):
    count = int(s[0])
    for j in range(1, 4):
        if i & (1 << j-1):
            count+=int(s[j])
        else:
            count-=int(s[j])
    
    if count == 7:
        ans = s[0] 
        for j in range(1, 4):
            if i & (1 << j-1):
                ans += '+'+s[j]
            else:
                ans += '-'+s[j]

        ans += '=7'
        print(ans)
        exit()

Solution (Python):
A = input()
n = len(A)-1
for i in range(2**n):
  pn = ['-']*n
  for j in range(n):
    if ((i>>j)&1):
      pn[n-1-j] = '+'
  ans = A[0]+pn[0]+A[1]+pn[1]+A[2]+pn[2]+A[3]
  
  if eval(ans) == 7:
    print(ans+'=7')
    break

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

a, b, c, d = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[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()
n = len(s)

for bit in range(1 << (n -1)):

    f = s[0]

    for i in range(n -1):
        if bit & (1 << i):
            f += '+'
        else:
            f += '-'
        f += s[i + 1]

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

Solution (Python):
import sys
input = sys.stdin.readline

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

ans = ''
for i in range(2):
    if ans != '':
        break
    for j in range(2):
        if ans != '':
            break
        for k in range(2):
            t = A + (2*i-1)*B + (2*j-1)*C + (2*k-1)*D
            if t == 7:
                op1 = '-' if i == 0 else '+'
                op2 = '-' if j == 0 else '+'
                op3 = '-' if k == 0 else '+'
                ans = "{}{}{}{}{}{}{}=7".format(A,op1,B,op2,C,op3,D)
                break

print(ans)

Solution (Python):
num = str(input())
a = num[0]
b = num[1]
c = num[2]
d = num[3]
plus = ["+", "+", "+"]
minus = ["-", "-", "-"]
for i in range(2**3):
    key = []
    for j in range(3):
        if ((i>>j) &1):
            key.append("+")
        else:
            key.append("-")
    ans = a + key[0] + b + key[1] + c + key[2] + d
    if eval(ans) == 7:
        print(ans + "=7")
        break

Solution (Python):
tmp=input()
solution=7
numbers=[]
for i in range(len(tmp)):
    numbers.append(int(tmp[i]))

n = len(numbers)
for i in range(n ** 2):
    ops = ["-"] * (n-1)
    for j in range(n-1):
        if ((i>>j) & 1):
            ops[n-1-j-1]="+"
    
    shiki = str(numbers[0])
    for j in range(n-1):
        shiki = shiki + ops[j] + str(numbers[j+1])
    
    if int(eval(shiki)) == int(solution):
        print(shiki+"="+str(solution))
        break

Solution (Python):

import sys

ops = [
        ['+', '+', '+'],
        ['+', '+', '-'],
        ['+', '-', '+'],
        ['+', '-', '-'],
        ['-', '+', '+'],
        ['-', '+', '-'],
        ['-', '-', '+'],
        ['-', '-', '-'],
        ]


def solve(ABCD: str):
    a = int(ABCD[0])
    b = int(ABCD[1])
    c = int(ABCD[2])
    d = int(ABCD[3])
    for i in range(8):
        t = a
        if ops[i][0] == "+":
            t += b
        else:
            t -=b
        if ops[i][1] == "+":
            t += c
        else:
            t -=c
        if ops[i][2] == "+":
            t += d
        else:
            t -=d
        if t == 7:
            print(f"{a}{ops[i][0]}{b}{ops[i][1]}{c}{ops[i][2]}{d}=7")
            break

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    ABCD = next(tokens)  
    solve(ABCD)

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import combinations

s = input()

ans = ['-','-','-']
for i in range(4):
    for comb in combinations(range(3),i):
        temp = int(s[0])
        for j in range(3):
            if j in comb:
                temp += int(s[j+1])
            else:
                temp -= int(s[j+1])
        if temp==7:
            for j in comb:
                ans[j] = "+"
            break 
print("{a}{op1}{b}{op2}{c}{op3}{d}=7".format(a=s[0],op1=ans[0],b=s[1],op2=ans[1],c=s[2],op3=ans[2],d=s[3]))

Solution (Python):





def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c, d = [int(x) for x in input().rstrip()]

    for o1 in [True, False]:
        for o2 in [True, False]:
            for o3 in [True, False]:
                ans = a
                ans += b if o1 else -b
                ans += c if o2 else -c
                ans += d if o3 else -d

                if ans == 7:
                    s = str(a)
                    s += "+" if o1 else "-"
                    s += str(b)
                    s += "+" if o2 else "-"
                    s += str(c)
                    s += "+" if o3 else "-"
                    s += str(d)
                    s += "=7"

                    print(s)
                    return


if __name__ == "__main__":
    resolve()

Solution (Python):
A=list(input())
for i in range(4):
    A[i]=int(A[i])
for i in range(8):
    x=A[0]
    for j in range(3):
        if (i//(2**j))%2==1:
            x+=A[j+1]
        else:
            x-=A[j+1]
    if x==7:
        print(A[0],end='')
        for j in range(3):
            if (i//(2**j))%2==1:
                print('+',end='')
            else:
                print('-',end='')
            print(A[j+1],end='')
        print('=7')
        break