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 sys
readline = sys.stdin.readline

def main():
    num = list(readline())
    op = ['+', '-']
    for op1 in op:
        for op2 in op:
            for op3 in op:
                f = num[0] + op1 + num[1] + op2 + num[2] + op3 + num[3]
                if eval(f) == 7:
                    print(f + '=7')
                    return


if __name__ == '__main__':
    main()

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

def main():
    num = list(map(int, list(readline().rstrip())))
    for op1 in ['+', '-']:
        for op2 in ['+', '-']:
            for op3 in ['+', '-']:
                v = num[0]
                if op1 == '+':
                    v += num[1]
                else:
                    v -= num[1]
                if op2 == '+':
                    v += num[2]
                else:
                    v -= num[2]
                if op3 == '+':
                    v += num[3]
                else:
                    v -= num[3]
                if v == 7:
                    print(str(num[0])+op1+str(num[1])+op2+str(num[2])+op3+str(num[3])+'=7')
                    return


if __name__ == '__main__':
    main()

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

for i in range(2 ** 3):
    op = ['+', '+', '+']
    ans = a
    for j in range(3):
        if ((i >> j) & 1):
            op[j] = '-'
            ans -= int(abcd[j + 1])
        else:
            ans += int(abcd[j + 1])
    if ans == 7:
        print(str(a) + str(op[0]) + str(b) + str(op[1]) + str(c) + str(op[2]) + str(d) + '=7')
        exit()

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

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

    if eval(A+op123[0]+B+op123[1]+C+op123[2]+D) == 7:
        print((A+op123[0]+B+op123[1]+C+op123[2]+D+'=7'))
        exit(0)

Solution (Python):
from itertools import permutations
def myAnswer(ABCD:list) -> str:
   ans = ""
   l = ["+","+","+","-","-","-"]
   
   for c in permutations(l,3):
      total = int(ABCD[0])
      ans = ABCD[0]
      for n,i in enumerate(c):
         if(i=="+"):
            total += int(ABCD[n+1])
            ans += "+" + ABCD[n+1]
         else:
            total -= int(ABCD[n+1])
            ans += "-" + ABCD[n+1]
      if(total == 7):
         return ans + "=7"




def modelAnswer():
   tmp=1
def main():
   ABCD = list(input())
   print(myAnswer(ABCD[:]))

if __name__ == '__main__':
   main()

Solution (Python):
L = list(map(int,list(input())))
for i in range(8):
    Str = '{:03b}'.format(i)
    cnt = L[0]
    for j in range(3):
        if Str[j] == '0':
            cnt -= L[j+1]
        else:
            cnt += L[j+1]
    if cnt == 7:
        ans = str(L[0])
        for j in range(3):
            if Str[j] == '0':
                ans += '-'
            else:
                ans += '+'
            ans += str(L[j+1])
        ans += '=7'
        print(ans)
        break

Solution (Python):
def main():
    A, B, C, D = input()
    for i in range(2**3):
        op = ['+', '+', '+']
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break
    
                
                
if __name__ == '__main__':
    main()

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

Solution (Python):

import random
import sys

str = input()


def retop():
    if(random.uniform(0, 1) > 0.5):
        return "+"
    return "-"


for i in range(100):
    formula = (str[0] + retop() + str[1] + retop() + str[2] + retop() + str[3])
    if eval(formula) == 7:
        print(formula + "=7")
        sys.exit()

Solution (Python):
def main():
    ABCD = input()
    A = int(ABCD[0])
    B = int(ABCD[1])
    C = int(ABCD[2])
    D = int(ABCD[3])
    for i in range(2):
        for j in range(2):
            for k in range(2):
                ans = 0
                op1 = ""
                op2 = ""
                op3 = ""
                if i % 2 == 0:
                    ans = A + B
                    op1 = "+"
                else:
                    ans = A - B
                    op1 = "-"
                
                if j % 2 == 0:
                    ans = ans + C
                    op2 = "+"
                else:
                    ans = ans - C
                    op2 = "-"
                
                if k % 2 == 0:
                    ans = ans + D
                    op3 = "+"
                else:
                    ans = ans - D
                    op3 = "-"

                if ans == 7:
                    print("{}{}{}{}{}{}{}=7".format(A, op1, B, op2, C, op3, D))
                    exit()
if __name__ == "__main__":
    main()

Solution (Python):
a,b,c,d = map(int,input())
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):
def resolve():
    A, B, C, D = list(map(int, input()))
    for op1 in ["+", "-"]:
        AB = A+B if op1 == "+" else A-B
        for op2 in ["+", "-"]:
            ABC = AB+C if op2 == "+" else AB-C
            for op3 in ["+", "-"]:
                ABCD = ABC+D if op3 == "+" else ABC-D
                if ABCD == 7:
                    print("{A}{op1}{B}{op2}{C}{op3}{D}=7".format(A=A,
                                                                 op1=op1,
                                                                 B=B,
                                                                 op2=op2,
                                                                 C=C,
                                                                 op3=op3,
                                                                 D=D))
                    return
    raise Exception("Not found")

    




if '__main__' == __name__:
    resolve()

Solution (Python):
a,b,c,d = map(int,input())
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):
I = str(input())
A = int(I[0])
B = int(I[1])
C = int(I[2])
D = int(I[3])
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            S = A
            a = b = c = '+' 
            if i == 0:
                S += B
                a = '+'
            else:
                S -= B
                a = '-'
            if j == 0:
                S += C
                b = '+'
            else:
                S -= C
                b = '-'
            if k == 0:
                S += D
                c = '+'
            else:
                S -= D
                c = '-'
            if S == 7:
                print(str(A)+a+str(B)+b+str(C)+c+str(D)+'=7')
                flag = True
                break
        if flag:
            break
    if flag:
        break

Solution (Python):
import itertools
a, *bcd = input()
for operater in itertools.product(['+', '-'], repeat=3):
    formula = a
    formula += "".join(op+num for op, num in zip(operater, bcd))
    if eval(formula) == 7:
        print(formula+'=7')
        exit()

Solution (Python):
from itertools import product
from operator import add, sub


def op_to_str(op):
  if op == add:
    return "+"
  else:
    return "-"


def main():
  a, b, c, d = map(int, input())
  
  op = (add, sub)
  for op1, op2, op3 in product(op, op, op):
    if op3(op2(op1(a, b), c), d) == 7:
      answer = (
        str(a) + op_to_str(op1)
      	+ str(b) + op_to_str(op2) 
        + str(c) + op_to_str(op3)
        + str(d) + "=7"
      )
      print(answer)
      break
      

if __name__ == "__main__":
  main()

Solution (Python):
s = input()


n = len(s)
for i in range(2**(n-1)):
  
  f = ''
  b = format(i, 'b').zfill(n-1) + '0'
  
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  
  if eval(f) == 7:
    print(f+'=7')
    break

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

for i in range(2**n):
    ope = ['-']*n
    for j in range(n):
        if (i >> j & 1):
            ope[j] = '+'
    formula = ''
    for i, o in zip(abcd, ope+['']):
        formula += i+o
    if eval(formula) == 7:
        print(formula+'=7')
        break

Solution (Python):
abcd = list(map(int, input()))
n = len(abcd)-1


for i in range(2**n):
    ans = 0
    formula = []
    for j in range(n):
        if (i >> j & 1):
            formula.append('+')
        else:
            formula.append('-')
    ans += abcd[0]
    for k in range(n):
        if formula[k] == '+':
            ans += abcd[k+1]
        elif formula[k] == '-':
            ans -= abcd[k+1]
    if ans == 7:
        print(abcd[0], formula[0], abcd[1], formula[1],
              abcd[2], formula[2], abcd[3], '=', 7, sep='')
        break

Solution (Python):
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left

def main():
    s = input()
    for bit in range(8):
        op = []
        for i in range(3):
            if (bit>>i)&1:
                op.append('+')
            else:
                op.append('-')
        
        tmp = s[0]
        for i in range(3):
            tmp += op[i]
            tmp += s[i + 1]

        if eval(tmp) == 7:
            ans = tmp + '=7'
            break
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
S = input()

equations_str = [S[0]]

def add_str(s:str, op:str):
    return s+op

for i in S[1:]:
    tmp_plus = list(map(lambda x: x+'+'+i, equations_str))
    tmp_minus = list(map(lambda x: x+'-'+i, equations_str))
    equations_str = tmp_plus
    equations_str.extend(tmp_minus)

for eq in equations_str:
    if eval(eq) == 7:
        print(eq+'=7')
        break

Solution (Python):

s = input()

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

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

Solution (Python):
s = input()

def dfs(i,sen,num):
    if i == 3:
        if num == 7:
            print(sen+"=7")
            quit()
    else:
        dfs(i+1,sen+"+"+s[i+1],num+int(s[i+1]))
        dfs(i+1,sen+"-"+s[i+1],num-int(s[i+1]))

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

Solution (Python):

n = [int(x) for x in input()]
op_cnt = len(n) - 1  

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  

    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  

    formula = ""

    for p_n, p_o in zip(n, op + [""]):  
        sum = str(p_n) + p_o
        formula += sum

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

Solution (Python):
import sys

S = list(input())

N = len(S)-1


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

    ans = ans + S[j+1]

    if eval(ans)==7:
        print(ans+"=7")
        sys.exit()

Solution (Python):
s = input()
n_op = len(s) - 1
for i in range(2**n_op):
  op = ['-'] * n_op
  for j in range(n_op):
    if i>>j & 1:
      op[n_op - 1 - j] = '+'
    
  formula = ''
  for p_s, p_op in zip(s, op+['']):
    formula += p_s + p_op
  if eval(formula) == 7:
    print(formula + '=7')
    break

Solution (Python):
A, B, C, D = (x for x in input())

OP = ('+', '-')

def solve():
  for op1 in OP:
    for op2 in OP:
      for op3 in OP:
        formula = A + op1 + B + op2 + C + op3 + D
        if eval(formula) == 7:
          return formula + '=7'

print(solve())

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

for ops in itertools.product(["+","-"],repeat=3):
    eq = a+ops[0]+b+ops[1]+c+ops[2]+d
    x = eval(eq)
    if x == 7:
        break

ans = eq + "=7"
print(ans)

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

for i in range(2**(n-1)):
    x = [s[0]]
    for j in range(n-1):
        if (i>>j)&1:
            y ='+'
        else:
            y = '-'
        x.append(y)
        y = 0
        x.append(s[j+1])
    z = ''.join(x)
    if eval(z) == 7:
        print(z + '=7')
        break

Solution (Python):
x = input()

for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            y = x[0]+i+x[1]+j+x[2]+k+x[3]
            if eval(y) == 7:
                ans = y
                
print(ans+"=7")

Solution (Python):
import sys
A = input()
A = list(A[0]+"F"+A[1]+"G"+A[2]+"H"+A[3])
B=["+", "-"]

for i in range(2):
    for j in range(2):
        for k in range(2):
            A[1] = B[i]
            A[3] = B[j]
            A[5] = B[k]
            C = "".join(A)
            if 7 == eval(C):
                print(C+"=7")
                sys.exit()

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

for i in range(8):
    output = []
    for j in range(3):
        if ((i >> j) & 1) == 1:
            output.append('+')
        else:
            output.append('-')
    ans = 0
    ansstr = ''
    for i in range(4):
        if i == 0:
            ans += int(s[i])
            ansstr += s[i]
        elif output[i-1] == '+':
            ans += int(s[i])
            ansstr += output[i-1]
            ansstr += s[i]
        else:
            ans -= int(s[i])
            ansstr += output[i-1]
            ansstr += s[i]
    if ans == 7:
        print(ansstr+'=7')
        exit()

Solution (Python):
nums=[int(n) for n in input()]

n=1
A=[nums[0]]

while n<=3:
    B=[]
    for a in A:
        B+=[a+nums[n],a-nums[n]]
    A=B
    n+=1

ans=str(nums[3])+'=7'
C=B.index(7)

for n in reversed(range(3)):
    if C%2==0:
        ans='+'+ans
    else:
        ans='-'+ans
    ans=str(nums[n])+ans
    C//=2

print(ans)

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

op = ['+', '-']

def check(A, B, C, D):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x = A+op[i]+B+op[j]+C+op[k]+D
                if eval(x) == 7:
                    return x

print(check(A, B, C, D)+'=7')

Solution (Python):
S = list(input())
for i in range(4):
    S[i] = int(S[i])

for i in range(2**3):
    a = S[0]
    for j in range(3):
        if (i >> j) & 1:
            a += S[j+1]
        else:
            a -= S[j+1]
    if a != 7:
        continue
    else:
        ans = str(S[0])
        for j in range(3):
            if (i >> j) & 1:
                ans += '+' + str(S[j+1])
            else:
                ans += '-' + str(S[j+1])
        print(ans + '=7')
        break

Solution (Python):
def resolve():
    s = input()
    for bit in range(2 ** 3):
        _str = "".join(
            s[i] if i == 3 else s[i] + "+" if 1 << i & bit else s[i] + "-"
            for i in range(4)
        )
        if eval(_str) == 7:
            print(_str + "=7")
            return


if __name__ == "__main__":
    resolve()

Solution (Python):
a=input()
op1,op2,op3="+","+","+"

if int(a[0])+int(a[1])+int(a[2])+int(a[3])==7:
    op1,op2,op3="+","+","+"
elif int(a[0])-int(a[1])+int(a[2])+int(a[3])==7:
    op1,op2,op3="-","+","+"
elif int(a[0])+int(a[1])-int(a[2])+int(a[3])==7:
    op1,op2,op3="+","-","+"
elif int(a[0])+int(a[1])+int(a[2])-int(a[3])==7:
    op1,op2,op3="+","+","-"
elif int(a[0])+int(a[1])-int(a[2])-int(a[3])==7:
    op1,op2,op3="+","-","-"
elif int(a[0])-int(a[1])-int(a[2])-int(a[3])==7:
    op1,op2,op3="-","-","-"
elif int(a[0])-int(a[1])+int(a[2])-int(a[3])==7:
     op1,op2,op3="-","+","-"
elif int(a[0])-int(a[1])-int(a[2])+int(a[3])==7:
    op1,op2,op3="-","-","+"

print((a[0])+op1+str(a[1])+op2+str(a[2])+op3+str(a[3])+"=7")

Solution (Python):
A = input()
f = ['+', '-']

def check(A):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x  = A[0]+f[i]+A[1]+f[j]+A[2]+f[k]+A[3]
                if eval(x) == 7:
                    return x

print(check(A)+'=7')

Solution (Python):
A = input()
n = len(A)
i = 1
ans = ''

def check(i, a, ans):
    if i == n:
        if eval(a) == 7:
            ans = a
        return ans
    
    else:
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '+' + a[p:]
        ans = check(i+1, a, ans)
        
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '-' + a[p:]
        ans = check(i+1, a, ans)
    return ans

ans = check(i, A, ans) 
print(ans+'=7')

Solution (Python):
N = 4
A = list(input())
total = 0

for bit in range(1 << (N-1)):
  f = A[0]
  for i in range(N-1):
    if bit & (1 << i):
      f += '+'
    else:
      f += '-'
    f += A[i+1]
  total = eval(f)
  if total == 7:
    print(f+'=7')
    break

Solution (Python):
k=input()
a=int(k[0])
b=int(k[1])
c=int(k[2])
d=int(k[3])
op1=["+","-"]
op2=["+","-"]
op3=["+","-"]
flag=0
for i in range(2):
  for j in range(2):
    for l in range(2):
      siki=k[0]+op1[i]+k[1]+op2[j]+k[2]+op3[l]+k[3]
      if (eval(siki)==7):
        print(siki+"=7")
        flag=1
      if (flag==1):
        break
    if (flag==1):
      break
  if (flag==1):
    break

Solution (Python):

s = input()
n = len(s)
for i in range(1,2**n):
  ans = [s[0]]
  for j in range(1,n):
    if (i>>j) & 1:
      ans.append("+")
    else:
      ans.append("-")
    ans.append(s[j])
  if eval("".join(ans)) == 7:
    ans.append("=7")
    print("".join(ans))
    exit()

Solution (Python):

s = input().strip()

op = ('+', '-')

for bit in range(8):
    ops = [op[bool(bit & (0x01 << d))] for d in range(3)]
    eq = ''.join(sum(zip(s, ops + ['']), ()))
    if eval(eq) == 7:
        print(eq+'=7')
        exit()

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

Solution (Python):
s=input()
n=len(s)
ans=''

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

Solution (Python):
from itertools import product
a, b, c, d = input().strip()
for e, f, g in product(['+', '-'], repeat=3):
  s = a+e+b+f+c+g+d
  if eval(s+'==7'):
    print(s+'=7')
    exit()

Solution (Python):
from operator import add, sub
from itertools import product
a, b, c, d = map(int, input().strip())
e = {add:'+', sub:'-'}
for X in product([add, sub], repeat=3):
  if X[2](X[1](X[0](a, b), c), d) == 7:
    print('{}{}{}{}{}{}{}=7'.format(a, e[X[0]], b, e[X[1]], c, e[X[2]], d))
    exit()

Solution (Python):
p,q,r,s=map(int,input())
flag=False
if p+q+r+s==7:
    print(str(p)+'+'+str(q)+'+'+str(r)+'+'+str(s)+'=7')
    flag=True
elif p+q+r-s==7 and flag==False:
    print(str(p)+'+'+str(q)+'+'+str(r)+'-'+str(s)+'=7')
    flag=True
elif p+q-r+s==7 and flag==False:
    print(str(p)+'+'+str(q)+'-'+str(r)+'+'+str(s)+'=7')
    flag=True
elif p+q-r-s==7 and flag==False:
    print(str(p)+'+'+str(q)+'-'+str(r)+'-'+str(s)+'=7')
    flag=True
elif p-q+r+s==7 and flag==False:
    print(str(p)+'-'+str(q)+'+'+str(r)+'+'+str(s)+'=7')
    flag=True    
elif p-q+r-s==7 and flag==False:
    print(str(p)+'-'+str(q)+'+'+str(r)+'-'+str(s)+'=7')
    flag=True
elif p-q-r+s==7 and flag==False:
    print(str(p)+'-'+str(q)+'-'+str(r)+'+'+str(s)+'=7')
    flag=True
elif p-q-r-s==7 and flag==False:
    print(str(p)+'-'+str(q)+'-'+str(r)+'-'+str(s)+'=7')
    flag=True

Solution (Python):
a, b, c, d = map(int, ','.join(input()).split(','))

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = 0
            lists = []
            if i % 2 == 0:
                ans = a + b
                lists.append('+')
            else:
                ans = a - b
                lists.append('-')
            if j % 2 == 0:
                ans += c
                lists.append('+')
            else:
                ans -= c
                lists.append('-')
            if k % 2 == 0:
                lists.append('+')
                ans += d
            else:
                ans -= d
                lists.append('-')
            if ans == 7:
                print(str(a) + lists[0] + str(b) + lists[1] + str(c) + lists[2] + str(d) + '=7')
                exit()

Solution (Python):
import sys
import itertools

n = str(input())

fugo =["+","-"]
p = list(itertools.product(fugo,repeat=3))

for i in p:
  shiki = n[0]+i[0]+n[1]+i[1]+n[2]+i[2]+n[3]
  if eval(shiki) == 7:
    print(shiki+"=7")
    sys.exit()

Solution (Python):
def main():
    nums = [int(num) for num in input()]

    for bit in range(1<<3):
        result = nums[0]
        ans = str(nums[0])
        
        for i in range(3):
            if (bit>>i) & 1:
                result += nums[i+1]
                ans += "+" + str(nums[i+1])
            else:
                result -= nums[i+1]
                ans += "-" + str(nums[i+1])

        ans += "=7"
        if result == 7:
            print(ans)
            exit()
        

if __name__ == "__main__":
    main()

Solution (Python):
s = input()

format = []
for i in range(2 ** (len(s) - 1)):
    pat = ""
    for j in range(len(s) - 1):
        pat += s[j]
        if i >> j & 1:
            pat += "+"
        else:
            pat += "-"

    pat += s[-1]    
    format.append(pat)

for i in range(len(format)):
    if eval(format[i]) == 7:
        print(format[i] + "=7")
        exit()

Solution (Python):
s = input()

l = []
for i in range(2**(len(s)-1)):
  pat = ''
  for j in range(len(s)-1):
    pat += s[j]
    if i >> j & 1:
      pat += '+'
    else:
      pat += '-'
  l.append(pat+s[-1])

for i in range(len(l)):
  if eval(l[i]) == 7:
    print(l[i] + '=7')
    break

Solution (Python):
import copy
S = list(input())
s = copy.copy(S)

for i in range(9):
    s = copy.copy(S)
    for j in range(3):
        if (i >> j) & 1 :
            s.insert(3-j,"+")
        else:
            s.insert(3-j,"-")

        tmp = "".join(s)

    if eval(tmp) == 7 :
        for k in s:
            print(k,end="")
        else:
            print("=7")
            quit()

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("{}+{}+{}+{}=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()
for i in range(2**3):
    f = s[0]
    for j in range(3):
        if i>>j & 1:
            f += '+'
        else:
            f += '-'
        f += s[j+1]
    if eval(f) == 7:
        print(f+'=7')
        exit()

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

if a+b+c+d==7:
  print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a-b+c+d==7:
  print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a-b-c+d==7:
  print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif a-b+c-d==7:
  print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a-b-c-d==7:
  print('{}-{}-{}-{}=7'.format(a,b,c,d))
elif a+b-c+d==7:
  print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a+b-c-d==7:
  print('{}+{}-{}-{}=7'.format(a,b,c,d))
else:
  print('{}+{}+{}-{}=7'.format(a,b,c,d))

Solution (Python):
ABCD=input()
digits=3
ops=[""]*(digits+1)
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            ops[j]="+"
        else:
            ops[j]="-"
    evals=""
    for num,op in zip(ABCD,ops):
        evals+=num+op
    if eval(evals)==7:
        print(evals+"=7")
        break

Solution (Python):
A,B,C,D=input()
digits=3
op=[""]*digits
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            op[j]="+"
        else:
            op[j]="-"
    if eval(A+op[0]+B+op[1]+C+op[2]+D)==7:
        print(A+op[0]+B+op[1]+C+op[2]+D+"=7")
        break

Solution (Python):
import sys
from itertools import product

s = sys.stdin.readline().rstrip()

def main():
    for ops in product('+-', repeat=3):
        res = s[0]
        for i in range(3):
            res += ops[i] + s[i+1]
        if eval(res) == 7:
            print(res + '=7')
            return 

if __name__ ==  '__main__':
    main()

Solution (Python):
S = input()
str_list = list(S)
p = len(S) - 1

for i in range(2 ** p):
  ans = int(str_list[0])
  sentence = S[0]
  for j in range(p):
    if (i >> j) & 1:
      ans += int(str_list[j+1])
      sentence += "+"+S[j+1]
    else:
      ans -= int(S[j+1])
      sentence += "-"+S[j+1]
  if ans ==7:
    print(sentence+"=7")
    break

Solution (Python):
s = input()

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

Solution (Python):
n = input()
a,b,c,d = map(str,(n[0],n[1],n[2],n[3]))
x = []
for i in range(8):  
  for j in range(3):
    if (i>>j)&1:
      x.append("+")
    else:
      x.append("-")
  line = a + x[0] + b + x[1] + c + x[2] + d
  if eval(line) == 7:
    print(line + "=7")
    break
  x = []

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

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

for i in range(2**3):
  tmp = A[0]
  for j in range(3):
    if (i >> j) & 1:
      tmp += A[j+1]
    else:
      tmp -= A[j+1]
  if tmp == 7:
    ops = [S[j] + ['-','+'][(i >> j) & 1] for j in range(3)]
    print(''.join(ops) + S[3] + '=7')
    exit()

Solution (Python):
a,b,c,d=input()
p = True
for i in ('+','-'):
    for j in ('+','-'):
        for k in ('+','-'):
            if eval(a+i+b+j+c+k+d)==7:
                print(a+i+b+j+c+k+d+'=7')
                p = False
                break
        else:
            continue
        break
    else:
        continue
    break
if p:
    print(u'バーカ')

Solution (Python):
s = input()

ops = ["-", "-", "-"]
n = 3

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

Solution (Python):
s = input()

EQS = []
n = 3
for i in range(2**n):
  eq = ""
  for j in range(len(s)):
    eq += s[j]
    if((i>>j)&1):
      eq += "+"
    else:
      eq += "-"
  eq = eq[:-1]
  EQS.append(eq)

def clc(eq):
  total = int(eq[0])
  for i in range(1,len(eq),2):
    if eq[i]!=eq[-1]:
      if eq[i]=="+":
        total+=int(eq[i+1])
      else:
        total-=int(eq[i+1])
  
  return total

for i in EQS:
  total = clc(i)
  if total ==7:
    i +="=7"
    print(i)
    exit()

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

lead = S.pop(0)
n = len(S)
k = 7-lead
l = ['=7']

def dfs(i, sum):
    if i == n:
        return sum == k
    if dfs(i + 1, sum + S[i]):
        l.insert(0, '+')
        return True
    if dfs(i + 1, sum - S[i]):
        l.insert(0, '-')
        return True
    return False

if dfs(0, 0):
    S.insert(0, lead)
    for i in range(n+1):
        print(S[i], end='')
        print(l[i], end='')
    print('')

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

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):
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
    exit()
s=input()
dfs(0,s[0],int(s[0]))

Solution (Python):
def dfs(array: list, index: int, calc: str, result: int):
    if index == len(array):
        if result == 7:
            return "{}=7".format(calc)
        else:
            return ""

    if index == 0:
        return dfs(array, index + 1, array[index], int(array[index]))
    elif index < len(array):
        return dfs(array, index + 1, calc + "-" + array[index], result - int(array[index])) + dfs(array, index + 1, calc + "+" + array[index], result + int(array[index]))

array = list(input())
S = dfs(array, 0, "", 0)
print(S[:9])