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()
ls=list(map(int,[S[i] for i in range(4)]))
for bit in range(1<<3):
  su=ls[0]
  st=str(ls[0])
  for i in range(3):
    if bit&(1<<i):
      su+=ls[i+1]
      st=st+"+"+str(ls[i+1])
    else:
      su-=ls[i+1]
      st=st+"-"+str(ls[i+1])
  if su==7:
    st=st+"=7"
    print(st)
    exit()

Solution (Python):


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

def calc(index,num):
    if index&1==1:
        return [num,"+"]
    else:
        return [-num,"-"]

for i in range(8):
    ans=S[0]
    s1=calc(i,S[1])[1]
    ans+=calc(i,S[1])[0]
    s2=calc(i>>1,S[2])[1]
    ans+=calc(i>>1,S[2])[0]
    s3=calc(i>>2,S[3])[1]
    ans+=calc(i>>2,S[3])[0]
    if ans==7:
        print(str(S[0])+s1+str(S[1])+s2+str(S[2])+s3+str(S[3])+"=7")
        exit()

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

Solution (Python):
import sys
X = int(input())
D = X%10
X = (X - D)//10
C = X%10
X = (X - C)//10
B = X%10
A = (X - B)//10
sm = A+B+C+D
if sm == 7:
    print("%d+%d+%d+%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*D == 7:
    print("%d+%d+%d-%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*C == 7:
    print("%d+%d-%d+%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*B == 7:
    print("%d-%d+%d+%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*(B+C) == 7:
    print("%d-%d-%d+%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*(B+D) == 7:
    print("%d-%d+%d-%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*(C+D) == 7:
    print("%d+%d-%d-%d=7"%(A,B,C,D))
    sys.exit()
elif sm-2*(B+C+D) == 7:
    print("%d-%d-%d-%d=7"%(A,B,C,D))
    sys.exit()

Solution (Python):
S = list(input())
ans = [""]*9
for bit in range(1<<3):
  a = int(S[0])
  ans = [None]*9
  ans[0]=S[0]
  ans[2]=S[1]
  ans[4]=S[2]
  ans[6]=S[3]
  ans[8]="7"
  ans[7]="="
  for k in range(3):
    if bit&(1<<k):
      a+=int(S[k+1])
      if k==0:
      	ans[1]="+"
      elif k==1:
        ans[3]="+"
      else:
        ans[5]="+"
    else:
      a-=int(S[k+1])
      if k==0:
      	ans[1]="-"
      elif k==1:
        ans[3]="-"
      else:
        ans[5]="-"
  if a==7:
    print("".join(ans))
    exit()

Solution (Python):
A, B, C, D = input()
o = ["+", "-"]
for i in range(2):
  for j in range(2):
    for k in range(2):
      s = A + o[i] + B + o[j] + C + o [k] + D
      if eval(s) == 7:
        print(s + "=7")
        exit()

Solution (Python):
a=input()
def dfs(i,s,l):
    if i==3:
        if s==7:
            print(l+'=7')
            exit()
    else:
        dfs(i+1,s+int(a[i+1]),l+'+'+a[i+1])
        dfs(i+1,s-int(a[i+1]),l+'-'+a[i+1])

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

Solution (Python):
a,b,c,d = map(str, input())
op_list = ['+', '-']


for op1 in op_list:
    for op2 in op_list:
        for op3 in op_list:
            f = a+op1+b+op2+c+op3+d
            if eval(f) == 7:
                print(f+'=7')
                exit()

Solution (Python):
S = input().strip()
op = ["+","-"]
ind = 0
for op1 in op:
    for op2 in op:
        for op3 in op:
            if eval(S[0]+op1+S[1]+op2+S[2]+op3+S[3])==7:
                print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+"=7")
                ind = 1
                break
        if ind==1:break
    if ind==1:break

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

Solution (Python):
A,B,C,D = map(int, list(input()))
ans = ''
op_list = ['+', '-']
for op1 in op_list:
    for op2 in op_list:
        for op3 in op_list:
            formula = "{}{}{}{}{}{}{}".format(A,op1,B,op2,C,op3,D)
            if 7 == eval(formula):
                ans = formula+"=7" 
                break
print(ans)

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

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

ops = ["+","-"]

for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            x = eval(a+op1+b+op2+c+op3+d)
            if x == 7:
                print(a+op1+b+op2+c+op3+d+"=7")
                exit()

Solution (Python):
def slove():
    import sys
    import itertools
    input = sys.stdin.readline
    a = list(map(int, list(str(input().rstrip('\n')))))
    ls = ["+", "-"]
    for v in itertools.product(ls, repeat=3):
        t = a[0]
        s = [str(a[0])]
        for i in range(len(v)):
            if v[i] == "+":
                t += a[i + 1]
                s.append("+")
            else:
                t -= a[i + 1]
                s.append("-")
            s.append(str(a[i + 1]))
        if t == 7:
            s.append("=7")
            print("".join(s))
            exit()


if __name__ == '__main__':
    slove()

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

for i in range(2**3):
    tmp = s[0]
    for j in range(n):
        if (i >> j) & 1:
            tmp += "+"

        else:
            tmp += "-"

        tmp += s[j+1]

    list_tmp = [tmp[0], tmp[1:3], tmp[3:5], tmp[5:7]]

    res = 0
    for j in list_tmp:
        res += int(j)

    if res == 7:

        print(tmp + "=7")
        exit()

Solution (Python):
import sys
df = list(map(int, list(str(input()))))
counter = 0
for i in range(2**3):
    bin_i = format(i, '03b')
    counter += df[0]
    for j in range(3):
        if bin_i[j] == '1':
            counter -= df[j+1]
        else:
            counter += df[j+1]
    if counter == 7:
        result = str(df[0])
        for j in range(3):
            if bin_i[j] =='0':
                result += '+' + str(df[j+1])
            else:
                result += '-' + str(df[j+1])
        result += '=7'
        print(result)
        sys.exit()
    else:
        counter = 0

Solution (Python):
def f(i,s,t):
    if i==3:
        if t==7:
            print(s + '=7')
            exit()
    
    else:
        f(i+1,s+'-'+a[i+1],t-int(a[i+1]))
        f(i+1,s+'+'+a[i+1],t+int(a[i+1]))

a=input()
f(0,a[0],int(a[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):
value = input()
n = len(value) - 1

for i in range(n ** 2):
    sign = ["+"] * n
    for j in range(n):
        if(i >> j & 1):
            sign[n-1-j] = "-"
    formula = ""
    for x,y in zip(value,sign+[""]):
        formula += x + y 
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )



import random


def main():
    
    ll=input().strip()
    l=[0 for i in range(4)]
    for i in range(len(l)):
        l[i]=int(ll[i])
    NUM_CASE=3

    for case in range(2**NUM_CASE):
        
        sum=l[0]
        
        stack=[]
        S=""
        for index in range(NUM_CASE):
            if (case>>index) & 1 == 1:
                
                sum+=l[index+1]
                stack.append("+")
            else:
                
                sum-=l[index+1]
                stack.append("-")
        
        if sum==7:
            for i in range(4):
                S+=str(l[i])
                if i!=3:
                    S+=str(stack[i])
            S+="=7"
            print(S)
            return
    return

if __name__ == '__main__':
    main()

Solution (Python):
def solve(next_idx, exp):
  if next_idx >= len(S):
    total = eval("".join(exp))
    return exp if total == 7 else ""

  return max(solve(next_idx+1, exp+"+"+S[next_idx]), solve(next_idx+1, exp+"-"+S[next_idx]))

S = input()
print(solve(1, S[0]) + "=7")

Solution (Python):

li = list(input())
li = [int(num) for num in li]

def dfs(index, total, ans):
    if (index==3):
        if total + li[index] == 7:
            return ans + '+' + str(li[index])
        elif total - li[index] == 7:
            return ans + '-' + str(li[index])
        else:
            return None
   
    if index == 0:
        return dfs(index + 1, total+li[index], ans+str(li[index]))
    else:
        val1 = dfs(index + 1, total + li[index], ans + '+' + str(li[index]))
        val2 = dfs(index + 1, total - li[index], ans + '-' + str(li[index]))
        if val1:
             return val1
        if val2:
             return val2
print(dfs(0, 0, '') + '=7')

Solution (Python):
ABCD = input()

ops = ['+', '-']

for i in range(2**3):

    ans = int(ABCD[0])
    op = []
    for j in range(3):
        if ops[i % 2] == '+':
            ans += int(ABCD[j+1])
        else:
            ans -= int(ABCD[j+1])
        op.append(ops[i%2])
        i //= 2

    if ans == 7:
        print(ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2] + ABCD[3] + '=7')
        break

Solution (Python):
s=input()
for bit in range(1<<3):
    l=s[0]
    for i in range(3):
        if bit & (1<<i):
            l+='+'+s[i+1]
        else:
            l+='-'+s[i+1]
    if eval(l)==7:
        print(l+'=7')
        exit()

Solution (Python):
def main():
    li = [int(i) for i in input()]
    t = li[1:]
    op = ["+", "+", "+"]
    t_sum = sum(li)
    if t_sum == 7:
        print("{}+{}+{}+{}=7".format(li[0], li[1], li[2], li[3]))
    else:
        for i in range(3):
            if t_sum - 2*t[i] == 7:
                op[i] = "-"
                print("{}{}{}{}{}{}{}=7".format(li[0], op[0], li[1], op[1], li[2], op[2], li[3]))
                return
            elif t_sum - 2*t[i] > 7:
                for j in range(1, 3):
                    if t_sum - (t[i] + t[i-j])*2 == 7:
                        op[i] = "-"
                        op[i-j] = "-"
                        print("{}{}{}{}{}{}{}=7".format(li[0], op[0], li[1], op[1], li[2], op[2], li[3]))
                        return

main()

Solution (Python):
import sys

a, b, c, d = tuple(input())
op = ('+', '-')

for op1 in op:
    for op2 in op:
        for op3 in op:
            res = a + op1 + b + op2 + c + op3 + d
            if eval(res) == 7:
                print(res + '=7')
                sys.exit(0)

Solution (Python):
a, b, c, d = map(int, list(input()))
abcd = [a, b, c, d]
anss = []
import copy
def dfs(add_list, index):
    value = abcd[0]
    if index == 2:
        for add_index in range(len(add_list)):
            if add_list[add_index]:
                value += abcd[add_index+1]
            else:
                value -= abcd[add_index+1]

        if value == 7:
            anss.append(add_list)

    else:
        new_index = index + 1
        new_add_list = copy.copy(add_list)
        new_add_list[new_index] = False
        dfs(new_add_list, new_index)

        new_add_list = copy.copy(add_list)
        new_add_list[new_index] = True
        dfs(new_add_list, new_index)


def main():
    dfs([True,True,True], 0)
    dfs([False,True,True], 0)

    ans = anss[0]
    ans_str = []
    for op in ans:
        if op:
            ans_str.append("+")
        else:
            ans_str.append("-")
    ret_str = ""
    for index in range(len(ans_str)):
        ret_str += str(abcd[index])
        ret_str += ans_str[index]
    ret_str += str(abcd[-1])
    ret_str += "=7"
    print(ret_str)
if __name__ == "__main__":
    main()

Solution (Python):
A = input()
for i in range(2**3):
    s = A
    for j in range(3):
        if i>>j & 1:
            s = s[:j-3]+"+"+s[j-3:]
        else:
            s = s[:j-3]+"-"+s[j-3:]
    ans = int(s[0])
    for k in range(len(s)):
        if k%2 == 0:
            n = int(s[k])
        if s[k-1] == "+":
            ans += n
        elif s[k-1] == "-":
            ans -= n
    if ans == 7:
        print(s+"=7")
        break

Solution (Python):

ABCD = input() 
op = ["*", "*", "*"] 
def operate(ans, i): 
    if i == 3:
        if ans == 7:
            print("{}{}{}{}{}{}{}=7".format(ABCD[0], op[0], ABCD[1], op[1], ABCD[2], op[2], ABCD[3]))
            exit()
    else:
        op[i] = op[i].replace("*", "+").replace("-", "+") 
        operate(ans + int(ABCD[i + 1]), i + 1)
        op[i] = op[i].replace("+", "-") 
        operate(ans - int(ABCD[i + 1]), i + 1)
operate(int(ABCD[0]), 0)

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

if A+B+C+D==7:
  print ("{}+{}+{}+{}=7".format(A,B,C,D))
elif A+B+C-D==7:
  print ("{}+{}+{}-{}=7".format(A,B,C,D))
elif A+B-C+D==7:
  print ("{}+{}-{}+{}=7".format(A,B,C,D))
elif A+B-C-D==7:
  print ("{}+{}-{}-{}=7".format(A,B,C,D))
elif A-B+C+D==7:
  print ("{}-{}+{}+{}=7".format(A,B,C,D))
elif A-B+C-D==7:
  print ("{}-{}+{}-{}=7".format(A,B,C,D))
elif A-B-C+D==7:
  print ("{}-{}-{}+{}=7".format(A,B,C,D))
elif A-B-C-D==7:
  print ("{}-{}-{}-{}=7".format(A,B,C,D))

Solution (Python):
s = input()
sLen = len(s)
for i in range(2**(sLen-1)):
  tmpAns = 0
  tmpOp =''
  for j in range(sLen-1):
    if((i>>j)&1):
      tmpAns += int(s[sLen-1-j])
      tmpOp += '+'
    else:
      tmpAns -= int(s[sLen-1-j])
      tmpOp += "-"
  if tmpAns+int(s[0]) == 7:
    print(s[0]+tmpOp[2]+s[1]+tmpOp[1]+s[2]+tmpOp[0]+s[3]+"=7")
    break

Solution (Python):
N = input()
n = [v for v in N]

l = len(n)
C = []

for i in range(2**(l-1)):
    c = ''
    for j in range(l):
        c += n[j]
        if i >> j & 1:
            c += '+'
        else:
            c += '-'
    if eval(c[:-1]) == 7:
        print('{}=7'.format(c[:-1]))
        exit()

Solution (Python):

S = input()
op_cnt = len(S) - 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 a, b in zip(S, op + ['']):
        formula += a + b
    if eval(formula) == 7:
        print(formula + '=7')
        break

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

o=['+++','++-','+-+','+--','-++','-+-','--+','---']

ans=-1
for i in range(8):
    if eval(a+o[i][0]+b+o[i][1]+c+o[i][2]+d)==7:
        ans=i
        break

print(a+o[i][0]+b+o[i][1]+c+o[i][2]+d+'=7')

Solution (Python):
S= list(input())
Answer = "a"

for i in ['+','-']:
  for j in ['+','-']:
    for k in ['+','-']:
      if eval(S[0]+i+S[1]+j+S[2]+k+S[3])==7:
        Answer = S[0]+i+S[1]+j+S[2]+k+S[3]+'=7'
        break

print(Answer)

Solution (Python):
import sys
abcd = input()
a, b, c, d = map(int, abcd)
op = [1, -1]
s_op = ['+', '-']
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:
                print('{}{}{}{}{}{}{}=7'.format(
                    a, s_op[i], b, s_op[j], c, s_op[k], d
                    ))
                sys.exit(0)

Solution (Python):
s = input()
for i in range(2**(len(s)-1)):
    ans = s[0]
    for j in range(len(s)-1):
        if i >> j & 1:
            ans += "+"
        else: ans += "-"
        ans += s[j+1]
    if eval(ans) == 7:print(ans+"=7");exit()

Solution (Python):
a,b,c,d = input()
abcd = list(map(int,[a,b,c,d]))
op = [None]*3
for i in range(2**3):
    f = abcd[0]
    for j in range(3):
        if ((i >> j) & 1):
            f += abcd[j+1]
            op[j] = '+'
        else:
            f -= abcd[j+1]
            op[j] = '-'
    if f == 7:
        print(a+op[0]+b+op[1]+c+op[2]+d+'=7')
        exit()

Solution (Python):
def f(i,s):
    if i == len(n)-1:
        if eval(s) == 7:
            ans.append(s)
            return 1
        else:return 0
    return f(i+1,s+"-"+n[i+1])+f(i+1,s+"+"+n[i+1])
n = input()
ans = []
f(0,n[0])
print(ans[0]+"=7")

Solution (Python):
from math import sqrt


def log(s):
    
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


def main():
    s = input()
    n = len(s) - 1
    for k in range(2 ** n):
        ops = list(("{0:{fill}%db}" % n).format(k, fill="0").replace("0", "+").replace("1", "-"))
        ops.append("")
        q = ""
        for a, b in zip(s, ops):
            q += a + b
        v = eval(q)
        if v == 7:
            print(q + "=7")
            break


main()

Solution (Python):
import sys

s = input()

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

ans = a
for i in range(2):
	if i == 0:
		ans += b
		s1 = '+'
	else:
		ans -= b
		s1 = '-'
	for j in range(2):
		if j == 0:
			ans += c
			s2 = '+'
		else:
			ans -= c
			s2 = '-'
		for k in range(2):
			if k == 0:
				ans += d
				s3 = '+'
			else:
				ans -= d
				s3 = '-'
			if ans == 7:
				print(s[0]+s1+s[1]+s2+s[2]+s3+s[3]+"=7")
				sys.exit()
			else:
				if k == 0:
					ans -= d
				else:
					ans += d
		if j == 0:
			ans -= c
		else:
			ans += c
	if i == 0:
		ans -= b
	else:
		ans += b

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

import sys
for bit in range(2 ** 3):
    sum = ls[0]
    ans = str(ls[0])
    for i in range(3):
        if bit >> i & 1:
            sum += ls[i + 1]
            ans += "+" + str(ls[i + 1])
        else:
            sum -= ls[i + 1]
            ans += "-" + str(ls[i + 1])
    if sum == 7:
        print(ans + "=7")
        sys.exit()

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

    formula = ""
    for k in range(n):
        formula += s[k] + p_or_m[k]
    formula += s[3]
    if eval(formula) == 7:
        print(formula+"=7")
        break

Solution (Python):
s = input()
S = [0]*len(s)
for i in range(len(s)):
    S[i] = int(s[i])


op = [0]*(len(S) - 1)
for i in range(2**len(op)):
    op = [0]*(len(S) - 1)
    for j in range(len(op)):
        if (i >> j & 1):
            op[j] = 1
    tmp = S[0]
    for j in range(len(op)):
        if op[j] == 0:
            tmp -= S[j+1]
        else:
            tmp += S[j+1]
    if tmp == 7:
        ans = op[:]
ans_str = s[0]
for i in range(len(S)-1):
    if ans[i] == 0:
        ans_str = ans_str + "-"
    else:
        ans_str = ans_str + "+"
    ans_str = ans_str + s[i+1]
ans_str = ans_str + "=7"
print(ans_str)

Solution (Python):
f=input()
o=['+','-']
for i in o:
    for j in o:
        for k in o:
            s=f[0]+i+f[1]+j+f[2]+k+f[3]+"==7"
            if eval(s):
                print(s.replace('==','='))
                exit()

Solution (Python):
b = input()
a = [0] * 4
a[0] = int(b[0])
a[1] = int(b[1])
a[2] = int(b[2])
a[3] = int(b[3])

for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      if i1 == 0 and i2 == 0 and i3 == 0:
        if a[0] + a[1] + a[2] + a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '+' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 0 and i2 == 0 and i3 == 1:
        if a[0] + a[1] + a[2] - a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '+' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 0 and i2 == 1 and i3 == 0:
        if a[0] + a[1] - a[2] + a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '-' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 0 and i2 == 1 and i3 == 1:
        if a[0] + a[1] - a[2] - a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '-' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 0 and i3 == 0:
        if a[0] - a[1] + a[2] + a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '+' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 0 and i3 == 1:
        if a[0] - a[1] + a[2] - a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '+' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 1 and i3 == 0:
        if a[0] - a[1] - a[2] + a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '-' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 1 and i3 == 1:
        if a[0] - a[1] - a[2] - a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '-' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()

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

if a+b+c+d==7:
    print("{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):
f=input()
o=['+','-']
for i in o:
    for j in o:
        for k in o:
            s=f[0]+i+f[1]+j+f[2]+k+f[3]+"==7"
            if eval(s):
                print(s.replace('==','='))
                exit()

Solution (Python):
n = input()
op = ["-", "+"]

for i in op:
    for j in op:
        for k in op:
            if eval(n[0] + i + n[1] + j + n[2] + k + n[3]) == 7:
                print(n[0] + i + n[1] + j + n[2] + k + n[3] + "=7")
                exit()

Solution (Python):
from itertools import zip_longest
s = input()
gotResult = False

for i in range(2**(len(s) - 1)):
  n = ['+'] * (len(s) - 1)
  formula = ""
  for j in range(len(s) - 1):
    if (i>>j)&1:
      n[len(s) - 1 - 1 - j] = '-'
  for num,op in zip_longest(s,n):
      formula += num if op == None else num + op
  if eval(formula) == 7:
    print(formula + '=' + str(eval(formula)))
    gotResult = True
    break
  if gotResult:
    break

Solution (Python):
import sys
from collections import defaultdict
a = input()
alst = [0, 1]
blst = [0, 1]
clst = [0, 1]
ans = ''
for i in alst:
    for j in blst:
        for k in clst:
            tmp = 0
            ans = ''
            if i == 0:
                tmp = int(a[0]) + int(a[1])
                ans = a[0] + '+' + a[1]
            else:
                tmp = int(a[0]) - int(a[1])
                ans = a[0] + '-' + a[1]
            if j == 0:
                tmp = tmp + int(a[2])
                ans = ans + '+' + a[2]
            else:
                tmp = tmp - int(a[2])
                ans = ans + '-' + a[2]
            if k == 0:
                tmp = tmp + int(a[3])
                ans = ans + '+' + a[3]
            else:
                tmp = tmp - int(a[3])
                ans = ans + '-' + a[3]
            if tmp == 7:
                print(ans + '=7')
                sys.exit()

Solution (Python):
a, b, c, d = input()
kigou = ["+", "-"]
for i in range(8):
    bin_str = str(format(i, 'b').rjust(10, '0'))
    soeji_01 = int(bin_str[-1])
    soeji_02 = int(bin_str[-2])
    soeji_03 = int(bin_str[-3])
    shiki = "" + a + kigou[soeji_01] + b + \
        kigou[soeji_02] + c + kigou[soeji_03] + d
    if eval(shiki) == 7:
        print(shiki+"=7")
        exit()

Solution (Python):
def conv(c): return '+' if c==1 else '-'
def main():
	num = [int(c) for c in input()]
	choices = [-1,1]
	for a in choices:
		for b in choices:
			for c in choices:
				if num[0]+num[1]*a+num[2]*b+num[3]*c==7:
					print("{}{}{}{}{}{}{}=7".format(num[0],conv(a),num[1],conv(b),num[2],conv(c),num[3]))
					return
main()

Solution (Python):
from itertools import product

S = list(input())
a = list(product(['+','-'],repeat=3))

for i in a:
  shiki = S[0]+i[0]+S[1]+i[1]+S[2]+i[2]+S[3]
  if eval(shiki) == 7:
    print(shiki + "=7")
    exit()

Solution (Python):
N = input()

def dfs(i,f):
    if i == 3:
         a = eval(f)
         if a == 7:
             print(f+"=7")
             exit()
    else:
        dfs(i+1, f+"+"+N[i+1])
        dfs(i+1, f+"-"+N[i+1])


dfs(0,N[0])

Solution (Python):
def main():
    abcd = input()
    n = len(abcd)
    for i in range(2**(n-1)):
        num = ""
        
        for j in range(n):
            num += abcd[j]
            if j < n-1:
                if (i >> j) & 1:
                    num += "-"
                else:
                    num += "+"
        if eval(num) == 7:
            print(num+"=7")
            exit()


if __name__ == "__main__":
    main()

Solution (Python):
ABCD = input()

for i in range(1<<3):
    t = ABCD[0]
    for j in range(3):
        t += "+" if (i>>j)%2 else "-"
        t += ABCD[j+1]
    if eval(t) == 7:
        print(t+"=7")
        exit()

Solution (Python):
N= input()
A = list([int(i) for i in N])

patterns = ['000', '001', '010', '011', '100', '101', '110', '111']

rem = ''

for pattern in patterns:
    S=A[0]
    for i, s in enumerate(pattern):
        if int(s):S+=A[i+1]
        else:S-=A[i+1]
    if S==7:
        rem = pattern
        break

pattern = pattern.replace('0','-').replace('1', '+')
lst = []
for i, j in zip(A, pattern):
    lst.append(i)
    lst.append(j)
lst.append(A[3])
lst.append('=7')
print(*lst,sep='')

Solution (Python):
import sys

a, b, c, d = list(input())
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            expr = ''.join([a, op1, b, op2, c, op3, d])
            if eval(expr) == 7:
                print(expr + '=7')
                sys.exit()

Solution (Python):

import itertools
s = input()
a = s[0:1]
b = s[1:2]
c = s[2:3]
d = s[3:4]

OP = ('+','-')

for op in itertools.product(OP,repeat=3):
    op1,op2,op3 = op
    t = int(a)
    if op1 == '+':
        t += int(b)
    elif op1 == '-':
        t -= int(b)

    if op2 == '+':
        t += int(c)
    elif op2 == '-':
        t -= int(c)

    if op3 == '+':
        t += int(d)
    elif op3 == '-':
        t -= int(d)
    if t == 7:
        print(a+op1+b+op2+c+op3+d+'=7')
        break

Solution (Python):
import itertools
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D = map(int, list(input().rstrip()))
        op = ['+', '-']
        for op1, op2, op3 in itertools.product(op, op, op):
            AB = A + B if op1 == '+' else A - B
            ABC = AB + C if op2 == '+' else AB - C
            ABCD = ABC + D if op3 == '+' else ABC - D
            if ABCD == 7:
                print('{a}{op1}{b}{op2}{c}{op3}{d}=7'.format(a=A, b=B, c=C, d=D, op1=op1, op2=op2, op3=op3))
                exit()



if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
calcNum = [1, -1]
calcSign = ["+", "-"]
n = list(input())
for a in range(2):
    for b in range(2):
        for c in range(2):
            if int(n[0]) + calcNum[a] * int(n[1]) + calcNum[b] * int(n[2]) + calcNum[c] * int(n[3]) == 7:
                string = n[0] + calcSign[a] + n[1] + \
                    calcSign[b] + n[2] + calcSign[c] + n[3] + "=7"

print(string)

Solution (Python):
s = input()
N = len(s)
s_num = [int(i) for i in s]
for i in range(2**(N-1)):
    x = []
    value = s_num[0]
    for j in range(N-1):
        if (i >> j) & 1:
            x.append('+')
            value += s_num[j+1]
        else:
            x.append('-')
            value -= s_num[j+1]
    if value == 7:
        fomula = ''
        for k in range(N-1):
            fomula += s[k]
            fomula += x[k]
        fomula += s[N-1]
        fomula += '=7'
        print(fomula)
        break

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

k=["+","-"]

for k1 in k:
    for k2 in k:
        for k3 in k:
                if eval(a+k1+b+k2+c+k3+d)==7:
                    print("{}=7".format(a+k1+b+k2+c+k3+d))
                    exit()

Solution (Python):
def main():
    S = input()
    a, b, c, d = (int(i) for i in S)
    ans = 0
    sign = []
    flag = False
    
    for op1 in range(2):
        for op2 in range(2):
            for op3 in range(2):
                ans = 0
                sign = []
                if op1 == 0:
                    ans = a + b
                    sign.append('+')
                else:
                    ans = a - b
                    sign.append('-')
                if op2 == 0:
                    ans += c
                    sign.append('+')
                else:
                    ans -= c
                    sign.append('-')
                if op3 == 0:
                    ans += d
                    sign.append('+')
                else:
                    ans -= d
                    sign.append('-')
                if ans == 7:
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
    for n,op in zip(S,sign):
        print(n+op,end="")
    else:
        print(S[-1]+'=7')


if __name__ == '__main__':
    main()

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

abcd = input()
print(dfs(0, abcd[0], int(abcd[0])))

Solution (Python):
A, B, C, D = input()
o = ["+", "-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            s = A + o[i]  + B + o[j] + C + o[k] + D
            if eval(s) == 7:
                print(s + "=7")
                exit()

Solution (Python):
n = input()
li = [n[0],n[1],n[2],n[3]]
pm = [[1,1,1],[1,1,0],[1,0,1],[1,0,0],[0,1,1],[0,1,0],[0,0,1],[0,0,0]]
s = ""

for i in range(8):
    for j in range(3):
        if pm[i][j]==1:
            pm[i][j]="+"
        elif pm[i][j]==0:
            pm[i][j]="-"

for j in range(8):
    s = li[0]+pm[j][0]+li[1]+pm[j][1]+li[2]+pm[j][2]+li[3]
    if eval(s)==7:
        break
print(s+"=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')