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):
a, b, c, d = map(int,input())
A = str(a)
B = str(b)
C = str(c)
D = str(d)
if a+b+c+d == 7:
    print(A+'+'+B+'+'+C+'+'+D+'=7')
elif a-b+c+d == 7:
    print(A+'-'+B+'+'+C+'+'+D+'=7')
elif a+b-c+d == 7:
    print(A+'+'+B+'-'+C+'+'+D+'=7')
elif a+b+c-d == 7:
    print(A+'+'+B+'+'+C+'-'+D+'=7')
elif a-b-c+d == 7:
    print(A+'-'+B+'-'+C+'+'+D+'=7')
elif a-b+c-d == 7:
    print(A+'-'+B+'+'+C+'-'+D+'=7')
elif a+b-c-d == 7:
    print(A+'+'+B+'-'+C+'-'+D+'=7')
elif a-b-c-d == 7:
    print(A+'-'+B+'-'+C+'-'+D+'=7')

Solution (Python):
A,B,C,D = map(int, input())
ans = list(str(A))
for b in [-B,B]:
    for c in [-C,C]:
        for d in [-D,D]:
            if sum([A,b,c,d]) == 7:
                ans += ["+" + str(x) if x>=0 else str(x) for x in [b,c,d]]
                break
        else:
            continue
        break
    else:
        continue
    break
for i in ans:
    print(i, end = "")
print("=7")

Solution (Python):
a, b, c, d = input()
op = ["+", "-"]

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

Solution (Python):

import itertools

s = list(input())
num = []
calc = [1, -1]
for i in range(len(s)):
    a = int(s[i])
    num.append(a)

calc_comb = [_ for _ in itertools.product(calc, repeat=3)]

x = 0
while True:
    ans = num[0]
    for i in range(len(num)-1):
        ans += num[i+1] * calc_comb[x][i]

    if ans == 7:
        r = calc_comb[x]
        break
    else:
        x += 1

r_replace = ['+' if i==1 else '-' for i in r]
out = [None] * (len(s)+len(r_replace))
out[::2] = s
out[1::2] = r_replace
out = ''.join(out)
print(out, '=7', sep='')

Solution (Python):
s = input()
n = 3
for i in range(2 ** n):
    sign = [False] * n
    for j in range(n):
        if (i >> j) & 1:
            sign[j] = True
    cal = int(s[0])
    for i in range(n):
        if sign[i]:
            cal += int(s[i+1])
        else:
            cal -= int(s[i+1])
    if cal == 7:
        print(s[0], end = '')
        for i in range(n):
            if sign[i]:
                print('+' + s[i+1], end = '')
            else:
                print('-' + s[i+1], end = '')
        print('=7')
        break

Solution (Python):

def main():
	ad = input()
	now = int(ad[0])
	q = []
	n = len(ad)
	q.append([0 , now , ad[0]])
	while len(q)!=0:
		
		cur = q.pop(0)
		
		if cur[0] ==n-1:
			if cur[1]==7:
				print(cur[2]+'='+'7')
				break
				exit(0)
			continue
		
		if cur[0]+1<n:
			q.append([cur[0]+1, cur[1]+((int)(ad[cur[0]+1])) , cur[2]+'+'+ad[cur[0]+1]])
			q.append([cur[0]+1, cur[1]-((int)(ad[cur[0]+1])) , cur[2]+'-'+ad[cur[0]+1]])
if __name__=="__main__":
	main()

Solution (Python):
def main():
	ad = input()
	now = int(ad[0])
	q = []
	n = len(ad)
	q.append([0 , now , ad[0]])
	while len(q)!=0:
		
		cur = q.pop(0)
		
		if cur[0] ==n-1:
			if cur[1]==7:
				print(cur[2]+'='+'7')
				break
				exit(0)
			continue
		
		if cur[0]+1<n:
			q.append([cur[0]+1, cur[1]+((int)(ad[cur[0]+1])) , cur[2]+'+'+ad[cur[0]+1]])
			q.append([cur[0]+1, cur[1]-((int)(ad[cur[0]+1])) , cur[2]+'-'+ad[cur[0]+1]])
if __name__=="__main__":
	main()

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

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):
N = input()
N = [int(n) for n in N]
A,B,C,D = N
op =['+','-']
ops = []
for a in op:
  for b in op:
    for c in op:
        ops.append(a + b + c)
        
for op in ops:
  S = "{}{}{}{}{}{}{}".format(A,op[0],B,op[1],C,op[2],D)
  if eval(S) == 7:
    print("{}=7".format(S))
    break

Solution (Python):
S = input()
for i in range(2**3):
  formula = ""
  for j in range(3):
    formula += S[j]
    if (i>>j) & 1:
      formula += "+"
    else:
      formula += "-"
  formula += S[3]
  if eval(formula) == 7:
    print(formula + "=7")
    break

Solution (Python):
A,B,C,D = map(int, input())
ans = [str(A)]
for b in [B,-B]:
    for c in [C,-C]:
        for d in [D,-D]:
            if sum([A,b,c,d]) == 7:
                ans += ['+' + str(x) if x >= 0 else str(x) for x in [b,c,d]]
                print(''.join(ans) + '=7')
                exit(0)

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

if sum(num) == 7:
  print(str(num[0])+"+"+str(num[1])+"+"+str(num[2])+"+"+str(num[3])+"=7")
elif num[0] -num[1] + num[2] + num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"+"+str(num[2])+"+"+str(num[3])+"=7")
elif num[0] -num[1] - num[2] + num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"-"+str(num[2])+"+"+str(num[3])+"=7")
elif num[0] -num[1] - num[2] - num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"-"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] +num[1] - num[2] - num[3] == 7:
  print(str(num[0])+"+"+str(num[1])+"-"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] +num[1] + num[2] - num[3] == 7:
  print(str(num[0])+"+"+str(num[1])+"+"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] - num[1] + num[2] - num[3] == 7:
  print(str(num[0])+"-"+str(num[1])+"+"+str(num[2])+"-"+str(num[3])+"=7")
elif num[0] +num[1] - num[2] + num[3] == 7:
  print(str(num[0])+"+"+str(num[1])+"-"+str(num[2])+"+"+str(num[3])+"=7")

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

for x in lis:
  for y in lis:
    for z in lis:
      p = n[0] + x + n[1] + y + n[2] + z + n[3]
      if eval(p) == 7:
        print(p + "=7")
        exit()

Solution (Python):
A,B,C,D = input()
op = ["+","-"]

for op1 in op:
  for op2 in op:
    for op3 in op:
      S = A+op1+B+op2+C+op3+D
      if eval(S)==7:
        print(S+"=7")
        exit()

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

for x in lis:
  for y in lis:
    for z in lis:
      p = n[0] + x + n[1] + y + n[2] + z + n[3]
      if eval(p) == 7:
        print(p + "=7")
        exit()

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

Solution (Python):
from itertools import product

m = input()
n = m[0] + 'x' + m[1] + 'y' + m[2] + 'z' + m[3]

for i in product([0,1], repeat=3):
    if i[0] == 0:
        l = n.replace('x', '+')
    elif i[0] == 1:
        l = n.replace('x', '-')

    if i[1] == 0:
        l = l.replace('y', '+')
    elif i[1] == 1:
        l = l.replace('y', '-')

    if i[2] == 0:
        l = l.replace('z', '+')
    elif i[2] == 1:
        l = l.replace('z', '-')

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

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

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

    formula = ''.join([n + op for n, op in zip(ABCD, ptn + [''])])
    if eval(formula) == 7:
        print(formula + '=7')
        exit()

Solution (Python):
from itertools import product as P

a, b, c, d = input()

ops = P(("+", "-"), repeat=3)
for op1, op2, op3 in ops:
    f = f"{a}{op1}{b}{op2}{c}{op3}{d}"
    if eval(f) == 7:
        print(f + "=7")
        break

Solution (Python):
abcd = input() 
l = len(abcd)  

for bit in range(1 << l-1):
    N = abcd[0]
    for i in range(3):
        N += ' '
        if ((bit >> i) & 1):
            N += '-'
        else:
            N += '+'
        N += abcd[i+1]
        N += ' '
    
    N_int = sum(map(int, N.split()))
    
    if N_int == 7:
        
        ans = N.replace(' ', '')
        print('{}=7'.format(ans))
        break

Solution (Python):


def main():
    tmp = input()
    a = int(tmp[0])
    b = int(tmp[1])
    c = int(tmp[2])
    d = int(tmp[3])
    
    for i in range(2 ** 3):
        opt = []
        for j in range(3):
            if (i >> j) & 1:
                opt.append("+")
            else:
                opt.append("-")
        ans = int(tmp[0])
        for j, x in enumerate(tmp[1:]):
            if opt[j] == "+":
                ans += int(x)
            else:
                ans -= int(x)
        if ans == 7:
            print(tmp[0] + opt[0] + tmp[1] + opt[1] + tmp[2] + opt[2] + tmp[3] + "=7")
            break
    
main()

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

def p_mark(j):
    if j % 2 == 0:
        return '+'
    else:
        return '-'

for i in range(2 ** 3):
    j = i
    p = a
    x = p_mark(j)
    if x == '+':
        p += b
    else:
        p -= b
    j = j // 2
    y = p_mark(j)
    if y == '+':
        p += c
    else:
        p -= c
    j = j // 2
    z = p_mark(j)
    if z == '+':
        p += d
    else:
        p -= d
    if p == 7:
        print(str(a) + x + str(b) + y + str(c) + z + str(d) + '=7')
        break

Solution (Python):
A, B, C, D = input()
op = ["+", "-"]

for i in op:
    for j in op:
        for k in op:
            ans = A + i + B + j + C + k + D
            if eval(ans) == 7:
                print(ans + "=7")
                exit()

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

def joinstring(s, op1, op2, op3):
  return str(s[0]) + op1 + str(s[1]) + op2 + str(s[2]) + op3 + str(s[3]) + "=7"

p = "+"
m = "-"

if s[0] + s[1] + s[2] + s[3] == 7:
  print(joinstring(s, p, p, p))
elif s[0] + s[1] + s[2] - s[3] == 7:
  print(joinstring(s, p, p, m))
elif s[0] + s[1] - s[2] + s[3] == 7:
  print(joinstring(s, p, m, p))
elif s[0] - s[1] + s[2] + s[3] == 7:
  print(joinstring(s, m, p, p))
elif s[0] + s[1] - s[2] - s[3] == 7:
  print(joinstring(s, p, m, m))
elif s[0] - s[1] + s[2] - s[3] == 7:
  print(joinstring(s, m, p, m))
elif s[0] - s[1] - s[2] + s[3] == 7:
  print(joinstring(s, m, m, p))
elif s[0] - s[1] - s[2] - s[3] == 7:
  print(joinstring(s, m, m, m,))

Solution (Python):
s = input()

for i in range(2**3):
    op = ["+"]*3
    op.append("")
    fomula = ""
    for j in range(3):
        if(i >> j & 1):
            op[j] = "-"
    for k in range(4):
        fomula += s[k] + op[k]
    if eval(fomula) == 7:
        print(fomula + "=7")
        break

Solution (Python):
ABCD = input()

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

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

Solution (Python):
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()

    else:
        dfs(i+1, f + "-" + s[i+1], sum - int(s[i+1]))
        dfs(i+1, f + "+" + s[i+1], sum + int(s[i+1]))


s = input()

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

Solution (Python):
ABCD = input()
for i in ('-1','+1'):
    for j in ('-1','+1'):
        for k in ('-1','+1'):
            if int(ABCD[0]) + (int(i)) * int(ABCD[1]) + (int(j)) * int(ABCD[2]) + + (int(k)) * int(ABCD[3]) == 7:
                print(ABCD[0]+i[0]+ABCD[1]+j[0]+ABCD[2]+k[0]+ABCD[3]+'=7')
                exit()

Solution (Python):
n=input()

def make_seven(n):
    al=[]
    for i in range(4):
        a=int(n[i])
        al.append(a)

    for j in range(-1,2,2):
        for k in range(-1,2,2):
            for l in range(-1,2,2):
                if al[0]+j*al[1]+k*al[2]+l*al[3]==7:
                    if j==-1:
                        o1="-"
                    else:
                        o1="+"
                    if k==-1:
                        o2="-"
                    else:
                        o2="+"
                    if l==-1:
                        o3="-"
                    else:
                        o3="+"
                    print(str(al[0])+o1+str(al[1])+o2+str(al[2])+o3+str(al[3])+"=7")
                    return
make_seven(n)

Solution (Python):
N = list(map(int, list(input())))
for i in range(2 ** 3):
    total = N[0]
    ans = []
    for j in range(3):
        if i >> j & 1:
            total += N[j + 1]
            ans.append('+')
        else:
            total -= N[j + 1]
            ans.append('-')
    if total == 7:
        joy = ''
        for i in range(3):
            joy += str(N[i])
            joy += str(ans[i])
        joy += str(N[-1])
        joy += '=7'
        print(joy)
        break

Solution (Python):
abcd = str(input())
w = ["+","-"]
s = []
for i in w:
    for h in w:
        for j in w:
            num = int(abcd[0])
            l = [i,h,j]
            for k in range(len(l)):
                if l[k] == "+":
                    num += int(abcd[k+1])
                else:
                    num -= int(abcd[k+1])
            if num == 7:
                s.append(abcd[0]+i+abcd[1]+h+abcd[2]+j+abcd[3]+"="+"7")
print(s[0])

Solution (Python):
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

Solution (Python):
import sys

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    S = SI()
    bit_len = len(S)-1
    for i in range(2**bit_len):
        ls = ['-' for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                ls[j] = '+'
        calc = []
        for n in range(len(S)):
            calc.append(S[n])
            if n != len(S)-1:
                calc.append(ls[n])
        if eval("".join(calc)) == 7:
            print("".join(calc)+"=7")
            sys.exit()

if __name__ == '__main__':
    main()

Solution (Python):
n = [int(x) for x in input()]
op_cnt = len(n) - 1
for i in range(1 << op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[op_cnt - 1 - j] = '+'
    formula = "{}{}{}{}{}{}{}".format(n[0], op[0], n[1], op[1], n[2], op[2], n[3])
    if eval(formula) == 7:
        print(formula + '=7')
        break

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

def calc(n,op):
  tmp = int(n[0])
  for i in range(len(op)):
    if op[i] == '+':
      tmp += int(n[i+1])
    else:
      tmp -= int(n[i+1])
  return tmp
for j in range(2**s):
  op = ''
  for k in range(s):
    if (j>>k)&1:
      op += '+'
    else:
      op += '-'
  if calc(n,op) == 7:
    ret = ''
    for l in range(len(op)):
      ret += n[l]
      ret += op[l]
    ret += n[-1]
    ret +='=7'
    print(ret)
    exit(0)

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


for i in range(2**s):
  op = ""
  for j in range(s):
    if (i>>j)&1:
      op += "+"
    else:
      op += "-"
  ans =int(n[0])
  for j in range(len(op)):
    if op[j]=="+":
      ans += int(n[j+1])
    else:
      ans -= int(n[j+1])
  if ans == 7:
      ret = ""
      for k in range(len(op)):
        ret += n[k]
        ret += op[k]
      ret += n[-1]
      ret += "=7"
      print(ret)
      exit(0)

Solution (Python):
s=input()
A=[]
d=s[0]
for i in range(2**(len(s)-1)):
    v=[]
    for j in range(len(s)-1):
        if ((i>>j)&1):
            v.append('+')
        else:
            v.append('-')
    A.append(v)

for i in range(len(A)):
    c=int(s[0])
    for j in range(3):
        if A[i][j]=='+':
            c+=int(s[j+1])
        else:
            c-=int(s[j+1])
    if c==7:
        for j in range(3):
            d+=A[i][j]+s[j+1]
        print(d+'=7')
        exit()

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

for i in range(2**3):
    op = ["+"]*3
    for j in range(3):
        if (i >> j) & 1 == 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')
        sys.exit()

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

for op1 in ["+","-"]:
  for op2 in ["+","-"]:
    for op3 in ["+","-"]:
      if eval(A+op1+B+op2+C+op3+D) == 7:
        ans = A+op1+B+op2+C+op3+D+"=7"
        break
print(ans)

Solution (Python):
S=input()
a=[0]*7
a[0]=int(S[0])
a[2]=int(S[1])
a[4]=int(S[2])
a[6]=int(S[3])
for i in range(2**3):
    j=bin(int(i))[2:]
    while len(j)<3:
        j="0"+j
    for k in range(3):
        if j[k]=="0":
            a[2*k+1]="+"
        else:
            a[2*k+1]="-"
    ans=a[0]
    if a[1]=="+":
        ans+=a[2]
    else:
        ans-=a[2]
    if a[3]=="+":
        ans+=a[4]
    else:
        ans-=a[4]
    if a[5]=="+":
        ans+=a[6]
    else:
        ans-=a[6]
    if ans==7:
        print(S[0]+a[1]+S[1]+a[3]+S[2]+a[5]+S[3]+"=7")
        break

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

sum_val = 0
for i in range(1 << (n - 1)):
    val = int(s[0])
    expression = s[0]
    for j in range(n - 1):
        if (i >> j) & 1:
            val += int(s[j+1])
            expression += "+" + s[j+1]
        else:
            val -= int(s[j+1])
            expression += "-" + s[j+1]
    if val == 7:
        print(expression + "=7")
        quit()

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


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

Solution (Python):
s = input()
op1 = "+"
op2 = "-"

a = [0 for _ in range(8)]
a[0] = int(s[0]) + int(s[1]) + int(s[2]) + int(s[3])
a[1] = int(s[0]) + int(s[1]) + int(s[2]) - int(s[3])
a[2] = int(s[0]) + int(s[1]) - int(s[2]) + int(s[3])
a[3] = int(s[0]) + int(s[1]) - int(s[2]) - int(s[3])
a[4] = int(s[0]) - int(s[1]) + int(s[2]) + int(s[3])
a[5] = int(s[0]) - int(s[1]) + int(s[2]) - int(s[3])
a[6] = int(s[0]) - int(s[1]) - int(s[2]) + int(s[3])
a[7] = int(s[0]) - int(s[1]) - int(s[2]) - int(s[3])

if a[0] == 7:
    print(s[0]+op1+s[1]+op1+s[2]+op1+s[3]+"=7")
    exit()
elif a[1] == 7:
    print(s[0]+op1+s[1]+op1+s[2]+op2+s[3]+"=7")
    exit()
elif a[2] == 7:
    print(s[0]+op1+s[1]+op2+s[2]+op1+s[3]+"=7")
    exit()
elif a[3] == 7:
    print(s[0]+op1+s[1]+op2+s[2]+op2+s[3]+"=7")
    exit()
elif a[4] == 7:
    print(s[0]+op2+s[1]+op1+s[2]+op1+s[3]+"=7")
    exit()
elif a[5] == 7:
    print(s[0]+op2+s[1]+op1+s[2]+op2+s[3]+"=7")
    exit()
elif a[6] == 7:
    print(s[0]+op2+s[1]+op2+s[2]+op1+s[3]+"=7")
    exit()
elif a[7] == 7:
    print(s[0]+op2+s[1]+op2+s[2]+op2+s[3]+"=7")
    exit()

Solution (Python):
a,b,c,d = list(map(int,input()))
op = ['plus','minus']
dic = {'plus':'+','minus':'-'}

for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a
            if op1 == 'plus':
                ans += b
            else:
                ans -= b
            if op2 == 'plus':
                ans += c
            else:
                ans -= c
            if op3 == 'plus':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(f'{a}{dic[op1]}{b}{dic[op2]}{c}{dic[op3]}{d}=7')
                exit()

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

Solution (Python):

"""
切符に４つの0以上9以下の整数A,B, C, Dが整理番号として順にかかれている。
Aop1Bop2Cop3D = 7　となるように、op1,2,3,に'+'または'-'を入れて式を作る。
答が存在しない入力は与えられず、また答が複数ある場合はどれを出力してもよい。
＜制約＞
0 <= A,B,C,D<=9
入力は整数
答が存在しない入力は与えられない
"""
n = list(int(x) for x in input())
op_cnt = len(n) - 1 

l = []
for i in range(1 << op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - j -1] = '+'
            l.append(op)

for operators in l:
    expression = f"{n[0]}{operators[0]}{n[1]}{operators[1]}{n[2]}{operators[2]}{n[3]}"
    if eval(expression) == 7:
        print(f"{expression}=7")
        break

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

for i in range(2 ** 3):
    ans = A[0]
    op = []
    for j in range(3):
        if ((i >> j) & 1):
            ans += A[j + 1] 
            op.append("+")
        else:
            ans -= A[j + 1]
            op.append("-")
    if ans == 7:
        break
A = list(map(str, A))
print(A[0], end="")
for c in range(3):
    print(op[c], end="")
    print(A[c + 1], end="")
print("=7")

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

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

Solution (Python):
def main():
    A, B, C, D = list(input())
    for i in ['+','-']: 
        for j in ['+','-']:
            for k in ['+','-']:
                tmp = A + i + B + j + C + k + D
                if eval(tmp) == 7:
                    print(tmp+'=7')
                    exit()

if __name__ == "__main__":
    main()

Solution (Python):
import sys
if __name__ == '__main__':
    s = input()
    o = []
    n = len(s)
    
    for i in range(1 << n - 1):
        tmp = 0
        tmp += int(s[0])
        o.clear()
        for j in range(n - 1):
            if 1 << j & i == 0:
                tmp += int(s[j + 1])
                o.append('+')
            else:
                tmp -= int(s[j + 1])
                o.append('-')
        if tmp == 7:
            print(s[0]+o[0]+s[1]+o[1]+s[2]+o[2]+s[3]+'=7')
            sys.exit()

Solution (Python):

S = input()
space_cnt = 3
for i in range(2 ** space_cnt):
    ops = ["-"] * space_cnt
    for j in range(space_cnt):
        if (i >> j) & 1:
            ops[j] = "+"
    formula = ""
    for j in range(space_cnt):
        formula += S[j]+ops[j]
    formula += S[-1]
    if eval(formula)==7:
        break
print(formula+"=7")

Solution (Python):
a = input()

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

Solution (Python):

s = input()
n = len(s)-1

def calc(s, op):
    ret = int(s[0])
    for i in range(len(op)):
        if op[i] == '+':
            ret += int(s[i+1])
        else:
            ret -= int(s[i+1])
    
    return ret

for i in range(2**n):
    op =''
    for j in range(n):
        if (i >> j)&1:
            op += '+'
        else:
            op += '-'
    
    if calc(s,op) == 7:
        
        ans = ''
        for a in range(len(op)):
            ans += s[a]
            ans += op[a]
        ans += s[-1]
        ans += '=7'
        print(ans)
        exit(0)

Solution (Python):
import itertools as itr

A=list(map(int,input()))
b=list(itr.product(range(2),repeat=3))

for i in b:
    i=['+' if j==1 else '-' for j in i]
    ans=A[0]

    for j in range(3):
        if i[j]=='+':
            ans+=A[j+1]
        else:
            ans-=A[j+1]

    if ans==7:
        C=[]
        for j in range(3):
            C.append(A[j])
            C.append(i[j])
        C.append(A[3])
        C.append('=7')
        print(''.join(map(str,C)))
        exit(0)   

print(-1)

Solution (Python):
import itertools as itr

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

b=list(itr.product(range(2),repeat=3))


for i in b:
    i=['+' if j==1 else '-' for j in i]
    ans=A[0]
    if i[0]=='+':
        ans+=A[1]
    else:
        ans-=A[1]

    if i[1]=='+':
        ans+=A[2]
    else:
        ans-=A[2]    

    if i[2]=='+':
        ans+=A[3]
    else:
        ans-=A[3] 

    if ans==7:
        C=[]
        C.append(A[0])
        C.append(i[0])
        C.append(A[1])
        C.append(i[1])
        C.append(A[2])
        C.append(i[2])
        C.append(A[3])
        C.append('=7')
        print(''.join(map(str,C)))
        exit(0)   


print(-1)

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

bit = 4

for i in range(8):
  calc_list = []
  for j in range(3):
    if((i >> j) & 1):
      calc_list.append("+")
    else:
      calc_list.append("-")
  calc_str = a + calc_list[0] + b + calc_list[1] + c + calc_list[2] + d
  if eval(calc_str) == 7:
    print(calc_str + "=7")
    sys.exit()

Solution (Python):
a, b, c, d = [int(x) for x in input().strip()]
if a + b + c + d == 7:
    print(f"{a}+{b}+{c}+{d}=7")
elif a + b + c - d == 7:
    print(f"{a}+{b}+{c}-{d}=7")
elif a + b - c + d == 7:
    print(f"{a}+{b}-{c}+{d}=7")
elif a - b + c + d == 7:
    print(f"{a}-{b}+{c}+{d}=7")
elif a - b - c + d == 7:
    print(f"{a}-{b}-{c}+{d}=7")
elif a + b - c - d == 7:
    print(f"{a}+{b}-{c}-{d}=7")
elif a - b + c - d == 7:
    print(f"{a}-{b}+{c}-{d}=7")
elif a - b - c - d == 7:
    print(f"{a}-{b}-{c}-{d}=7")

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")
elif a-b-c-d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"="+"7")

Solution (Python):
A,B,C,D = list(input().strip())
if int(A)+int(B)+int(C)+int(D) == 7:
    print(A+"+"+B+"+"+C+"+"+D+"=7")
elif int(A)+int(B)+int(C)-int(D) == 7:
    print(A+"+"+B+"+"+C+"-"+D+"=7")
elif int(A)+int(B)-int(C)+int(D) == 7:
    print(A+"+"+B+"-"+C+"+"+D+"=7")
elif int(A)+int(B)-int(C)-int(D) == 7:
    print(A+"+"+B+"-"+C+"-"+D+"=7")
elif int(A)-int(B)+int(C)+int(D) == 7:
    print(A+"-"+B+"+"+C+"+"+D+"=7")
elif int(A)-int(B)+int(C)-int(D) == 7:
    print(A+"-"+B+"+"+C+"-"+D+"=7")
elif int(A)-int(B)-int(C)+int(D) == 7:
    print(A+"-"+B+"-"+C+"+"+D+"=7")
elif int(A)-int(B)-int(C)-int(D) == 7:
    print(A+"-"+B+"-"+C+"-"+D+"=7")

Solution (Python):
from itertools import product

a,b,c,d=map(int,list(input()))
op = ['+','-']
for p in product(range(2),repeat=3):
  txt=f'{a}{op[p[0]]}{b}{op[p[1]]}{c}{op[p[2]]}{d}'
  if eval(txt)==7:
    print(txt+'=7')
    exit()

Solution (Python):
S=input()

o=['-','+']
for h in o:
    for i in o:
        for j in o:
            if 7 == eval(S[0]+h+S[1]+i+S[2]+j+S[3]):
                print(S[0]+h+S[1]+i+S[2]+j+S[3]+"=7")
                exit()

Solution (Python):
from itertools import product

a, b, c, d = [int(i) for i in list(input())]
for i, j in zip(product([1, -1], repeat=3), product(["+", "-"], repeat=3)):
    if a + b * i[0] + c * i[1] + d * i[2] == 7:
        print(f"{a}{j[0]}{b}{j[1]}{c}{j[2]}{d}=7")
        break

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")
    break
  else:
    continue
  break

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

for j in range(8):
    op = [[1, "+"]] * 3
    for i in range(3):
        if (j >> i) & 1:
            op[i] = [-1, "-"]
    if a + b * op[0][0] + c * op[1][0] + d * op[2][0] == 7:
        print(f"{a}{op[0][1]}{b}{op[1][1]}{c}{op[2][1]}{d}=7")
        exit()

Solution (Python):
def myfunc(op):
    if op:
        return "+"
    else:
        return "-"


a, b, c, d = [int(i) for i in list(input())]

for j in range(8):
    op = [[1, "+"]] * 3
    for i in range(3):
        if (j >> i) & 1:
            op[i] = [-1, "-"]
    if a + b * op[0][0] + c * op[1][0] + d * op[2][0] == 7:
        print(f"{a}{op[0][1]}{b}{op[1][1]}{c}{op[2][1]}{d}=7")
        exit()

Solution (Python):
def myfunc(op):
    if op == 1:
        return "+"
    else:
        return "-"


a, b, c, d = [int(i) for i in list(input())]

for j in range(8):
    op = [1, 1, 1]
    for i in range(3):
        if (j >> i) & 1:
            op[i] = -1
    if a + b * op[0] + c * op[1] + d * op[2] == 7:
        x = myfunc(op[0])
        y = myfunc(op[1])
        z = myfunc(op[2])
        print(f"{a}{x}{b}{y}{c}{z}{d}=7")
        exit()

Solution (Python):
def myfunc(op):
    if op == 1:
        return "+"
    else:
        return "-"


a, b, c, d = [int(i) for i in list(input())]

for k in [0, 1]:
    for j in [0, 1]:
        for i in [0, 1]:
            op = [-1, -1, -1]
            if k == 0:
                op[0] = 1
            if j == 0:
                op[1] = 1
            if i == 0:
                op[2] = 1
            if a + b * op[0] + c * op[1] + d * op[2] == 7:
                x = myfunc(op[0])
                y = myfunc(op[1])
                z = myfunc(op[2])
                print(f"{a}{x}{b}{y}{c}{z}{d}=7")
                exit()

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

for i in range(2 ** l):
    ans: int = int(n[0])
    num = n[0]
    for j in range(l):
        if (i >> j) & 1:
            num += "+"
            num += n[j + 1]
        else:
            num += "-"
            num += n[j + 1]
    for k in range(1, len(num), 2):
        if num[k] == "-":
            ans -= int(num[k+1])
        else:
            ans += int(num[k+1])
    if ans == 7:
        print(num + "=7")
        break

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

dic = {1: "+", 0: "-"}

for i in range(2 ** 3):
    t = A[0]
    s = str(A[0])
    for j in range(3):
        if (i >> j) & 1:
            t += A[j + 1]
            s += dic[1] + str(A[j + 1])
        else:
            t -= A[j + 1]
            s += dic[0] + str(A[j + 1])
            
    if t == 7:
        print(s + "=7")
        exit()