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



Sample input:
1222


Sample output:
1+2+2+2=7

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = list(input())
s = [int(i) for i in s]

for fl in itertools.product([0,1],repeat=3):
    cnt = s[0]
    for i,t in enumerate(fl):
        if t==0:
            cnt += s[i+1]
        else:
            cnt -= s[i+1]
    if cnt == 7:
        L = str(s[0])
        for i,t in enumerate(fl):
            if t==0:
                L += '+' + str(s[i+1])
            else:
                L += '-' + str(s[i+1])
        print(L + '=7')
        break

Submission status: Accepted

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

for x in '+-':
    for y in '+-':
        for z in '+-':
            f = a + x + b + y + c + z + d
            if eval(f) == 7:
                print(f + '=7')
                exit()

Submission status: Accepted

Solution code:
import itertools

s = input()
final = ""
gr = list(itertools.product('+-', repeat=3))
for c in gr:
    ans = int(s[0])
    for i in range(1, 4):
        if c[i-1] == "+":
            ans += int(s[i])
        else:
            ans -= int(s[i])
    if ans == 7:
        final = s[0] + c[0] + s[1] + c[1] + s[2] + c[2] + s[3] + "=7"

print(final)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main():
    S = input()
    size = len(S)

    for bit in range(1 << (size-1)):
        exp = S[0]
        for i in range(size-1):
            if (bit & (1 << i)):
                exp += '+'
            else:
                exp += '-'
            exp += S[i+1]
        if eval(exp) == 7:
            print(exp + '=7')
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
_ = "_"


def solve(f):
    if _ in f:
        a = solve(f.replace(_, '+', 1))
        b = solve(f.replace(_, '-', 1))
        if a is not None:
            return a
        if b is not None:
            return b
    else:
        if eval(f) is 7:
            return f
        else:
            return None


s = _.join(input())
print(solve(s) + '=7')

Submission status: Accepted

Solution code:
n = list(input())
li = list()
for i in range(2**3):
    op = ["-"]*3
    for j in range(3):
        if ((i>>j)&1):
            op[2-j] = "+"
    ans = n[0]+op[0]+n[1]+op[1]+n[2]+op[2]+n[3]
    if (eval(ans) == 7):
        print(ans+"=7")
        break

Submission status: Accepted

Solution code:
#ABC079 C bit全探索
A, B, C, D = input()
for i in range(2**3):
    op = ['+']*3
    for j in range(3):
        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

Submission status: Accepted

Solution code:
import itertools

abcd = input()
memo = list(itertools.product(['+', '-'], repeat=3))

for i in range(2 ** 3):
    cnt = int(abcd[0])
    for j in range(3):
        if memo[i][j] == '+':
            cnt += int(abcd[j + 1])
        else:
            cnt -= int(abcd[j + 1])
    if cnt == 7:
        print(abcd[0] + memo[i][0] + abcd[1] + memo[i][1] + abcd[2] + memo[i][2] + abcd[3] + '=7')
        break

Submission status: Accepted

Solution code:
def main():
    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] = "+"
        #print(op)
        formula = ""
        #print(list(zip(n,op + [""])))
        for p_n,p_o in zip(n,op + [""]):
            formula += (str(p_n) + p_o)
        #print(formula)
        if eval(formula) == 7:
            print(formula + "=7")
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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(N[0]+"+"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c+d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b-c+d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b+c-d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c+d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c-d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a+b-c-d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c-d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()

Submission status: Accepted

Solution code:
a = input()

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

    sum = a[0] + N[0] + a[1] + N[1] + a[2] + N[2] + a[3]
    if eval(sum) == 7:
        print(sum + "=7")
        exit()

Submission status: Accepted

Solution code:
s=input()
for i in range(8):
  e=bin(i)[2:].zfill(3).replace("0","+").replace("1","-")+"="
  x="".join("".join(c )for c in zip(s,e))[:-1]
  if eval(x)==7:print(x+"=7");exit()

Submission status: Accepted

Solution code:
import sys

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] = "-"
    s = ""
    
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[N]
    if 7==eval(s):
        print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+"=7")
        sys.exit()

Submission status: Accepted

Solution code:
s = input()

n = len(s) - 1
ans = 0
for i in range(1 << n):
    exp = s[0]
    for j in range(n):
        if i & (1 << j):
            exp += "+"
        else:
            exp += "-"
        exp += s[j + 1]
    if eval(exp) == 7:
        ans = exp

ans += "=7"
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
def main():
    s = str(input())
    n = len(s)
    for i in range(2**(n-1)):
        op = ["+"]*(n-1)
        for j in range(n-1):
            if ((i >> j) & 1):
                op[j] = "-"
        formula = ""
        for p_s , p_o in zip(s, op+[""]):
            formula += p_s + p_o
        if (eval(formula)==7):
            print(formula+"=7")
            return
main()

Submission status: Accepted

Solution code:
s = input()
for i in range(2**3):
    plusminus = ["+"]*3
    for j in range(3):
        if (i >> j) & 1:
            plusminus[j] = "-"
    key = s[0] + plusminus[0] + s[1] + plusminus[1] + s[2] + plusminus[2] + s[3]
    if eval(key) == 7:
        print(key+"=7")
        break

Submission status: Accepted

Solution code:
def main():
    s = str(input())
    n = len(s)
    for i in range(2**(n-1)):
        op = ["+"]*(n-1)
        for j in range(n-1):
            if ((i >> j) & 1):
                op[j] = "-"
        formula = ""
        for p_s , p_o in zip(s, op+[""]):
            formula += p_s + p_o
        if (eval(formula)==7):
            print(formula+"=7")
            return
main()

Submission status: Accepted

Solution code:
num = input()
pm_cnt = len(num)  - 1

for i in range(2 ** pm_cnt):
  pm = ["-"] * pm_cnt
  for j in range(pm_cnt):
    if ((i >> j) & 1):
      pm[pm_cnt - 1 - j] = "+"

  ans = ""

  for p_n, p_o in zip(num, pm + [""]):
    ans += (p_n + p_o)
  if eval(ans) == 7:
    print(ans + "=7")
    break

Submission status: Accepted

Solution code:
abcd = input()
n = len(abcd) - 1
form_list = []
for i in range(2 ** n):
    form = abcd[0]
    for j in range(n):
        if ((i >> j) & 1):
            form += "+" + abcd[j + 1]
        else:
            form += "-" + abcd[j + 1]
    form_list.append(form)
#form_list
flag = False
for formula in form_list:
    if eval(formula) == 7:
        #print(formula)
        flag = True
        break
if flag:
    print(formula + "=7")

Submission status: Accepted

Solution code:
nums = input()


for i in range(8):
    operands = []
    sum_num = int(nums[0])
    for j in range(3):
        if i >> j & 1:
            sum_num += int(nums[j+1])
            operands.append("+")
        else:
            sum_num -= int(nums[j+1])
            operands.append("-")
    if sum_num == 7:
        result = []
        operands.append("")
        for num, operand in zip(nums, operands):
            result.append(num)
            result.append(operand)
        print("".join(result) + "=7")
        break

Submission status: Accepted

Solution code:
def main():
    #import sys
    #input = sys.stdin.readline
    ABCD = input()
    A = int(ABCD[0])
    B = int(ABCD[1])
    C = int(ABCD[2])
    D = int(ABCD[3])
    op_max = format(7,"03b")
    for i in range(int(op_max,2)+1):
        res = A
        now = format(i,"03b")
        op_s = []
        for j in range(len(now)):
            if now[j] == "0":
                op_s.append("+")
            elif now[j] == "1":
                op_s.append("-")
        if op_s[0] == "+":
            res += B
        elif op_s[0] == "-":
            res -= B
        if op_s[1] == "+":
            res += C
        elif op_s[1] == "-":
            res -= C
        if op_s[2] == "+":
            res += D
        elif op_s[2] == "-":
            res -= D
        if res == 7:
            print(str(A)+op_s[0]+str(B)+op_s[1]+str(C)+op_s[2]+str(D)+"=7")
            exit()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

M = list(input())
N = [int(m) for m in M]

ans_list = [N[0],'+',N[1],'+',N[2],'+',N[3],'=',7]

for i in range(1<<3):
    tmp = N[0]
    for j in range(3):
        if i & (1<<j):
            tmp += N[j+1]
            ans_list[j*2+1] = '+'
        else:
            tmp -= N[j+1]
            ans_list[j*2+1] = '-'
    if tmp == 7:
        ans_maped = map(str,ans_list)
        ans = ''.join(ans_maped)
        print(ans)
        break

Submission status: Accepted

Solution code:
s=list(map(int,list(input())))
if s[0]+s[1]+s[2]+s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"+"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]+s[1]+s[2]-s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"+"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]+s[1]-s[2]+s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"-"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]+s[1]-s[2]-s[3]==7:
    print(str(s[0])+"+"+str(s[1])+"-"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]-s[1]+s[2]+s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"+"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]-s[1]+s[2]-s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"+"+str(s[2])+"-"+str(s[3])+"=7")
elif s[0]-s[1]-s[2]+s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"-"+str(s[2])+"+"+str(s[3])+"=7")
elif s[0]-s[1]-s[2]-s[3]==7:
    print(str(s[0])+"-"+str(s[1])+"-"+str(s[2])+"-"+str(s[3])+"=7")

Submission status: Accepted

Solution code:
abcd = list(input())
a, b, c, d = (int(abcd[i]) for i in range(4))

dict = {1: "+", -1: "-"}

for k in [1, -1]:
    for l in [1, -1]:
        for m in [1, -1]:
            if a + (k * b) + (l * c) + (m * d) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, dict[k], b, dict[l], c, dict[m], d))
                exit()

Submission status: Accepted

Solution code:
s = list(input())
s = [int(i) for i in s]
for i in range(0, 8):
    t = str(s[0])
    a = s[0]
    c = format(i, '03b')
    for j in range(3):
        if c[j] == "0":
            a -= s[j+1]
            t += "-"+str(s[j+1])
        else:
            a += s[j+1]
            t += "+"+str(s[j+1])
    if a == 7:
        print(t+"=7")
        break

Submission status: Accepted

Solution code:
S = input()
ans = ""
for b in range(2**(3)):
    ans = ""
    for i,s in enumerate(S):
        ans += s
        if b & 1 << i:
            ans += "+"
        else:
            ans += "-"
    ans = ans[:-1]
    if eval(ans)==7:
        print("{}=7".format(ans))
        break

Submission status: Accepted

Solution code:
s = list(input())

enzan = ["+","-"]

for a in enzan:
    for b in enzan:
        for c in enzan:
            ans = s[0] + a + s[1] + b + s[2] + c + s[3]
            if eval(ans) == 7:
                print(ans+"=7")
                exit()

Submission status: Accepted

Solution code:
def op(a,b,n):
  if n == 0:
    return a+b
  else:
    return a-b
def p(n):
  if n == 0:
    return '+'
  else:
    return '-'
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
for i in range(2):
  for j in range(2):
    for k in range(2):
      s1 = op(a,b,i)
      s2 = op(s1,c,j)
      tmp = op(s2,d,k)
      if tmp == 7:
        ans = str(a) + p(i) + str(b) + p(j) + str(c) + p(k) + str(d) +"=7"
        print(ans)
        exit()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

                
def resolve():
    a=list(input())
    A=["+","-"]
    temp=""
    for i in A:
        for j in A:
            for k in A:
                temp=a[0]+i+a[1]+j+a[2]+k+a[3]
                if eval(temp)==7:
                    print(temp+"=7")
                    return
        #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1222"""
        output = """1+2+2+2=7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """0290"""
        output = """0-2+9+0=7"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3242"""
        output = """3+2+4-2=7"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Submission status: Accepted

Solution code:
s = list(input())
a, b, c, d = map(int, s)
op = ['+', '+', '+']

sums = a + b + c + d

for i in range(2):
    for j in range(2):
        for k in range(2):
            if sums - (2 *b * i + 2* c * j + 2* d * k) == 7:
                if i == 1:
                    op[0] = '-'
                if j == 1:
                    op[1] = '-'
                if k == 1:
                    op[2] = '-'
                print('{}{}{}{}{}{}{}=7'.format(a, op[0], b, op[1], c, op[2], d))
                exit()

Submission status: Accepted

Solution code:
n = [int(x) for x in input()]
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):  # 000→001→010→...
    ops = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if (i >> j) & 1:
            ops[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き
    # print(op)  # ['-', '-']\n['-', '+']\n['+', '-']\n['+', '+']

    formula = str(n[0])
    for op, num in zip(ops, n[1:]):
        formula += op + str(num)

    if eval(formula) == 7:  # 文字列数式→数式
        print(formula + "=7")
        exit()

Submission status: Accepted

Solution code:
import sys

A, B, C, D = list(input())

op = ["+", "-"]

for i in range(2):
    for j in range(2):
        for k in range(2):
            f = A + op[i] + B + op[j] + C + op[k] + D
            # print(f)
            if eval(f) == 7:
                print(f, "=7", sep="")
                sys.exit()

Submission status: Accepted

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

import math

#ans = ['']*3

def p_m(num):
  if math.floor(num)%2 == 0:
    return '+'
  else :
    return '-'

for i in range(8):
  if a + ( (-1)**(math.floor(i/4)) )*b + ((-1)**(math.floor(i/2)))*c + ((-1)**(math.floor(i)))*d == 7:
#    ans = [p_m(i/4),p_m(i/2),p_m(i)]
    break

print(str(a)+p_m(i/4)+str(b)+p_m(i/2)+str(c)+p_m(i)+str(d)+'=7')

Submission status: Accepted

Solution code:
import sys

A, B, C, D = list(input())

op = ["+", "-"]

for i in range(2):
    for j in range(2):
        for k in range(2):
            f = A + op[i] + B + op[j] + C + op[k] + D
            # print(f)
            if eval(f) == 7:
                print(f, "=7", sep="")
                sys.exit()

Submission status: Accepted

Solution code:
ABCD=input()
A=ABCD[0]
B=ABCD[1]
C=ABCD[2]
D=ABCD[3]
for i in range((len(ABCD)-1)**2):
    aida=["-"]*(len(ABCD)-1)
    for j in range(len(ABCD)-1):
        if ((i>>j)&1):
            aida[len(ABCD)-2-j]="+"
    ks=A+aida[0]+B+aida[1]+C+aida[2]+D
    if eval(ks)==7:
        print(ks+"=7")
        exit()

Submission status: Accepted

Solution code:
import sys

ABCD = input()
for n in range(2 ** (len(ABCD) - 1)):
    value = ""
    for i in range(len(ABCD) - 1):
        value += ABCD[i]
        if n & (2 ** i) != 0:
            value += "+"
        else:
            value += "-"
    value += ABCD[-1]
    if eval(value) == 7:
        print(value + "=7")
        sys.exit()

Submission status: Accepted

Solution code:
x=list(map(int,input()))
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()
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()
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()
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()
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()
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()
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()
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()

Submission status: Accepted

Solution code:
a = list(input())
op = ['-'] * 3
for i in range(2**3):
    ans = int(a[0])
    for j in range(3):
        if 1 & (i>>j):
            ans += int(a[3-j])
            op[2-j] = '+'
        else:
            ans -= int(a[3-j])
            op[2-j] = '-'
    if ans == 7:
        break
print(a[0] + op[0] + a[1] + op[1] + a[2] + op[2] +a[3] + "=7")

Submission status: Accepted

Solution code:
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = []

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):
                sign.append(i)
                sign.append(j)
                sign.append(k)

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "+"
    else:
        sign[n] = "-"

print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")

Submission status: Accepted

Solution code:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import sys
input = sys.stdin.readline

s = input()
a,b,c,d=[int(s[i]) for i in range(4)]
op = -1
ans = []
for i in range(2):
    for j in range(2):
        for m in range(2):
            if (a+b*op**i+c*op**j+d*op**m)==7:
                ans.append(i)
                ans.append(j)
                ans.append(m)
for i in range(3):
    if ans[i]==0:
        ans[i]="+"
    else:
        ans[i]="-"
print(s[0]+ans[0]+s[1]+ans[1]+s[2]+ans[2]+s[3]+"=7")

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
num = list(map(int,list(str(input()))))

for i in range(2**3):
  temp = 0
  
  for j in range(len(num)):
    if j == 0:
      temp = num[j]
      ans = str(num[j])
      continue
    
    if ((i >> j-1)&1):
      temp = temp + num[j]
      ans = ans + "+" + str(num[j])
      
    elif not ((i >> j-1)&1):
      temp = temp - num[j]
      ans = ans + "-" + str(num[j])
      
  if temp == 7:
    ans = ans + "=7"
    print(ans)
    break

Submission status: Accepted

Solution code:
A = input()
a,b,c,d = map(int,[A[0],A[1],A[2],A[3]])

op = ['-','+']
for i in range(8):
  o = format(i, '03b')
  if o[0] == str(0):
    s = a-b
  else:
    s = a+b
  if o[1] == str(0):
    s = s-c
  else:
    s = s+c
  if o[2] == str(0):
    s = s-d
  else:
    s = s+d
  if s == 7:
    print(str(a)+op[int(o[0])]+str(b)+op[int(o[1])]+str(c)+op[int(o[2])]+str(d)+'=7')
    break

Submission status: Accepted

Solution code:
ns = list(map(int, list(input())))

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

Submission status: Accepted

Solution code:
s=input()
A, B, C, D = [int(s_) for s_ in s]

for ii in range(8):
    first  = ii >> 0 & 1
    second = ii >> 1 & 1
    third  = ii >> 2 & 1
    sum = A
    if first == 0:
        sum -= B
        first_op = '-'
    else:
        sum += B
        first_op = '+'
    if second == 0:
        sum -= C
        second_op = '-'
    else:
        sum += C
        second_op = '+'
    if third == 0:
        sum -= D
        third_op = '-'
    else:
        sum += D
        third_op = '+'
    if sum == 7:
        print(str(A)+first_op+str(B)+second_op+str(C)+third_op+str(D)+'=7')
        exit()

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
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[j]="+"

    formula=""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Accepted

Solution code:
A, B, C, D = map(int, input())
O = [B, C, D]

N = len(O)
ans = []

## 一桁目は、Plus固定かな

for i in range(2**(N)):
    tmp_list = []
    tmp_count = 0
    for j in range(N):
        if (i>>j)&1:
            tmp_list.append("+")
            tmp_count += O[j]
        else:
            tmp_list.append("-")
            tmp_count -= O[j]
            
    if A + tmp_count == 7:
        ans = []
        for k in range(N):
            ans.append(tmp_list[k] + str(O[k]))


print(str(A) + "".join(ans) + "=7")

Submission status: Accepted

Solution code:
S = input()
N = len(S)
op_cnt = N - 1

for i in range(2 ** op_cnt):
    op = ["+"] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = "-"
    op.append("")
    ans = []
    for num,ops in zip(S,op):
        ans.append(num)
        ans.append(ops)
    ans = [_ for _ in ans if _ != ""]
    ans = ''.join(ans)
    if eval(ans) == 7:
        print(ans + '=7')
        break

Submission status: Accepted

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

def helper(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ""
    
    op_p = helper(i+1, x+int(s[i]), op + "+" + s[i])
    if op_p != "":
        return op_p
    
    op_m = helper(i+1, x-int(s[i]), op + "-" + s[i])
    if op_m != "":
        return op_m
    
    return ""


result = helper(1, int(s[0]), s[0])
if result == "":
    print(result)
else:
    print(result + "=7")

Submission status: Accepted

Solution code:
S = input()
for i in range(2 ** (len(S) - 1)):
    ope = ['-'] * (len(S) - 1)
    for j in range(len(S) - 1):
        if ((i >> j) & 1):
            ope[2 - j] = '+' # j=0->ope[2], j=1->ope[1], j=2->ope[0]
    ans = ''
    ans += S[0]+ope[0]+S[1]+ope[1]+S[2]+ope[2]+S[3]
    if eval(ans) == 7:
        ans += '=7'
        break

print(ans)

Submission status: Accepted

Solution code:
s = str(input())

ans = ''
for i in range(8):
  bin_str = format(i, '03b')
  #print(bin_str)

  total = int(s[0])
  formula = s[0]
  for oper, num in zip(bin_str, s[1:]):
    if int(oper) == 1:
      total += int(num)
      formula += '+' + str(num)
    else:
      total -= int(num)
      formula += '-' + str(num)

  if total == 7:
    ans = formula
    break

print(ans + '=7')

Submission status: Accepted

Solution code:
s=list(input())

hugou=[]
for i in range(8):
  z=[]
  k=0
  ans=0
  for j in range(3):
    if k==0:
      z.append(s[k])
      ans+=int(s[k])
    if ((i>>j)&1):
      z.append("+")
      k+=1
      ans+=int(s[k])
      z.append(s[k])
    else:
      z.append("-")
      k+=1
      ans-=int(s[k])
      z.append(s[k])
  if ans==7:
    print("".join(z)+"=7")
    break

Submission status: Accepted

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

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Accepted

Solution code:
s = list(map(int, input()))
for bit in range(1 << 3):
    n = 7 - s[0]
    ans = str(s[0])
    for i in range(3):
        if bit & (1 << i):  # 足し算の処理
            n -= s[i + 1]
            ans += '+' + str(s[i + 1])
        else:
            n += s[i+ 1]
            ans += '-' + str(s[i+1])
    if n == 0:
        print(ans + '=7')
        break

Submission status: Accepted

Solution code:
S = input()
for i in range((len(S) - 1) ** 2 - 1):
    ope = ['-'] * (len(S) - 1)
    for j in range(len(S) - 1):
        if ((i >> j) & 1):
            ope[2 - j] = '+' # j=0->ope[2], j=1->ope[1], j=2->ope[0]
    ans = ''
    ans += S[0]+ope[0]+S[1]+ope[1]+S[2]+ope[2]+S[3]
    if eval(ans) == 7:
        ans += '=7'
        break

print(ans)

Submission status: Accepted

Solution code:
a, b, c, d = map(int, list(input()))
# print(a, b, c, d)

def add(x, y):
    return x + y


def sub(x, y):
    return x - y

for op1 in [('+', add), ('-', sub)]:
    for op2 in [('+', add), ('-', sub)]:
        for op3 in [('+', add), ('-', sub)]:
            result = op3[1](op2[1](op1[1](a, b), c), d)
            if result == 7:
                print(str(a) + op1[0] + str(b) + op2[0] + str(c) + op3[0] + str(d) + '=7')
                exit(0)

Submission status: Accepted

Solution code:
seq=input()
list=[]
for i in range(4):
    list.append(int(seq[i]))
ans=[]
brk=0
for a in range (2):
    for b in range (2):
        for c in range (2):
            if list[0]+(2*a-1)*list[1]+(2*b-1)*list[2]+(2*c-1)*list[3]==7:
                ans.append(a)
                ans.append(b)
                ans.append(c)
                brk+=1
                break
        if brk!=0:
            break
    if brk!=0:
        break
A=""
B=""
C=""
if a==0:
    A="-"
else:
    A="+"
if b==0:
    B="-"
else:
    B="+"    
if c==0:
    C="-"
else:
    C="+"
print(str(list[0])+A+str(list[1])+B+str(list[2])+C+str(list[3])+"=7")

Submission status: Accepted

Solution code:
import itertools
ns=""
def calc(nums,op):
    sum=int(nums[0])
    for i in range(0,3):
        if op[i]=="+":
            sum=sum+int(nums[i+1])
        elif op[i]=="-":
            sum=sum-int(nums[i+1])
    return sum
S=list(input())
l=["+","-"]
p_list=list(itertools.product(l,l,l))
#print(p_list)

for i in range(len(p_list)):
    if calc(S,list(p_list[i]))==7:
        #print(S,list(p_list[i]))
        ans=list(p_list[i])
        ns="".join((ns,S[0]))
        for i in range(3):
            ns="".join((ns,ans[i],S[i+1]))
        ns = "".join((ns,"=7"))
        print(ns)
        break

Submission status: Accepted

Solution code:
import sys

N = list(input())
op = ["-", "+"]
shiki = ""
ev = []
ans = 0
for bit in range(1 << 3):
    ev.append(N[0])
    for i in range(3):
        if bit & (1 << i):
            ev.append(op[0])
        else:
            ev.append(op[1])
        ev.append(N[i + 1])
    shiki = "".join(ev)
    ans = eval(shiki)
    if ans == 7:
        print(shiki + "=7")
        sys.exit()
    ev.clear()

Submission status: Accepted

Solution code:
a = list(input())
for i in range(4):
    a[i] = int(a[i])

n = 3

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

    cal = "{}{}{}{}{}{}{}".format(a[0], sym[0], a[1], sym[1], a[2], sym[2], a[3])
    ans = eval(cal)
    if ans == 7:
        print("{}={}".format(cal, eval(cal)))
        break

Submission status: Accepted

Solution code:
number = input()

ans_list = []
indexes = [1, 3, 5]
def make_seven(num, index):
    if index == 3:
        if eval(num) == 7:
            ans_list.append(num+"=7")
        return

    make_seven(num[:indexes[index]]+"+"+num[indexes[index]:], index+1)
    make_seven(num[:indexes[index]]+"-"+num[indexes[index]:], index+1)

make_seven(number, 0)
print(ans_list[0])