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 in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class B {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        string ABCD;
        Input(out ABCD);
        int A = int.Parse(ABCD[0].ToString());
        int B = int.Parse(ABCD[1].ToString());
        int C = int.Parse(ABCD[2].ToString());
        int D = int.Parse(ABCD[3].ToString());
        int N = 3;
        bool[][] ret = new bool[1 << N][];
        for(int i = 0; i < (1 << N); i++) {
            ret[i] = new bool[N];
            for(int j = 0; j < N; j++) {
                if((1 & (i >> j)) == 1) {
                    //j番目が真だった時
                    ret[i][j] = true;
                } else {
                    //j番目が偽だった時
                }
            }
        }
        int S = A;
        string P = $"{A}";
        for(int i = 0; i < ret.Length; i++) {
            S = A;
            P = $"{A}";
            if(ret[i][0]) {
                S += B;
                P += $"+{B}";
            } else {
                S -= B;
                P += $"-{B}";
            }
            if(ret[i][1]) {
                S += C;
                P += $"+{C}";
            } else {
                S -= C;
                P += $"-{C}";
            }
            if(ret[i][2]) {
                S += D;
                P += $"+{D}";
            } else {
                S -= D;
                P += $"-{D}";
            }
            if(S == 7) {
                P += "=7";
                Print(P);
                //return;
            }

        }
        Out.Flush();
    }
    //bit全探索
    static bool[][] GetAllBitFlags(int N) {
        bool[][] ret = new bool[1 << N][];
        for(int i = 0; i < (1 << N); i++) {
            ret[i] = new bool[N];
            for(int j = 0; j < N; j++) {
                if((1 & (i >> j)) == 1) {
                    //j番目が真だった時
                    ret[i][j] = true;
                } else {
                    //j番目が偽だった時
                }
            }
        }
        return ret;
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}