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

def read_input():
    s = input()
    a, b, c, d = map(int, [c for c in s])

    return a, b, c, d


def check_formulae(a, b, c, d):
    if a + b + c + d == 7:
        print('{}+{}+{}+{}=7'.format(a,b,c,d))
        return
    if a + b + c - d == 7:
        print('{}+{}+{}-{}=7'.format(a,b,c,d))
        return
    if a + b - c + d == 7:
        print('{}+{}-{}+{}=7'.format(a,b,c,d))
        return
    if a + b - c - d == 7:
        print('{}+{}-{}-{}=7'.format(a,b,c,d))
        return
    if a - b + c + d == 7:
        print('{}-{}+{}+{}=7'.format(a,b,c,d))
        return
    if a - b + c - d == 7:
        print('{}-{}+{}-{}=7'.format(a,b,c,d))
        return
    if a - b - c + d == 7:
        print('{}-{}-{}+{}=7'.format(a,b,c,d))
        return
    if a - b - c - d == 7:
        print('{}-{}-{}-{}=7'.format(a,b,c,d))
        return
    return


def submit():
    a, b, c, d = read_input()
    check_formulae(a, b, c, d)

if __name__ == '__main__':
    submit()

Solution (Python):
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
ans_list = []
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, B, C, D = list(input())

for op1 in "+-":
    for op2 in "+-":
        for op3 in "+-":
            S = A + op1 + B + op2 + C + op3 + D
            if eval(S) == 7:
                print(S + "=7")
                quit()

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

for i in range(8):
    op1 = "+" if i & 1 else "-"
    op2 = "+" if i & 2 else "-"
    op3 = "+" if i & 4 else "-"
    S = A + op1 + B + op2 + C + op3 + D
    if eval(S) == 7:
        print(S + "=7")
        quit()

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

for i in range(8):
    op1 = "+" if i & 1 else "-"
    op2 = "+" if i & 2 else "-"
    op3 = "+" if i & 4 else "-"
    S = "{}{}{}{}{}{}{}".format(A, op1, B, op2, C, op3, D)
    if eval(S) == 7:
        print(S + "=7")
        quit()

Solution (Python):

s = input()
op = []
oplist = []
cnt = len(s) - 1

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

for i in range(2**cnt):
    ans = int(s[0:1])
    for j in range(cnt):
        if oplist[i][j] == '+':
            ans += int(s[j+1:j+2])
        else:
            ans -= int(s[j+1:j+2])
    if ans == 7:
        print(s[0], end='')
        for k in range(cnt):
            print(oplist[i][k] + s[k+1:k+2], end='')
        print('=7')
        break

Solution (Python):
from itertools import product
S = input()

for string in product(["+","-"],repeat = 3):
    string = list(string)
    string.append("")
    sum_ = [a + b for a,b in zip(S,string)]
    if eval("".join(sum_)) == 7:
        print("".join(sum_)+"=7")
        break

Solution (Python):
def BitArrFromInt(i):
    arr = []
    quotient = i
    for ind in range(3):
        arr.append(quotient % 2)
        quotient /= 2
    return arr

def OpeStrFromBit(i):
    return '+' if i == 0 else '-'


def solve():
    S = raw_input()
    
    for i in range (2**3):
        bit_arr = BitArrFromInt(i)
        sum = int(S[0])
        for j in range (3):
            sum += (int(S[j+1]) if bit_arr[j] == 0 else -int(S[j+1]))
            
        if sum == 7:
            print S[0] + OpeStrFromBit(bit_arr[0]) + S[1] + \
                OpeStrFromBit(bit_arr[1]) + S[2] + OpeStrFromBit(bit_arr[2]) + S[3]+ '=7'
            break

if __name__ == '__main__':
    solve()

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 - j - 1] = "-"
    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n+p_o)
    if eval(formula) == 7:
        break

print(formula + "=7")

Solution (Python):
from itertools import product


def main():
    abcd = input()

    for op in product(["+", "-"], repeat=3):
        op = list(op)
        op.append("")
        expr = ''.join(a + b for a, b in zip(abcd, op))
        if eval(expr) == 7:
            print(expr, '=7', sep='')
            break


if __name__ == '__main__':
    main()

Solution (Python):
A,B,C,D = map(int,list(input()))
def main(A,B,C,D):
    for i in range(2):
        ans1 =0
        if i == 0:
            ans1 = A + B
            s1 ='+'
        else:
            ans1 = A - B
            s1 ='-'
        for j in range(2):
            ans2 = 0
            if j == 0:
                ans2 = ans1 + C
                s2 ='+'
            else:
                ans2 = ans1 - C
                s2 ='-'
            for k in range(2):
                ans3 = 0
                if k == 0:
                    ans3 = ans2 + D
                    s3 ='+'
                else:
                    ans3 = ans2 - D
                    s3 ='-'
                if ans3 == 7:
                    print(str(A)+s1+str(B)+s2+str(C)+s3+str(D)+"=7")
                    return
main(A,B,C,D)

Solution (Python):
S = input()

s = []
for c in S:
    s.append(c)

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

    operator.append(op)

F = []
for op in operator:
    f = "".join(a+b for a, b in zip(s,op))
    F.append(f)


for fm in F:
    if eval(fm)==7:
        print(fm + '=7')
        break

Solution (Python):
ABCD = list(input())
lst = [int(i) for i in ABCD]



def judge(x):
    if lst[0]+lst[1]+lst[2]+lst[3]==7:
        return '+ + +'
    elif lst[0]+lst[1]+lst[2]-lst[3]==7:
        return '+ + -'
    elif lst[0]+lst[1]-lst[2]+lst[3]==7:
        return '+ - +'
    elif lst[0]+lst[1]-lst[2]-lst[3]==7:
        return '+ - -'
    elif lst[0]-lst[1]+lst[2]+lst[3]==7:
        return '- + +'
    elif lst[0]-lst[1]+lst[2]-lst[3]==7:
        return '- + -'
    elif lst[0]-lst[1]-lst[2]+lst[3]==7:
        return '- - +'
    elif lst[0]+lst[1]-lst[2]-lst[3]==7:
        return '- - -'


lst2 = list(judge(lst).split())

ans = str(lst[0])+lst2[0]+str(lst[1])+lst2[1]+str(lst[2])+lst2[2]+str(lst[3])+'=7'

print (ans)

Solution (Python):
s = 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")
    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):
ABCD = input()

def calc(calc_str):
    tmp = ""
    x, y = 0, 0
    calc_str = "0+" + calc_str
    for i in calc_str:
        if i == "+":
            tmp = i
        elif i == "-":
            tmp = i
        else:
            y = int(i)
            if tmp == "+":
                x = x + y
            elif tmp == "-":
                x = x - y
    return x

def create(A):
    for i in ("+", "-"):
        for t in ("+", "-"):
            for k in ("+", "-"):
                calc_str = A[0] + i + A[1] + t + A[2] + k + A[3]
                if calc(calc_str) == 7:
                    print(calc_str+"=7")
                    return

create(ABCD)

Solution (Python):
S = input()
for i in range(8) :
    a = []
    b = int(S[0])
    c = 0
    for j in range(3) :
        if (i>>j) & 1 :
            b += int(S[j+1])
            a.append('+')
        else :
            b -= int(S[j+1])
            a.append('-')
    if b == 7 :
        print(S[0]+a[0]+S[1]+a[1]+S[2]+a[2]+S[3]+'=7')
        break

Solution (Python):

X = input() 
n = 8
op =[0 for i in range(3)]
for i in range(n):
  p = bin(i)[2:]
  p = "0"*(3-len(p))+p
  Y =""
  for j,k in enumerate(X):
    Y +=k
    if j < 3:
      if p[j:j+1] =="0":
        Y +="+"
      else:
        Y +="-"
  ans = eval(Y)
  if ans ==7:
    print(Y+"=7")
    break

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

Solution (Python):


import sys
import math


S = list(str(input()))


def calc(en):
  if len(en) != 3:
    return 0
  else:
    ret = int(S[0])
    for i in range(len(en)):
      if en[i] == "+":
        ret += int(S[i+1])
      else:
        ret -= int(S[i+1])
    return ret


def solve(i, en):
  if i == 4:
    if calc(en) == 7:
      return en
    else:
      return ""

  ret = max("", solve(i+1, en+"+"), solve(i+1, en+"-"))
  return ret


if __name__ == "__main__":
  en = solve(1, "")
  print(S[0]+en[0]+S[1]+en[1]+S[2]+en[2]+S[3]+"=7")

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

for i in range(1 << 3):
    check = int(S[0])
    for j in range(3):
        if i & (1<<j):
            check += int(S[j+1])
        else:
            check -= int(S[j+1])
    if check == 7:
        ans = S[0]
        for j in range(3):
            if i & (1<<j):
                ans += '+' + S[j+1]
            else:
                ans += '-' + S[j+1]
        break

ans += '=7'

print(ans)

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

MINUS = '-'
PLUS = '+'

def cal(a,b, what):
    if what == MINUS:
        return a - b
    else:
        return a+b


def print_ans(v):
    print('{}{}{}{}{}{}{}=7'.format(A,v[0],B,v[1],C,v[2],D))
    
    
li = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            op1 = PLUS if i %2==0 else MINUS
            op2 = PLUS if j %2==0 else MINUS
            op3 = PLUS if k %2==0 else MINUS
            li.append([op1, op2, op3])

for v in li:
    t = cal(A, B, v[0])
    t = cal(t, C, v[1])
    t = cal(t, D, v[2])
    if t == 7:
        print_ans(v)
        break

Solution (Python):
import operator
S = input()
nums = []
for s in S:
    nums.append(int(s))

ope = {'+': operator.add, '-': operator.sub}
idx = {0:'+', 1:'-'}
for i in range(2):
    ans1 = ope[idx[i]](nums[0], nums[1])
    for j in range(2):
        ans2 = ope[idx[j]](ans1, nums[2])
        for k in range(2):
            if ope[idx[k]](ans2, nums[3]) == 7:
                print(str(nums[0])+idx[i]+str(nums[1])+idx[j]+str(nums[2])+idx[k]+str(nums[3])+'=7')
                quit()

Solution (Python):
def find(abcd):
    a, b, c, d = abcd
    ops = ['{}{}{}'.format(i, j, k)
           for i in [1, 2] for j in [1, 2] for k in [1, 2]]
    opr = {'1': '+', '2': '-'}

    for op in ops:
        expression = a + opr[op[0]] + b + opr[op[1]] + c + opr[op[2]] + d
        try:
            if eval(expression) == 7:
                return(expression)
        except SyntaxError:
            pass


def main():
    abcd = input()
    print('{}=7'.format(find(abcd)))


main()

Solution (Python):
ABCD = input()

for i in range(2 ** 3):
    ans = int(ABCD[0])
    pm = []
    for j in range(3):
        if (i >> j) & 1:
            ans += int(ABCD[j+1])
            pm.append("+")
        else:
            ans -= int(ABCD[j+1])
            pm.append("-")
    if ans == 7:
        print("{}{}{}{}{}{}{}=7".format(ABCD[0], pm[0], ABCD[1], pm[1], ABCD[2], pm[2], ABCD[3]))
        break

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

x = list(input())
del(x[4])
x = [int(i) for i in x]

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()
elif x[0]-x[1]+x[2]+x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '+' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]+x[1]-x[2]+x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '-' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]+x[1]+x[2]-x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '+' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()
elif x[0]-x[1]-x[2]+x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '-' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]+x[1]-x[2]-x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '-' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()
elif x[0]-x[1]+x[2]-x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '+' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()
elif 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):
strtick = input()
inttick = [int(i) for i in strtick]

for i in range(2**3):
  ans = inttick[0]
  op = ["-"]*3 
  for j in range(3):
    if (i >> j) & 1:
      ans += inttick[j+1]
      op[j] = "+"
    else:
      ans -= inttick[j+1]

  if ans == 7:
    print(inttick[0], op[0], inttick[1], op[1], inttick[2], op[2], inttick[3], "=7", sep="")
    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
    result = eval(formula)
    if result == 7:
        print(formula + '=7')
        break

Solution (Python):
I = input()
for param in range(2**(len(I)-1)):
    ans = ""
    for i in range(len(I)):
        ans += I[i] + ["+","-",""][((param >> i) & 1) if i != len(I) - 1 else 2]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Solution (Python):
i=input()
b=True
while b==True:
  if int(i[0])+int(i[1])+int(i[2])+int(i[3])==7:
    print(i[0]+"+"+i[1]+"+"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])+int(i[1])+int(i[2])-int(i[3])==7:
    print(i[0]+"+"+i[1]+"+"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])+int(i[1])-int(i[2])-int(i[3])==7:
    print(i[0]+"+"+i[1]+"-"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])+int(i[2])-int(i[3])==7:
    print(i[0]+"-"+i[1]+"+"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])-int(i[2])-int(i[3])==7:
    print(i[0]+"-"+i[1]+"-"+i[2]+"-"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])+int(i[1])-int(i[2])+int(i[3])==7:
    print(i[0]+"+"+i[1]+"-"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])+int(i[2])+int(i[3])==7:
    print(i[0]+"-"+i[1]+"+"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False
  elif int(i[0])-int(i[1])-int(i[2])+int(i[3])==7:
    print(i[0]+"-"+i[1]+"-"+i[2]+"+"+i[3]+"="+"7")
    exit
    b=False

Solution (Python):
s = input()
space = len(s) - 1
ans = 0

for i in range(2 ** space):
    formula = s[0]
    for j in range(space):
        if (i >> j) & 1:
            formula += "+"
        else:
            formula += "-"
        formula += s[j + 1]
    if eval(formula) == 7:
        print("{}=7".format(formula))
        break

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

p=["+","+","+","+","-","-","-","-"]
q=["+","+","-","-","+","+","-","-"]
r=["+","-","+","-","+","-","+","-"]
for i,j,k in zip(p,q,r):
    ans=a
    if i=="+":
        ans+=b
    else:
        ans-=b
    if j=="+":
        ans+=c
    else:
        ans-=c
    if k=="+":
        ans+=d
    else:
        ans-=d
    if ans==7:
        print("{}{}{}{}{}{}{}=7".format(str(a),i,str(b),j,str(c),k,str(d)))
        break

Solution (Python):
s=input()
m=["+","-"]
for i in m:
    for j in m:
        for k in m:
            a=s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(a)==7:
                print(a+"=7")
                break
        else:continue
        break
    else:continue
    break

Solution (Python):


S = input()
t = len(S)-1

for i in range(2**t):
    p = bin(i)[2:]
    p = "0"*(t - len(p))+p  

    x = ""
    for j, k in enumerate(S):
        x += k
        if j != t and p[j] == "1":
            x += "+"
        elif j != t and p[j] == "0":
            x += "-"

    if eval(x) == 7:
        print("{0}=7".format(x))
        exit()

Solution (Python):
import sys, ast

def dfs(str_input,count = 1):
    if count == 7:
        if ast.literal_eval(str_input) == 7:
            print(str_input + "=7")
            sys.exit(0)
        else:
            return 0
    for i in ["+","-"]:
        dfs(str_input[:count] + i + str_input[count:], count = count + 2)

x = input()

dfs(x)

Solution (Python):
s = input()
space = len(s) - 1

for i in range(2 ** space):
    f = s[0]
    for j in range(space):
        f += "+" if (i >> j) & 1 else "-"
        f += s[j + 1]

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

Solution (Python):
from itertools import product
ABCD = list(input())
ops = ['+', '-']

for op in list(product(ops, ops, ops)) :
    if eval(ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2] + ABCD[3]) == 7 :
        print(str(ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2] + ABCD[3])+'=7')
        break

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


def D2NC(D: int, N: int) -> list:
    res = []
    while D > 0:
        res.insert(0, D % N)
        D //= N
    if not res:
        res.append(0)
    res = [str(i) for i in res]
    return res


for i in range(2**3):
    pattern = ''.join(D2NC(i, 2)).zfill(3)
    ans = ABCD[0]
    idx = 0
    op = []
    for j in pattern:
        if j == '0':
            ans += ABCD[idx+1]
            op.append('+')
        else:
            ans -= ABCD[idx+1]
            op.append('-')
        idx += 1
    if ans == 7:
        break

A, B, C, D = ABCD
op_1, op_2, op_3 = op
print('{}{}{}{}{}{}{}=7'.format(A, op_1, B, op_2, C, op_3, D))

Solution (Python):
import sys
input = sys.stdin.readline
 
abc = input()
 
OP = ['+','-']
ans = 0
for op1 in OP:
    for op2 in OP:
        for op3 in OP:
            if eval(abc[0]+op1+abc[1]+op2+abc[2]+op3+abc[3]) == 7:
                ans = abc[0]+op1+abc[1]+op2+abc[2]+op3+abc[3]
print(ans+'=7')

Solution (Python):
s=input()
for i in range(8):
    y="".join([s[k]+"+-"[i>>k&1]for k in range(3)]+[s[-1]])
    if eval(y)==7:
        print(y+"=7")
        exit()

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    INF = float("inf")
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    S = list(_ for _ in input())
    e= ''
    for i in range(2**3):
        e=S[0]
        for j in range(0,3):
            if 1<<j & i:
                e+='+'
            else:
                e+='-'
            e+=S[j+1]
        if eval(e) == 7:
            e+='=7'
            break
    print(e)
if __name__ == '__main__':
    main()

Solution (Python):

S = [i for i in list(input())]

for i in range(2**(len(S)-1)):
  ops = [S[0]]
  for j in range(len(S)-1):
    if (i >> j) & 1:
      ops.append("+")
      ops.append(S[j+1])
    else:
      ops.append("-")
      ops.append(S[j+1])
      
  expr = "".join(ops)
  if eval(expr) == 7:
    print(expr + "=7")
    break

Solution (Python):
A, B, C, D = [int(i) for i in input()]
for i in "+-":
    for j in "+-":
        for k in "+-":
            ans = A + B if i == "+" else A - B
            ans = ans + C if j == "+" else ans - C
            ans = ans + D if k == "+" else ans - D
            if ans == 7:
                print(str(A) + i + str(B) + j + str(C) + k + str(D) + "=7")
                exit()

Solution (Python):
abcd = input()

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

counter = 0
if a - b - c - d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a - b - c + d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    counter += 1

if a - b + c - d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a - b + c + d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    counter += 1

if a + b - c - d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a + b - c + d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    counter += 1

if a + b + c - d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a + b + c + d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    counter += 1

Solution (Python):
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ans = []
for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            if a + b * i + c * j + d * k == 7:
                ans = [i,j,k]
                break
print(a,end="")
print('+' if ans[0] == 1 else '-',end="")
print(b,end="")
print('+' if ans[1] == 1 else '-',end="")
print(c,end="")
print('+' if ans[2] == 1 else '-',end="")
print(d,end="=7\n")

Solution (Python):
Astr = input()
Aint = [0]*4
for i in range(4):
  Aint[i] = int(Astr[i])
q = [1,1,1]
ans = 7-Aint[0]

while sum(q) != -3:
  a = [0]*3
  for i in range(3):
    a[i] = Aint[i+1]*q[i]
  if sum(a) == ans:
    print(str(Aint[0])+"{:+}{:+}{:+}".format(a[0],a[1],a[2])+"=7")
    break
  elif q[2] == 1:
    q[2] = -1
  elif q[1] == 1:
    q[1] = -1
    q[2] = 1
  else:
    q[0] = -1
    q[1] = 1
    q[2] = 1

Solution (Python):
s = str(input())
n = len(s)-1

for i in range(2**n):
  op = ['-']*n
  for j in range(n):
    if (i >> j) & 1:
      op[j] = '+'

  formula = ''
  op = op + ['']
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  if eval(formula) == 7:
      print(formula+'=7')
      exit()

Solution (Python):
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] = '+'

  formula = ''
  op = op + ['']
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  if eval(formula) == 7:
      print(formula+'=7')
      exit()

Solution (Python):
a,b,c,d=map(str,input())
p=['+','-']
for i in p:
    for j in p:
        for x in p:
            s=a+i+b+j+c+x+d
            if eval(s)==7:
                print(s+'=7')
                exit()

Solution (Python):
def dfs(s,plus,i):

    i += 1

    if i == 4:
        ans = int(s[0])
        for j in range(1,4):
            ans += int(s[j])*plus[j-1]
        if ans == 7:
            ret = s[0]
            for k in range(1,4):
                if plus[k-1] == 1:
                    ret += '+'
                else:
                    ret += '-'
                ret += s[k]
            ret += '=7'
            print(ret)
            exit()
        return

    plus[i-1] = 1
    dfs(s, plus, i)

    plus[i-1] = -1
    dfs(s, plus, i)

    return


dfs(input(), [0,0,0], 0)

Solution (Python):
s=input()
for i in range(2**3):
  b=bin(i)[2:].zfill(3)
  a=s[0]
  for i in range(3):a+=("+"if b[i]=="0"else"-")+s[i+1]
  if eval(a)==7:print(a+"=7");exit()

Solution (Python):
import itertools

num_list = input()
rule = '+-'

for ops in itertools.product(rule, repeat=3):
    ans = '{}{}{}{}{}{}{}'.format(num_list[0], ops[0], num_list[1], ops[1], num_list[2], ops[2], num_list[3])
    res = eval(ans)
    if res == 7:
        print('{}=7'.format(ans))
        break

Solution (Python):
s=str(input())
n1=int(s[0])
n2=int(s[1])
n3=int(s[2])
n4=int(s[3])
sum1=0
sum2=0
sum3=0
ans=''
op=['+','-']
for i in range(2):
  if i == 0:
    sum1 = n1+n2
  else:
    sum1 = n1-n2
  for j in range(2):
    if j == 0:
      sum2 = sum1+n3
    else:
      sum2 = sum1-n3
    for k in range(2):
      if k == 0:
        sum3=sum2+n4
      else:
        sum3=sum2-n4
      if sum3==7:
        ans=str(n1)+op[i]+str(n2)+op[j]+str(n3)+op[k]+str(n4)+'=7'
print(ans)

Solution (Python):
N = input()
A, B, C, D = int(N[0]), int(N[1]), int(N[2]), int(N[3])
OP = ["+", "-"]

ANS = 0
flg = False


for op1 in OP:
    if flg is True:
        break
    ANS = A
    if op1 == "+":
        ANS = ANS + B
    else:
        ANS = ANS - B
    for op2 in OP:
        if flg is True:
            break
        ANS2 = ANS
        if op2 == "+":
            ANS2 = ANS + C
        else:
            ANS2 = ANS - C
        for op3 in OP:
            ANS3 = ANS2
            if op3 == "+":
                ANS3 = ANS2 + D
            else:
                ANS3 = ANS2 - D
            if ANS3 == 7:
                print("%d%s%d%s%d%s%d=7" % (A, op1, B, op2, C, op3, D))
                flg = True
                break

Solution (Python):
from collections import deque
A,B,C,D = list(input())

dq = deque()
dq.append("")
while dq:
    op = dq.pop()
    if len(op) == 3:
        res = A + op[0] + B + op[1] + C + op[2] + D
        if eval(res) == 7:
            ans = res + "=7"
            print(ans)
            break
    else:
        dq.append(op+"+")
        dq.append(op+"-")

Solution (Python):
from collections import deque
A,B,C,D = list(input())

dq = deque()
dq.append("")
while dq:
    op = dq.popleft()
    if len(op) == 3:
        res = A + op[0] + B + op[1] + C + op[2] + D
        if eval(res) == 7:
            ans = res + "=7"
            print(ans)
            break
    else:
        dq.append(op+"+")
        dq.append(op+"-")

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

def dfs(depth=0,op=""):
    if depth == 3:
        res = A + op[0] + B + op[1] + C + op[2] + D
        if eval(res) == 7:
            ans = res + "=7"
            print(ans)
            exit()
        return
    dfs(depth+1,op+"+")
    dfs(depth+1,op+"-")

dfs()

Solution (Python):
a = input()
x,  y,  z,  b=int(a[0]),  int(a[1]),  int(a[2]),  int(a[3])
if x+y+z+b==7:
    print("{}+{}+{}+{}=7".format(x, y, z, b))
elif x-y-z-b==7:
    print("{}-{}-{}-{}=7".format(x, y, z, b))
elif x+y+z-b==7:
    print("{}+{}+{}-{}=7".format(x, y, z, b))
elif x+y-z+b==7:
    print("{}+{}-{}+{}=7".format(x, y, z, b))
elif x-y+z+b==7:
    print("{}-{}+{}+{}=7".format(x, y, z, b))
elif x+y-z-b==7:
    print("{}+{}-{}-{}=7".format(x, y, z, b))
elif x-y-z+b==7:
    print("{}-{}-{}+{}=7".format(x, y, z, b))
else:
    print("{}-{}+{}-{}=7".format(x, y, z, b))

Solution (Python):


S = input()
ans = 0
for i in range(1 << len(S)): 
    string = str(0)
    tmp = 0
    enzan = []
    for j in range(len(S)):
        if ((i >> j) & 1) == 1:
            tmp+=int(S[j])
            enzan.append("+")
        else:
            tmp -= int(S[j])
            enzan.append("-")
    
    if tmp == 7:
        
        print(S[0]+enzan[1]+S[1]+enzan[2]+S[2]+enzan[3]+S[3]+"=7")
        exit()

Solution (Python):
import sys
from sys import stdin
abcd = [int(c) for c in list(stdin.readline().rstrip())]
op = ['+', '-']
for i in op:
    for j in op:
        for k in op:
            result=abcd[0]
            if i == '+':
                result+=abcd[1]
            else:
                result-=abcd[1]
            if j == '+':
                result+=abcd[2]
            else:
                result-=abcd[2]
            if k == '+':
                result+=abcd[3]
            else:
                result-=abcd[3]
            if result == 7:
                print(abcd[0], end='')
                print(i, end='')
                print(abcd[1], end='')
                print(j, end='')
                print(abcd[2], end='')
                print(k, end='')
                print(abcd[3], end='')
                print('=7')
                sys.exit()

Solution (Python):
lst = ['+', '-']
S = raw_input()
oplst = []
for i in range(0, 8):
	op = []
	n = i
	for i in range(0, 3):
		op.append(n%2)
		n = n/2
	oplst.append(op)
for i in range(0, 8):
	sum = int(S[0])
	for j in range(0, 3):
		if oplst[i][j] == 0:
			sum += int(S[j+1])
		else:
			sum -= int(S[j+1])
	if sum == 7:
		ans = S[0]
		for j in range(0, 3):
			ans = ans + lst[oplst[i][j]] + S[j+1]
		ans = ans + '=7'
		print ans
		break

Solution (Python):
import sys
A,B,C,D=input()
for a in ("-","+"):
    for b in ("-","+"):
        for c in ("-","+"):
            if eval(A+a+B+b+C+c+D)==7:
                print(A+a+B+b+C+c+D+"=7")
                sys.exit()

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

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, '=7', sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, '=7', sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, '=7', sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, '=7', sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, '=7', sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, '=7', sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, '=7', sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, '=7', sep='')