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

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

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

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


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

    if sum == 7:
        print(f + "=7")
        break

Solution (Python):
s = input()

for bit in range(1<<3):
    ans=int(s[0])
    f=s[0]
    
    for j in range(3):
        if bit & (1<<j):
            ans+=int(s[j+1])
            f+="+"
        else:
            ans-=int(s[j+1])
            f+="-"
        
        f+=s[j+1]
    
    if ans == 7:
        print(f + "=7")
        exit()

Solution (Python):
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

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

Solution (Python):
S=input()
A=[int(s) for s in S]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if A[0]+A[1]*(-1)**i+A[2]*(-1)**j+A[3]*(-1)**k==7:
                temp=[i,j,k]
                break
ans=S[0]
for l in range(3):
    if temp[l]==0:
        ans+="+"
    else:
        ans+="-"
    ans+=S[l+1]
print(ans+"=7")

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

for n in range(2**3):
    sum_N=N[0]
    l=[]
    for i in range(3):
        if (n>>i)&1==1:
            sum_N+=N[i+1]
            l.append("+")
        else:
            sum_N-=N[i+1]
            l.append("-")
    if sum_N==7:
        break
print("{}{}{}{}{}{}{}".format(N[0],l[0],N[1],l[1],N[2],l[2],N[3])+"=7")

Solution (Python):
s=input()
item=["+","-"]
 
last = ""
for op1 in item:
  for op2 in item:
    for op3 in item:
      ans = s[0] + op1 + s[1] + op2 + s[2] + op3 +s[3]
      if eval(ans)==7:
        last = ans+"=7"
print(last)

Solution (Python):
def ans(s, c):
	d, *n = map(str, s)
	for j in range(len(n)):
		if ((c >> j) & 1):
			d = d + '+' + n[j]
		else:
			d = d + '-' + n[j]
	print(d + '=' + '7')

def resolve():
	s = [int(i) for i in input()]
	c = 0

	for i in range(1 << len(s) - 1):
		ts = s[1:]
		k = s[0]
		for j in range(len(s)-1):
			if ((i >> j) & 1):
				k += ts[0]
			else:
				k -= ts[0]
			ts = ts[1:]
		if k == 7:
			c = i
	ans(s, c)

resolve()

Solution (Python):
from itertools import product


ABCD = list(input())

OPERATIONS = list(product("+-", repeat = 3))

for operation in OPERATIONS:
    for i in range(3):
        ABCD.insert(2 * i + 1, operation[i])
    if eval("".join(ABCD)) == 7:
        print("".join(ABCD) + "=7")
        exit()
    for i in range(3)[::-1]:
        ABCD.pop(2 * i + 1)

Solution (Python):
s = str(input())
length = len(s)

bins = []
for i in range(2**(length-1)):
    bins.append(list(str(format(i,'b')).zfill(length-1)))

for i in range(2**(length-1)):
    tmp_str=s[0]
    tmp_ans=int(s[0])
    for j in range(length-1):
        if(bins[i][j]=='0'):
            tmp_str += '+'+s[j+1]
            tmp_ans += int(s[j+1])
        else:
            tmp_str += '-'+s[j+1]
            tmp_ans -= int(s[j+1])
    if(tmp_ans == 7):
        ans = tmp_str

print(ans+'=7')

Solution (Python):
S = input()
N = len(S)

ans = 0
for i in range(2 ** (N - 1)):
    signs = bin(i)[2:].zfill(N - 1).replace('0', '+').replace('1', '-')

    tmp_s = S[0]
    for j, sign in enumerate(signs):
        tmp_s += sign + S[j + 1]

    if eval(tmp_s) == 7:
        print(tmp_s + '=7')
        exit()

Solution (Python):
s=input()
s=list(map(str,str(s)))
l=len(s)-1

for i in range(2**l):
    listA=['+']*len(s)
    for j in range(l):
        if ((i>>j)&1):
            listA[j]='-'
    listB=[]
    for o,p in zip(s,listA):
        listB.append(o)
        listB.append(p)
    del listB[-1]
    listC=''.join(listB)
    ans=eval(listC)
    if ans==7:
        print('{}=7'.format(listC))
        break

Solution (Python):
n = int(input())
t=0
A=n//1000
B=(n-A*1000)//100
C=(n-A*1000-B*100)//10
D=n%10

for i in range(8):
    k=A
    if i%2==0:
        k+=B
        p="+"
    else:
        k-=B
        p="-"
    if (i//2)%2==0:
        k += C
        q="+"
    else:
        k -= C
        q="-"
    if (i//4)%2==0:
        k += D
        r="+"
    else:
        k -= D
        r="-"
    if k==7:
        a=p
        b=q
        c=r
        t=1
if t>0:
    x=str(A)+a+str(B)+b+str(C)+c+str(D)+"=7"
    print(x)

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

for op1 in ["+", "-"]:
    for op2 in ["+", "-"]:
        for op3 in ["+", "-"]:
            total = a
            if op1 == "+":
                total += b
            else:
                total -= b
            if op2 == "+":
                total += c
            else:
                total -= c
            if op3 == "+":
                total += d
            else:
                total -= d
            if total == 7:
                print(a, op1, b, op2, c, op3, d, "=7", sep="")
                quit()

Solution (Python):
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 = a
            if i==0:
                ans += b
                X="+"
            else:
                ans -= b
                X="-"
            if j==0:
                ans += c
                Y="+"
            else:
                ans -= c
                Y="-"
            if k==0:
                ans += d
                Z="+"
            else:
                ans -= d
                Z="-"
            if ans==7:
                print(str(a)+X+str(b)+Y+str(c)+Z+str(d)+"=7")
                exit()

Solution (Python):
import sys
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")
    sys.exit
elif (a+b+c-d == 7):
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit    
elif (a+b-c+d == 7):
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit  
elif (a+b-c-d == 7):
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit      
elif (a-b+c+d == 7):
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit  
elif (a-b+c-d == 7):
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit  
elif (a-b-c+d == 7):
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit  
elif (a-b-c-d == 7):
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit

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()
dfs(0, abcd[0], int(abcd[0]))

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


def f(ans, i, shift, operand):
    if int(bin(i >> shift)[-1]):
        ans += operand
        ops.append('+')
    else:
        ans -= operand
        ops.append('-')
    return ans, ops


for i in range(8):
    ops = []
    ans = a
    ans, ops = f(ans, i, 2, b)
    ans, ops = f(ans, i, 1, c)
    ans, ops = f(ans, i, 0, d)
    if ans == 7:
        print(a, ops[0], b, ops[1], c, ops[2], d, '=7', sep='')
        break

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

import itertools

A, B, C, D = list(read().rstrip().decode('utf-8'))

for operators in itertools.product(['+', '-'], repeat=3):
    op1, op2, op3 = operators
    eq = A + op1 + B + op2 + C + op3 + D
    x = eval(eq)
    if x == 7:
        break

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, C, D = list(read().rstrip().decode('utf-8'))

def F(op, v1, v2):
    if op == "1":
        return v1 + v2
    else:
        return v1 - v2

for operators in [list(format(i, "03b")) for i in range(2**3)]:
    op1, op2, op3 = operators
    op1 = "+" if op1 == "1" else "-"
    op2 = "+" if op2 == "1" else "-"
    op3 = "+" if op3 == "1" else "-"

    eq = A + op1 + B + op2 + C + op3 + D
    x = eval(eq)
    if x == 7:
        break

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, C, D = map(int, list(read().rstrip().decode('utf-8')))

def F(op, v1, v2):
    if op == "1":
        return v1 + v2
    else:
        return v1 - v2

for operators in [list(format(i, "03b")) for i in range(2**3)]:
    op1, op2, op3 = operators
    tmp = F(op1, A, B)
    tmp = F(op2, tmp, C)
    tmp = F(op3, tmp, D)

    if tmp == 7:
        op1 = "+" if op1 == "1" else "-"
        op2 = "+" if op2 == "1" else "-"
        op3 = "+" if op3 == "1" else "-"
        answer = str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7"
        print(answer)
        quit()

Solution (Python):
abcd = list(map(int,list(input())))
bins = []

for i in range(2**3):
    bins.append(list(str(format(i,'b').zfill(3))))

for i in range(8):
    res=abcd[0]
    ans = str(abcd[0])
    for j in range(3):
        if bins[i][j] == '0':
            res += (abcd[j+1])
            ans += '+'
            ans += str(abcd[j+1])
        
        else:
            res -= (abcd[j+1])
            ans += '-'
            ans += str(abcd[j+1])
    
    if res == 7:
        print(ans+'=7')
        break

Solution (Python):

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

s = ''

for i in range(8):
    s = str(abcd[0])    
    tmp = abcd[0]       
    for j in range(3):
        
        
        if (1 << j) & i == 0:
            s += '+'
            tmp += abcd[j + 1]
        else:
            s += '-'
            tmp -= abcd[j + 1]
        s += str(abcd[j + 1])
    s += '=7'
    if tmp == 7:
        break
print(s)

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

bins = []

for i in range(2**3):
    bins.append(list(str(format(i,'b').zfill(3))))


for i in range(8):
    res = a
    
    for j in range(3):
        if j == 0 and bins[i][j] == '0':
            res += b
        
        if j == 0 and bins[i][j] == '1':
            res -= b
        
        if j == 1 and bins[i][j] == '0':
            res += c
        
        if j == 1 and bins[i][j] == '1':
            res -= c
        
        if j == 2 and bins[i][j] == '0':
            res += d
        
        if j == 2 and bins[i][j] == '1':
            res -= d
    
    if res == 7:
        ans = str(a)
        for k in range(3):
            if bins[i][k] == '0':
                ans += '+'
            
            else:
                ans += '-'
            
            ans += str([a,b,c,d][k+1])

print(ans+'=7')

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

for i in range(2**3):
    ls = ["+"] *3
    for j in range(len(ls)):
        if (i>>j) & 1:
            ls[j] = "-"
    ans = a+ls[0]+b+ls[1]+c+ls[2]+d
    if eval(ans) == 7:
        print(ans+"=7")
        break

Solution (Python):

n = input()
op_cnt = len(n) - 1 
for i in range(2**op_cnt):
    op = ["-"]*op_cnt 
    for j in range(op_cnt):
        if((i>>j)&1):
            op[op_cnt -1 -j] = "+" 
    
    formula = ""
    for p_n,p_o in zip(n, op+[""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
S = list(map(int, list(input())))
for pattern in range(1 << 3):
    this_sum = S[0]
    for i in [1, 2, 3]:
        if pattern & 1 << i-1:
            this_sum += S[i]
        else:
            this_sum -= S[i]
    if this_sum == 7:
        break
output = str(S[0]) + "".join(["-+"[bool(pattern & 1 << i-1)] + str(S[i]) for i in [1, 2, 3]]) + "=7"
print(output)

Solution (Python):
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    *S, = iss()
    E = ['+', '-']
    tmp = [0] * 7
    for e in E:
        tmp[0] = S[0]
        tmp[1] = e
        for e in E:
            tmp[2] = S[1]
            tmp[3] = e
            for e in E:
                tmp[4] = S[2]
                tmp[5] = e
                tmp[6] = S[3]
                ans = ''.join(map(str, tmp))
                if eval(ans) == 7:
                    print(ans + '=7')
                    exit()


if __name__ == '__main__':
    main()

Solution (Python):
S = input()

for a in '+-':
  for b in '+-':
    for c in '+-':
      ans = S[0] + a + S[1] + b + S[2] + c + S[3]
      if eval(ans) == 7:
        print(ans + '=7')
        exit()

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

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

ptn = []
for bit in range(2**(n-1)):
    p = []
    for i in range(n-1):
        if ((bit>>i)&1):
            p.append('+')
        else:
            p.append('-')
    ptn.append(p)

for p in ptn:
    for i, s in enumerate(S):
        if i == 0:
            result = int(s)
            continue
        if p[i-1]=='+':
            result += int(s)
        else:
            result -= int(s)
    if result == 7:
        print('{}{}{}{}{}{}{}=7'.format(S[0],p[0],S[1],p[1],S[2],p[2],S[3]))
        break

Solution (Python):
a = list(input())
a,b,c,d = int(a[0]), int(a[1]), int(a[2]), int(a[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 pm(S,a,i):
	if i == 0:
		S += a
	else:
		S -= a

	return S

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


if __name__ == '__main__':
	S = input()
	A = int(S[0])
	B = int(S[1])
	C = int(S[2])
	D = int(S[3])

	ans = ''

	for a in range(2):
		for b in range(2):
			for c in range(2):	
				goukei = A
				goukei = pm(goukei,B,a)
				goukei = pm(goukei,C,b)
				goukei = pm(goukei,D,c)

				if goukei == 7:

					ans = S[0] + ch(a) + S[1] + ch(b) + S[2] + ch(c) + S[3] + '=7'
					break
					break
					break

	print(ans)

Solution (Python):
import sys

n = input()

code_1 = ['+', '-']
code_2 = ['+', '-']
code_3 = ['+', '-']

answer = ''
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            sum_num = 0
            if code_1[i] == '+':
                sum_num += int(n[0]) + int(n[1])
            else:
                sum_num += int(n[0]) - int(n[1])
            if code_2[j] == '+':
                sum_num += int(n[2])
            else:
                sum_num -= int(n[2])
            if code_3[k] == '+':
                sum_num += int(n[3])
            else:
                sum_num -= int(n[3])
            if sum_num == 7:
                answer = n[0] + code_1[i] + n[1] + code_2[j] + n[2] + code_3[k] + n[3] + '=7'
                flag = True
            if flag:
                break

        if flag:
            break
    
    if flag:
        break


print(answer)

Solution (Python):
N = input()
a = []
n = len(N)
k = 7

for i in range(len(N)):
    a.append(int(N[i]))

X = [0]*(n-1)
flag = False

for i in range(2**(n-1)):
    if flag:
        break
    S = a[0]
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            X[j] = 1
            S += a[j+1]
        else:
            X[j] = 0
            S -= a[j+1]
    if S == k:
        flag = True
        break
print(a[0], end="")
for i in range(3):
    if X[i] == 1:
        print('+', end='')
    else:
        print('-', end='')
    print(a[i+1], end="")
print('=', end='')
print(k)

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

for i in range(1 << n):
    aa = ["-"] * n
    for j in range(n):
        if (i >> j) % 2 == 1:
            aa[n - 1 -j] = "+"
    sum = 0
    for index, x in enumerate(list):
        if index == 0:
            sum = int(x)
        else:
            if aa[index-1] == "+":
                sum = sum + int(x)
            elif aa[index-1] == "-":
                sum = sum - int(x)

    if sum == 7:
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(list[0], aa[0], list[1],
                                               aa[1], list[2], aa[2],
                                               list[3]))
        exit()

Solution (Python):
S = input()
 
n = len(S)
S_list = [int(S[0]), int(S[1]), int(S[2]), int(S[3])]
 

def bit_to_notation(bit):
  bitlist = [0 for i in range(n-1)] 
  for i in range(n-1):
    if ((bit >> i) & 1):
      bitlist[n-2-i] = "+"
    else:
      bitlist[n-2-i] = "-"
  return bitlist
 
notation = 2 ** (n-1)
for bit in range(notation):
  sum4 = S_list[0]
  for j in range(n-1):
    if((bit >> j) & 1):
      sum4 += S_list[n-1-j]
    else:
      sum4 -= S_list[n-1-j]
      
  if(sum4 == 7):
    
    bitlist = bit_to_notation(bit)
    print(str(S_list[0]) + bitlist[0] + str(S_list[1]) + bitlist[1] 
          + str(S_list[2]) + bitlist[2] + str(S_list[3]) + "=7")
    break

Solution (Python):






def main():
    a, b, c, d = list(map(int, list(input())))

    def p(x, y):
        return x + y
    
    def m(x, y):
        return x - y
    
    conv = {0: "+", 1: "-"}
    
    for i, op1 in enumerate([p, m]):
        for j, op2 in enumerate([p, m]):
            for k, op3 in enumerate([p, m]):
                if op3(op2(op1(a, b), c), d) == 7:
                    return "{}{}{}{}{}{}{}=7".format(a, conv[i], b, conv[j], c, conv[k], d)


print(main())

Solution (Python):
import sys

abcd = input()
a = [int(i) for i in abcd]

for i in range(2**3) :
  bit = i
  v = a[0]
  ans = str(v)
  for j in range(1,4) :
    c = bit%2
    bit = bit//2
    if c == 0 :
      v -= a[j]
      ans += '-' + str(a[j])
    else :
      v += a[j]
      ans += '+' + str(a[j])
  if v == 7 :
    print(ans+'=7')
    sys.exit()

Solution (Python):
import sys

abcd=input()

for i in range(8):
	tempsum=int(abcd[0])
	tempmoji=abcd[0]
	
	for j in range(3):
		if(i>>j) & 1:
			tempsum += int(abcd[j+1])
			tempmoji = tempmoji + "+" + abcd[j+1]
		else:
			tempsum -= int(abcd[j+1])
			tempmoji = tempmoji + "-" + abcd[j+1]
	if tempsum == 7:
		print(tempmoji + "=7")
		sys.exit()

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

Solution (Python):
A, B, C, D = map(int, list(str(input())))
ABCD=[A,B,C,D]

for i in range(0, 2**3):
    
    answer=A
    shiki='{}'.format(A)
    for j in range(3):
        
        if ((i >> j) & 1):
            answer+=ABCD[j+1]
            shiki+='+'
        else:
            answer-=ABCD[j+1]
            shiki+='-'
        shiki+='{}'.format(ABCD[j+1])
    
    
    if answer==7:
        shiki+='=7'
        print(shiki)
        break

Solution (Python):
a, b, c, d = map(int, input())
pm = [1, -1]
op = ["+", "-"]
for i in range(2):
  for j in range(2):
    for k in range(2):
      if a + pm[i]*b + pm[j]*c + pm[k]*d == 7:
        ans = [op[i], op[j], op[k]]
        break
print("".join(map(str, [a, ans[0], b, ans[1], c, ans[2], d, "=", 7])))

Solution (Python):

from itertools import product
import sys


def solve(ABCD: str):
    A, B, C, D = ABCD
    for ops in product(["+", "-"], repeat=3):
        expr = "{1}{0[0]}{2}{0[1]}{3}{0[2]}{4}".format(ops, A, B, C, D)
        if eval(expr) == 7:
            print(expr + "=7")
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    ABCD = next(tokens)  
    solve(ABCD)


if __name__ == '__main__':
    main()

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

n = len(A) - 1
for i in range(2**n):
    pattern = ['-']*n 
    ans= A[0]
    
    for j in range(n):
        if ((i >> j) & 1):
            pattern[j]='+'  
            ans+=A[j+1]
        else:
            
            ans-=A[j+1]

    else:
        if ans == 7:
            print(A[0], end='')
            for k in range(n):
                print(pattern[k],end='')
                print(A[k+1],end='')
            else:
                print('=7')
            break

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('{}+{}+{}+{}=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):
abcd = input()

abcd_list = []

def plus_or_minas(abcd_str, pos, abcd):
    if pos == 4:
        abcd_list.append(abcd_str)
        return

    plus_or_minas(abcd_str+'+'+abcd[pos], pos+1, abcd)
    plus_or_minas(abcd_str+'-'+abcd[pos], pos+1, abcd)
    return

plus_or_minas(abcd[0], 1, abcd)

for i_abcd in abcd_list:
    if eval(i_abcd) == 7:
        print(i_abcd+'=7')
        exit()

Solution (Python):
N = input()
A = []
for i in range(len(N)):
    A.append(int(N[i]))

for i in range(2 ** 3):
    List = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            List.append(1)
        elif (i >> j) & 1 == 0:
            List.append(0)
    ans = A[0]
    for k in range(len(List)):
        if (List[k]):
            ans += A[k+1]
        else :
            ans -= A[k+1]

    if ans == 7:
        break

print(A[0], end="")
for i in range(3):
    if List[i]:
        print("+", end="")
    else:
        print("-", end="")
    print(A[i + 1], end="")
print("=7",end="")

Solution (Python):











abcd = input()

for i in range(2**3):
    r = int(abcd[0])
    ans = abcd[0]
    for j in range(3):
        
        if i & (2**j):
            ans = ans + "+" + abcd[j+1]
            r += int(abcd[j+1])
        
        else: 
            ans = ans + "-" + abcd[j+1]
            r -= int(abcd[j+1])
    if r==7:
        output = ans + "=7"


print(output)

Solution (Python):
import sys
s=input()
a=[int(s[i]) for i in range(4)]
for b in [a[1],-a[1]]:
    for c in[a[2],-a[2]]:
        for d in [a[3],-a[3]]:
            if a[0]+b+c+d==7:
                s=str(a[0])
                for x in [b,c,d]:
                    s+="+"+str(x) if x>=0 else str(x)
                s+="=7"
                print(s)
                sys.exit()

Solution (Python):
num = input()


flag = "loop"
op_list = ["+","-"]
for i in op_list:
  if flag == "break":
    break
  for j in op_list:
    if flag == "break":
      break
    for k in op_list:
      if i == "+":
        ans = int(num[0]) + int(num[1])
      else:
        ans = int(num[0]) - int(num[1])
        
      if j == "+":
        ans += int(num[2])
      else:
        ans -= int(num[2])
        
      if k == "+":
        ans += int(num[3])
      else:
        ans -= int(num[3])
      
      if ans == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        flag = "break"
        break
      ans = 0

Solution (Python):
from itertools import product

def main():
    n = [i for i in input()]
    for i in product(('+', '-'), repeat=3):
        formula = n[0]
        for op, num in zip(i, n[1:]):
            formula += op
            formula += num
        if eval(formula) == 7:
            print(formula+'=7')
            exit()

if __name__ == '__main__':
    main()

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

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
            
    formula = ""
    
    for p_n, p_op in zip(n, op + [""]):
        formula += (p_n + p_op)
    if eval(formula) == 7:
        print(formula + "=7")
        break

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

sign = ['+', '-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            tmp = a + sign[i] + b + sign[j] + c + sign[k] + d  
            if eval(tmp) == 7:
                print(tmp+'=7')
                exit()

Solution (Python):
n = [int(x) for x in input()]
s=len(n)-1

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

    sum=n[0]
    ans=str(n[0])
    
    for i in range(s):
        if op[i] == '+':
            sum+=n[i+1]
            ans += '+'
        else:
            sum-=n[i+1]
            ans += '-'
        ans += str(n[i+1])

    if sum == 7:
        ans+='=7'
        print(ans)
        break

Solution (Python):
S = [int(s) for s in input()]

res = []
for i in range(2**4):
    s = S[0]
    c = []
    for j in range(3):
        m = i >> j & 1
        if m == 0:
            s = s + S[j+1]* -1
            c.append("-")
        else:
            s = s + S[j+1]
            c.append("+")

    if s == 7:
        print(str(S[0])+""+c[0]+""+str(S[1])+""+c[1]+""+str(S[2])+""+c[2]+str(S[3])+"=7")
        break

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

for i in range(1 << 3):
    op = [None] * 3
    a = A
    b = B if (i >> 0) & 1 else -B
    op[0] = '+' if (i >> 0) & 1 else '-'

    c = C if (i >> 1) & 1 else -C
    op[1] = '+' if (i >> 1) & 1 else '-'

    d = D if (i >> 2) & 1 else -D
    op[2] = '+' if (i >> 2) & 1 else '-'

    if sum([a, b, c, d]) == 7:
        break

print('{}{}{}{}{}{}{}=7'.format(A, op[0], B, op[1], C, op[2], D))

Solution (Python):
def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"

if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    
    for i in range(1 << bin_pattern_digit):
        
        result = int(abcd[0:1])
        
        for j in range(bin_pattern_digit):

            
            
            
            
            
            
            
            
            

            
            
            if i & 1 << bin_pattern_digit - 1 >> j:
                
                result += int(abcd[j + 1])
            
            else:
                
                result -= int(abcd[j + 1])

        
        if result == 7:
            break

    
    
    
    
    
    
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")

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

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(1<<3):
    su=0
    ans=[]
  
    for j in range(3):
        if (i>>j)&1:
            ans.append('+')
        else: 
            ans.append('-')
    ans=ans[::-1]
    ss=[ int(i) for i in s]
    su+=ss[0]
 

  
    for k in range(1,4):
        if ans[k-1]=='+':
   
            su+=ss[k]
        else:
    
            su-=ss[k]
    
    if su==7:
        for i in range(0,3):
            print(s[i],end='')
            print(ans[i],end='')
        print(s[3],end='')
        print('=7')
        import sys
        sys.exit()

Solution (Python):
import sys
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")
  sys.exit()
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b-c-d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()

Solution (Python):
a = list(input())






op = [
    ["+", "+", "+"],
    ["+", "+", "-"],
    ["+", "-", "+"],
    ["+", "-", "-"],
    ["-", "+", "+"],
    ["-", "+", "-"],
    ["-", "-", "+"],
    ["-", "-", "-"],
]

for i in range(2 ** 3):
    for j in op:
        s = a[0] + j[0] + a[1] + j[1] + a[2] + j[2] + a[3]
        if eval(s) == 7:
            print(s + "=7")
            exit()