Problem:
 Score : 300 points    Problem Statement Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A , B , C and D in this order, each between 0 and 9 (inclusive).  In the formula A  op1  B  op2  C  op3  D  =  7 , replace each of the symbols op1 , op2 and op3 with + or - so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.      Constraints  0≤A,B,C,D≤9  All input values are integers.  It is guaranteed that there is a solution.         Input Input is given from Standard Input in the following format:  ABCD       Output Print the formula you made, including the part =7 .  Use the signs + and - .  Do not print a space between a digit and a sign.        Sample Input 1 1222      Sample Output 1 1+2+2+2=7  This is the only valid solution.       Sample Input 2 0290      Sample Output 2 0-2+9+0=7  0 - 2 + 9 - 0 = 7 is also a valid solution.       Sample Input 3 3242      Sample Output 3 3+2+4-2=7

Solution (Python):
import sys

tmp = list(sys.stdin.readline().strip())
nums = list(map(int, tmp))

for a in range(2):
    for b in range(2):
        for c in range(2):
            tmp = nums[0]
            exp = str(nums[0])
            if a == 0:
                tmp += nums[1]
                exp += "+"
            else:
                tmp -= nums[1]
                exp += "-"
            exp += str(nums[1])
            if b == 0:
                tmp += nums[2]
                exp += "+"
            else:
                tmp -= nums[2]
                exp += "-"
            exp += str(nums[2])
            if c == 0:
                tmp += nums[3]
                exp += "+"
            else:
                tmp -= nums[3]
                exp += "-"
            exp += str(nums[3])
            if tmp == 7:
                print(exp + "=7")
                sys.exit()

Solution (Python):
import sys

*S, = input()

op = ['-', '+']
for i in op:
    for j in op:
        for k in op:
            e = f'{S[0]}{i}{S[1]}{j}{S[2]}{k}{S[3]}'
            if eval(e) == 7:
                print(f'{e}=7')
                sys.exit()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

for i in ('+', '-'):
    for j in ('+', '-'):
        for k in ('+', '-'):
            val = A
            if i=='+':
                val += B
            else:
                val -= B

            if j=='+':
                val += C
            else:
                val -= C

            if k=='+':
                val += D
            else:
                val -= D
            
            if val==7:
                print('{}{}{}{}{}{}{}=7'.format(A, i, B, j, C, k, D))
                exit()

Solution (Python):
a=[int(c) for c in input()]

for i in range(2**3):
    s=a[0]
    ss=str(a[0])
    for j in range(3):
        if (i>>j)&1==1:
            s+=a[j+1]
            ss=ss+'+'+str(a[j+1])
        else:
            s-=a[j+1]
            ss=ss+'-'+str(a[j+1])
    
    if s==7:
        ss=ss+'=7'
        print(ss)
        exit(0)

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

Solution (Python):
def main(A,B,C,D):
    list = [A,B,C,D]

    tmp = ['+','-']


    for i in range(2**3):
        ans = A
        back = []
        for j in range(3):
            if ( (i>>j)&1 ):
                ans += list[j+1]
                back.append(tmp[0])
            else:
                ans -= list[j+1]
                back.append(tmp[1])
        if ans == 7:
            return back

tmp = int(input())
D = tmp%10
tmp = tmp//10
C = tmp%10
tmp = tmp//10
B = tmp%10
tmp = tmp//10
A = tmp%10
back = main(A,B,C,D)
print(str(A)+back[0]+str(B)+back[1]+str(C)+back[2]+str(D)+'=7')

Solution (Python):
s = input()
a = [int(x) for x in s]
for bit in range(1 << 3):
    tmp = a[0]
    tmps = str(a[0])

    for i in range(3):
        if bit >> i & 1:
            tmp += a[i + 1]
            tmps += '+' + str(a[i + 1])
        else:
            tmp -= a[i + 1]
            tmps += '-' + str(a[i + 1])
    if tmp == 7:
        print(tmps + '=7')
        exit()

Solution (Python):
import sys
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
hugo = [1, -1]
for b in hugo:
    AB = A+b*B
    for c in hugo:
        ABC = AB+c*C
        for d in hugo:
            ABCD = ABC+d*D
            if ABCD == 7:
                if b == 1:
                    b = "+"
                else:
                    b = "-"
                if c == 1:
                    c = "+"
                else:
                    c = "-"
                if d == 1:
                    d = "+"
                else:
                    d = "-"
                print(A, b, B, c, C, d, D, "=7", sep="")
                sys.exit()

Solution (Python):
s=input()
a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3])
if a+b+c+d==7:
    print("{}+{}+{}+{}=7".format(a,b,c,d))
elif a+b+c-d==7:
    print("{}+{}+{}-{}=7".format(a,b,c,d))
elif a+b-c+d==7:
    print("{}+{}-{}+{}=7".format(a,b,c,d))
elif a-b+c+d==7:
    print("{}-{}+{}+{}=7".format(a,b,c,d))
elif a+b-c-d==7:
    print("{}+{}-{}-{}=7".format(a,b,c,d))
elif a-b+c-d==7:
    print("{}-{}+{}-{}=7".format(a,b,c,d))
elif a-b-c+d==7:
    print("{}-{}-{}+{}=7".format(a,b,c,d))
else:
    print("{}-{}-{}-{}=7".format(a,b,c,d))

Solution (Python):
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    nums = list(input())
    for pattern in product(["+", "-"],repeat=3):
        pattern = list(pattern) + [""]
        fomula = ""
        for op, num in zip(pattern, nums):
            fomula += num + op
        if eval(fomula) == 7:
            print(fomula + "=" + "7")
            break


if __name__ == '__main__':
    resolve()

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

P = product([1, -1], repeat=3)

def convert(integer):
    if integer == 1:
        return "+"
    elif integer == -1:
        return "-"

for o1, o2, o3 in P:
    if A + B * o1 + C * o2 + D * o3 == 7:
        print(str(A) + convert(o1) + str(B) + convert(o2) + str(C) + convert(o3) + str(D) + "=7")
        exit()

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

for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            if a + i*b + j*c + k*d == 7:
                op1 = ['-','+'][i==1]
                op2 = ['-','+'][j==1]
                op3 = ['-','+'][k==1]
                print(f'{a}{op1}{b}{op2}{c}{op3}{d}=7')
                exit()

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

from itertools import product as pr

p = list(pr(['+','-'],repeat=3))

for ope in p:
    f = s[0] + ope[0] + s[1] + ope[1] + s[2] + ope[2] + s[3]

    if eval(f)==7:
        print(f+'=7')
        exit(0)

Solution (Python):
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      ops = [op[i], op[j], op[k]]
      tmp = a[0]
      for l in range(3):
        if ops[l]=='+':
          tmp = tmp + a[l+1]
        else:
          tmp = tmp - a[l+1]
      if tmp==7:
        break
    if tmp==7:
      break
  if tmp==7:
    break

print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')

Solution (Python):
s = list(input())
ans = []
for i in ['+', '-']:
    for j in ['+', '-']:
        for k in ['+', '-']:
            tmp = int(s[0])
            if i == '+':
                tmp += int(s[1])
            else:
                tmp -= int(s[1])
            if j == '+':
                tmp += int(s[2])
            else:
                tmp -= int(s[2])
            if k == '+':
                tmp += int(s[3])
            else:
                tmp -= int(s[3])
            if tmp == 7:
                ans = [s[0],i,s[1],j,s[2],k,s[3],'=7']
                break
print(''.join(map(str,ans)))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
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()))

s = input()
for pt in itertools.product([0,1],repeat=3):
    now = int(s[0])
    for i,x in enumerate(pt):
        
        if x:
            now += int(s[i+1])
        else:
            now -= int(s[i+1])
    if now == 7:
        res = s[0]
        for i in range(1,4):
            tmp = '+' if pt[i-1] else '-'
            res += tmp + s[i]
        print(res+'=7')
        break

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

A = list(map(int,sys.stdin.readline().rstrip()))

from itertools import product

X = ['+','-']
for a in product(X,repeat=3):
    b = A[0]
    for i in range(3):
        if a[i] == '+':
            b += A[i+1]
        else:
            b -= A[i+1]
    if b == 7:
        print(str(A[0])+a[0]+str(A[1])+a[1]+str(A[2])+a[2]+str(A[3])+'=7')
        break

Solution (Python):
import sys

a, b, c, d = list(map(int, input().rstrip()))

li = ["+", "-"]

for x in li:
    for y in li:
        for z in li:
            tmp = a
            if x == "+":
                tmp += b
            else:
                tmp -= b
            if y == "+":
                tmp += c
            else:
                tmp -= c
            if z == "+":
                tmp += d
            else:
                tmp -= d
            if tmp == 7:
                print("{}{}{}{}{}{}{}=7".format(a, x, b, y, c, z, d))
                sys.exit()

Solution (Python):
import itertools
S = str(input())
L = ("+","-")

kouho = list(itertools.product(L, repeat=3))

for x in kouho:
  temp = S[0]+x[0]+S[1]+x[1]+S[2]+x[2]+S[3]
  ans = eval(temp)
  if ans == 7:
    print(temp+"=7")
    exit()

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


for a in ['+','-']:
    for b in ['+','-']:
        for c in ['+','-']:
            cal = s[0]+a+s[1]+b+s[2]+c+s[3]
            v = eval(cal)
            if v == 7:
                print(cal+'=7')
                exit()

Solution (Python):
from itertools import product
s = input().strip()
for x in product(("+","-"),repeat=3):
    y = s[0]+x[0]+s[1]+x[1]+s[2]+x[2]+s[3]
    if eval(y)==7:
        break
print(y+"=7")

Solution (Python):
import sys
import itertools

a, b, c, d = list(input())

lst = ['-', '+']
for i, j, k in itertools.product(range(2), range(2), range(2)):
    ans = int(a)
    if i:
        ans += int(b)
    else:
        ans -= int(b)
    if j:
        ans += int(c)
    else:
        ans -= int(c)
    if k:
        ans += int(d)
    else:
        ans -= int(d)
        
    if ans == 7:
        print(a,lst[i],b,lst[j],c,lst[k],d,'=7',sep='')
        break

Solution (Python):
s = input()
for bit in range(1 << 3):
    tmp = int(s[0])
    sign = []
    for i in range(3):
        if bit & (1 << i):
            tmp += int(s[i+1])
            sign.append("+")
        else:
            tmp -= int(s[i+1])
            sign.append("-")
    
    if tmp == 7:
        print(s[0] + sign[0] + s[1] + sign[1] + s[2] + sign[2] + s[3] + "=7")
        exit()

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

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

S = str(input())
dfs(0,S[0],int(S[0]))

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

def dfs(ans, index, cnt):
    if index == 0:
        return dfs(ans + str(L[index]), index + 1, cnt + L[index])
    if index == 4:
        if cnt == 7:
            return ans + '=7'
        else:
            return False
    ans1 = dfs(ans + '+' + str(L[index]), index+1, cnt + L[index])
    ans2 = dfs(ans + '-' + str(L[index]), index+1, cnt - L[index])
    if ans1:
        return ans1
    if ans2:
        return ans2
    return False

ans = dfs('', 0, 0)
print(ans)

Solution (Python):
N=str(input())
cc=['+']*3
ans=int(N[0])
for j in range(2**3):
    temp=bin(2**3+j)
    for i in range(3,6):
        if temp[i]=='0':
            ans+=int(N[i-2])
            cc[i-3]='+'
        else:
            ans-=int(N[i-2])
            cc[i-3]='-'
    if ans==7:
        print(N[0]+cc[0]+N[1]+cc[1]+N[2]+cc[2]+N[3]+'=7')
        exit()
    else:
        ans=int(N[0])

Solution (Python):
import itertools
moji = str(input())
A,B,C,D = int(moji[0]),int(moji[1]),int(moji[2]),int(moji[3])

Bn = [B,B*-1]
Cn = [C,C*-1]
Dn = [D,D*-1]
flg = 0
for i,j,k in itertools.product(Bn, Cn,Dn):
    X = A + i + j + k
    if X == 7:
        break
    
print(str(A) + (str(i),"+"+str(i))[i >= 0]+ (str(j),"+"+str(j))[j >= 0]+ (str(k),"+"+str(k))[k >= 0]+"=7")

Solution (Python):
N=input()
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])
if A+B+C+D==7 :
  print(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 = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

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



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

Solution (Python):
def operator(x):
    if x < 0:
        return '-'
    else:
        return '+'


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

    lst = []
    for op_1 in range(2):
            for op_2 in range(2):
                for op_3 in range(2):

                    b1 = b
                    c1 = c
                    d1 = d
                    if op_1 == 1:
                        b1 = -b
                    if op_2 == 1:
                        c1 = -c
                    if op_3 == 1:
                        d1 = -d

                    if b1 + c1 + d1 == 7 - a:
                        lst.append(b1)
                        lst.append(c1)
                        lst.append(d1)
                        break

    op1 = operator(lst[0])
    op2 = operator(lst[1])
    op3 = operator(lst[2])
    answer = str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + '=' + '7'
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
N=list(input())
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])
if A+B+C+D==7:
  key=N[0]+'+'+N[1]+'+'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A+B+C-D==7:
  key=N[0]+'+'+N[1]+'+'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()
if A+B-C+D==7:
  key=N[0]+'+'+N[1]+'-'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A-B+C+D==7:
  key=N[0]+'-'+N[1]+'+'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A-B-C+D==7:
  key=N[0]+'-'+N[1]+'-'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A-B+C-D==7:
  key=N[0]+'-'+N[1]+'+'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()
if A+B-C-D==7:
  key=N[0]+'+'+N[1]+'-'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()
if A-B-C-D==7:
  key=N[0]+'-'+N[1]+'-'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()

Solution (Python):
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


a = list(_S())
a = list(map(int,a))
l = len(a)-1

for i in range(1<<l):
    t = a[0]
    sign = ['-','-','-']
    
    for j in range(l):
        
        if (i >> j) & 1 == 0:
            t += a[j+1]
            sign[j]='+'
        else:
            t -= a[j+1]
    
    if t == 7:
        break

ans = str(a[0])
for i in range(l):
    ans += sign[i] + str(a[i+1])
ans += '=7'
print(ans)

Solution (Python):
num = input()

ls = [0] * 3
for i in range(2 ** 3):
    make7 = int(num[0])
    for j in range(3):
        if (i >> j) & 1:
            make7 += int(num[j+1])
            ls[j] = "+"
        else:
            make7 -= int(num[j+1])
            ls[j] = "-"
    if make7 == 7:
        print(num[0] + ls[0] + num[1] + ls[1] + num[2] + ls[2] + num[3] + "=7")
        exit()

Solution (Python):
abcd = input()
n = len(abcd)
for i in range(1<<n-1):
    ans = abcd[0]
    for j in range(n-1):
        if i>>j&1:
            ans += "-" + abcd[j+1]
        else:
            ans += "+" + abcd[j+1]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Solution (Python):
a=input()
A = int(a[0])

for flag in range(2**3):
	op=[]
	temp_a=A
	for i in range(3):
		if (flag>>i)&1==1:
			op.append("+")
			temp_a+=int(a[i+1])
		else:
			op.append("-")
			temp_a-=int(a[i+1])
	if temp_a==7:
		print("{}{}{}{}{}{}{}=7".format(a[0],op[0],a[1],op[1],a[2],op[2],a[3]))
		exit()

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

Solution (Python):
def operation(a,ops):
    ans = a[0]
    for i in range(3):
        if ops[i]=='+':
            ans += a[i+1]
        else:
            ans -= a[i+1]
    return ans

s = list(input())
a = [int(i) for i in s]
op = ['+','-']

for i in range(1<<3):
    ops = [op[1&(i>>j)] for j in range(3)]
    if operation(a,ops)==7:
        print("{}{}{}{}{}{}{}=7".format(a[0],ops[0],a[1],ops[1],a[2],ops[2],a[3]))
        break

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

for i in range(8):
    b = format(i, "03b")
    S = A[0]
    for j in range(3):
        if b[j] == "0":
            S += A[j + 1]
        else:
            S -= A[j + 1]
    if S == 7:
        break

op = ["+", "-"]
ans = s[0] + op[int(b[0])] + s[1] + op[int(b[1])] + s[2] + op[int(b[2])] + s[3] + "=7"
print(ans)

Solution (Python):
s = input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
for j in range(2):
    for k in range(2):
        for l in range(2):
            sm=a
            if j==0:
                B='+'
                sm+=b
            else:
                B='-'
                sm-=b
            if k==0:
                C='+'
                sm+=c
            else:
                C='-'
                sm-=c
            if l==0:
                D='+'
                sm+=d
            else:
                D='-'
                sm-=d
            if sm==7:
                
                m=str(a)+B+str(b)+C+str(c)+D+str(d)+'=7'
                print(m)
                exit()

Solution (Python):
abcd=str(input())
for i in range(2**4):
    list=[int(abcd[0])]
    symbol=[]
    for j in range(1,4):
        if (i>>j)&1==True:
            list.append(int(abcd[j]))
            symbol.append('+')
        else:
            list.append(int(abcd[j])*(-1))
            symbol.append('-')
    if sum(list)==7:
        print(str(abcd[0])+symbol[0]+str(abcd[1])+symbol[1]+str(abcd[2])+symbol[2]+abcd[3]+"=7")
        break

Solution (Python):
s = input()

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

Solution (Python):
X = input()

A, B, C, D = [int(X[i]) for i in range(4)]

for i in range(2**3, 2**4):
    s = format(i, 'b')[1:]
    E = A + (-1) ** int(s[0]) * B + (-1) ** int(s[1]) * C + (-1) ** int(s[2]) * D
    if E == 7:
        break

op = ['+', '-']

print(str(A) + op[int(s[0])] + str(B) + op[int(s[1])] + str(C) + op[int(s[2])] + str(D) + '=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):
AA=list(input())

A=[int(n) for n in AA]
Q=sum(A)
B=Q-2*A[1]
C=Q-2*A[2]
D=Q-2*A[3]
E=Q-2*A[1]-2*A[2]
F=Q-2*A[1]-2*A[3]
G=Q-2*A[1]-2*A[2]-2*A[3]
H=Q-2*A[2]-2*A[3]
if Q==7:
    print(AA[0]+'+'+AA[1]+'+'+AA[2]+'+'+AA[3]+'='+'7')
elif B==7:
    print(AA[0]+'-'+AA[1]+'+'+AA[2]+'+'+AA[3]+'='+'7')
elif C==7:
    print(AA[0]+'+'+AA[1]+'-'+AA[2]+'+'+AA[3]+'='+'7')
elif D==7:
    print(AA[0]+'+'+AA[1]+'+'+AA[2]+'-'+AA[3]+'='+'7')
elif E==7:
    print(AA[0]+'-'+AA[1]+'-'+AA[2]+'+'+AA[3]+'='+'7')
elif F==7:
    print(AA[0]+'-'+AA[1]+'+'+AA[2]+'-'+AA[3]+'='+'7')
elif G==7:
    print(AA[0]+'-'+AA[1]+'-'+AA[2]+'-'+AA[3]+'='+'7')
elif H==7:
    print(AA[0]+'+'+AA[1]+'-'+AA[2]+'-'+AA[3]+'='+'7')

Solution (Python):
def dsf(i,sum1,ans):
    if i == 4:
        if ans == 7:
            print(sum1 + "=7")
            exit()
    else:
        dsf(i+1,sum1+"+"+abcd[i],ans + int(abcd[i]))
        dsf(i+1,sum1+"-"+abcd[i],ans - int(abcd[i]))


abcd = input()
dsf(1,abcd[0],int(abcd[0]))

Solution (Python):
x = input()
y = x[0] + 't' + x[1] + 't' + x[2] + 't' + x[3]
for i in range(8):
  for j in range(3):
    if ((i>>j) & 1) == 1:
      z = list(y)
      z[5-2*j] = '+'
      y = ''.join(z)
    else:
      z = list(y)
      z[5-2*j] = '-'
      y = ''.join(z)
      
  if eval(y) == 7:
    print(y+ '=7')
    break

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

def dfs(i,f,total):
  if i == n - 1:
    if total == 7:
      print(f + '=7')
      exit()
  else:
    dfs(i+1,f + '+' + S[i+1],total + int(S[i+1]))
    dfs(i+1,f + '-' + S[i+1],total - int(S[i+1]))

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

Solution (Python):

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

for i in range(1<<3):
    culc = A[0]
    box = []
    for j in range(3):
        mask = 1<<j
        if mask & i != 0:
            culc += A[j+1]
            box.append('+')
        else:
            culc -= A[j+1]
            box.append('-')
    if culc == 7:
        break
ans = [0]*7
ans[::2]=[str(i) for i in A]
ans[1::2]=box
ans.append('=7')
print(''.join(ans))

Solution (Python):
A,B,C,D = list(map(int, input()))
flag = 0
for op1 in ["+", "-"]:
    if flag:
        break
    tmp1 = A+B if op1=="+" else A-B
    for op2 in ["+", "-"]:
        if flag:
            break
        tmp2 = tmp1+C if op2=="+" else tmp1-C
        for op3 in ["+", "-"]:
            if flag:
                break
            tmp3 = tmp2+D if op3=="+" else tmp2-D
            if tmp3==7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7"
                print(ans)
                flag = 1
                break

Solution (Python):
sstr=list(input())
s=list(map(int,sstr))

op=["" for _ in range(3)]
for i in range(2**3):
    tmp=0
    tmp+=s[0]
    for j in range(3):
        if (i>>j)&1:
            tmp+=s[j+1]
            op[j]="+"
        else:
            tmp-=s[j+1]
            op[j]="-"
    if tmp==7:
        ans=sstr[0]+op[0]+sstr[1]+op[1]+sstr[2]+op[2]+sstr[3]+"=7"
        print(ans)
        break

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

def ops (i):
    ans = "+" if i == 0 else "-"
    return ans

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A + ((-1)**i)*B + ((-1)**j)*C + ((-1)**k)*D

            if ans == 7:
                print("{0}{1}{2}{3}{4}{5}{6}=7" .format(A,ops(i),B,ops(j),C,ops(k),D))
                sys.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(A,'+',B,'+',C,'+',D,'=7',sep='')
elif A-B+C+D==7:
    print(A,'-',B,'+',C,'+',D,'=7',sep='')
elif A-B-C+D==7:
    print(A,'-',B,'-',C,'+',D,'=7',sep='')
elif A-B-C-D==7:
    print(A,'-',B,'-',C,'-',D,'=7',sep='')
elif A+B-C-D==7:
    print(A,'+',B,'-',C,'-',D,'=7',sep='')
elif A+B+C-D==7:
    print(A,'+',B,'+',C,'-',D,'=7',sep='')
elif A-B+C-D==7:
    print(A,'-',B,'+',C,'-',D,'=7',sep='')
elif A+B-C+D==7:
    print(A,'+',B,'-',C,'+',D,'=7',sep='')

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

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

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

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

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

Solution (Python):
num = input()
A = int(num[0])
B = int(num[1])
C = int(num[2])
D = int(num[3])
if 7-A==B+C+D:
  op1='+'
  op2='+'
  op3='+'
elif 7-A==B+C-D:
  op1='+'
  op2='+'
  op3='-'
elif 7-A==B-C+D:
  op1='+'
  op2='-'
  op3='+'
elif 7-A==C+D-B:
  op1='-'
  op2='+'
  op3='+'
elif 7-A==B-C-D:
  op1='+'
  op2='-'
  op3='-'
elif 7-A==C-D-B:
  op1='-'
  op2='+'
  op3='-'
elif 7-A==D-C-B:
  op1='-'
  op2='-'
  op3='+'
elif 7-A==-D-C-B:
  op1='-'
  op2='-'
  op3='-'
print(num[0]+op1+num[1]+op2+num[2]+op3+num[3]+"=7")

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

for i in range(3**2):
    number = int(s[0])
    str = s[0]
    for j in range(3):
        if ((i>>j)&1):
            number += int(s[j+1])
            str += '+'+s[j+1]
        else:
            number -= int(s[j+1])
            str += '-'+s[j+1]
    if number == 7:
        print(str + '=7')
        exit(0)

Solution (Python):
abcd = input()

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

Solution (Python):
def main():
    S = input()

    for i in range(2 ** 3):
        c = S[0]
        for j in range(3):
            if (i >> j) & 1:
                c += "+"
            else:
                c += "-"
            c += S[j + 1]
        if eval(c) == 7:
            print(c + "=7")
            exit()


if __name__ == "__main__":
    main()

Solution (Python):
import sys

s = input()
def main():
    for i in range(2**3):
        localsum = s[0]
        for j in range(3):
            if (i >> j) & 1:
                localsum += "+"
            else:
                localsum += "-"
            localsum += s[j+1]
        sum = eval(localsum)
        if sum == 7:
            localsum += "=7"
            print(localsum)
            sys.exit()
main()

Solution (Python):
import sys

s = input()

for i in range(2**3):
    localsum = s[0]
    for j in range(3):
        if (i >> j) & 1:
            localsum += "+"
        else:
            localsum += "-"
        localsum += s[j+1]
    sum = eval(localsum)
    if sum == 7:
        localsum += "=7"
        print(localsum)
        sys.exit()

Solution (Python):
import sys

s = input()

for i in range(2**3):
    sum = 0
    localsum = s[0]
    for j in range(3):
        if (i >> j) & 1:
            localsum += "+"
        else:
            localsum += "-"
        localsum += s[j+1]
    sum += eval(localsum)
    if sum == 7:
        localsum += "=7"
        print(localsum)
        sys.exit()

Solution (Python):




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)


def resolve():
    N = input()

    for bit in range(1 << 3):
        S = ""
        for j in range(3):
            S += N[j]
            if bit & (1 << j) == 0:
                op = "+"
            else:
                op = "-"
            S += op
        S += N[3]
        if eval(S) == 7:
            print(S+"=7")
            break


if __name__ == "__main__":
    
    resolve()

Solution (Python):
numbers = input()
a,b,c,d = numbers
i = len(numbers)-1

op = ['+','-']

for j in range(2 ** i):
  o = [op[int((j>>k)&1)] for k in range(i)]
  f=f"{a}{o[0]}{b}{o[1]}{c}{o[2]}{d}"
  if eval(f) == 7:
    print(f+'=7')
    break

Solution (Python):
s=input()
ans=[]

for i in range(2**3):
  a=int(s[0])
  for j in range(3):
    if ((i>>j)&1):
      a+=int(s[j+1])
    else:
      a-=int(s[j+1])
      
  if a==7:
    ans.append(i)
    
u=ans[0]
ans1=[]
for j in range(3):
  if ((u>>j)&1):
      ans1.append('+')
  else:
      ans1.append('-')
      
print(s[0]+ans1[0]+s[1]+ans1[1]+s[2]+ans1[2]+s[3]+'=7')

Solution (Python):
def main():
    s = input()
    op = ["-", "+"]

    for i in range(2 ** 3):
        lst = [0] * 3
        for j in range(3):
            if (i >> j) & 1 == 1:
                lst[2 - j] = 1

        res = int(s[0])
        for j in range(3):
            if lst[j] == 0:
                res -= int(s[j + 1])
            if lst[j] == 1:
                res += int(s[j + 1])
        if res == 7:
            print(f"{s[0]}{op[lst[0]]}{s[1]}{op[lst[1]]}{s[2]}{op[lst[2]]}{s[3]}=7")
            break


if __name__ == "__main__":
    main()