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 = list(map(int, input()))
N = 7 - A

if B+C+D == N:
    print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif B+C-D == N:
    print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif B-C+D == N:
    print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif B-C-D == N:
    print('{}+{}-{}-{}=7'.format(A, B, C, D))

elif -B+C+D == N:
    print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif -B+C-D == N:
    print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif -B-C+D == N:
    print('{}-{}-{}+{}=7'.format(A, B, C, D))
else:
    print('{}-{}-{}-{}=7'.format(A, B, C, D))

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

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

Solution (Python):
line=str(input())
line=list(line)
line=list(map(int,line))
a=line[0]
b=line[1]
c=line[2]
d=line[3]
o1='+'
o2='+'
o3='+'
count=0
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7 and count==0:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
        count+=1
print("{}{}{}{}{}{}{}=7".format(a,o1,b,o2,c,o3,d))

Solution (Python):
N = list(map(int,[i for i in input()]))
op = ["000","001","010","100","011","101","110","111"]

num = sum(N)
for i in op:
  tmp = num
  if i[0] == "1":
    tmp -= N[1]*2
  if i[1] == "1":
    tmp -= N[2]*2
  if i[2] == "1":
    tmp -= N[3]*2
  if tmp == 7:
    ans = str(N[0])
    for j in range(3):
      if i[j] == "0":
        ans += "+"+ str(N[j+1])
      else:
        ans += "-"+ str(N[j+1])
    break
print(ans+"=7")

Solution (Python):
N = input()

ops = ['+','-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      cal = N[0] + op1 + N[1] + op2 + N[2] + op3 + N[3]
      if(eval(cal) == 7):
        print(N[0] + op1 + N[1] + op2 + N[2] + op3 + N[3] + '=7')
        exit()

Solution (Python):
s = list(input())
ops = ['+', '-']

for x in ops:
    for y in ops:
        for z in ops:
            fom = s[0] + x + s[1] + y + s[2] + z + s[3]
            if eval(fom) == 7:
                print(fom + '=7')
                exit(0)

Solution (Python):
numbers = [int(e) for e in input()]

for i in range(8):
    cand = format(i, 'b').zfill(3)
    res = numbers[0] + sum([n if b == '1' else -n for n, b in zip(numbers[1:], cand)])
    if res == 7:
        break

ope = ['+' if b == '1' else '-' for b in cand] + ['']
res = ''

for n, o in zip(numbers, ope):
    res += str(n) + o

print(res+'=7')

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

for i in op:
  for j in op:
    for k in op:
      formula = a+i+b+j+c+k+d
      if eval(formula) == 7:
        print(formula + '=7')
        exit()

Solution (Python):
def main():
    
    num = list(input())

    sum = 0
    s = ''

    
    for i in range(8):
        sum = int(num[0])
        s = num[0]
        for j in range(3):
            if (i >> j) & 1:
                sum += int(num[j+1])
                s = s + '+' + num[j+1]
            else:
                sum -= int(num[j+1])
                s = s + '-' + num[j+1]

        if sum == 7:
            s = s + '=' + str(sum)
            print(s)
            return

    return


main()

Solution (Python):
def main():
    
    num = list(input())

    
    op = [1, -1]
    opc = ['+','-']

    ans = 0
    fin = False

    
    for i in range(2):
        for j in range(2):
            for k in range(2):
                ans = int(num[0]) + op[i]*int(num[1]) + op[j]*int(num[2]) + op[k]*int(num[3])
                if ans == 7:
                    fin = True
                    break
                    
            if fin == True:
                break
        if fin == True:
            break

    print(num[0]+opc[i]+num[1]+opc[j]+num[2]+opc[k]+num[3]+'='+str(ans))

main()

Solution (Python):
abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans += '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7'.format(ans))
    break

Solution (Python):
N = input()



for x in ('+', '-'):
    for y in ('+', '-'):
        for z in ('+', '-'):
            res = int(N[0])
            
            if x == '+':
                res += int(N[1])
            else:
                res -= int(N[1])
                
            if y == '+':
                res += int(N[2])
            else:
                res -= int(N[2])
                
            if z == '+':
                res += int(N[3])
            else:
                res -= int(N[3])
                
            if res == 7:
                result = N[0] + x + N[1] + y + N[2] + z + N[3] + '=7'
                break
    
print(result)

Solution (Python):
num = list(input())
for i in range(4):
    num[i] = int(num[i])
res = [num[0]] * 8
for i in range(0,8):
    if i >> 2 & 1 == 1:
        res[i] += num[1]
    else:
        res[i] -= num[1]
    if i >> 1 & 1 == 1:
        res[i] += num[2]
    else:
        res[i] -= num[2]
    if i & 1 == 1:
        res[i] += num[3]
    else:
        res[i] -= num[3]
for i in range(0,8):
    if res[i] == 7:
        op1 = "+" if i >> 2 & 1 == 1 else "-"
        op2 = "+" if i >> 1 & 1 == 1 else "-"
        op3 = "+" if i >> 0 & 1 == 1 else "-"
        print(str(num[0])+op1+str(num[1])+op2+str(num[2])+op3+str(num[3])+"=7")
        break

Solution (Python):
abcd = input()

answer = 0
for i in range(1 << len(abcd) - 1):
    formula = abcd[0]
    for j in range(len(abcd) - 1):
        if (i >> j) & 1:
            formula += '+'
        else:
            formula += '-'
        formula += abcd[j + 1]
    canditate = eval(formula)
    if canditate == 7:
        print(formula + '=7')
        exit()

Solution (Python):
s=input()
a,b,c,d=s[0],s[1],s[2],s[3]
ans='=7'
def bitmath(nums):
    return bin(nums)[2:].zfill(3).replace('0','+').replace('1','-')
for i in range(2**len(s)-1):
    op=bitmath(i)
    if eval(a+op[0]+b+op[1]+c+op[2]+d)==7:
        print(a+op[0]+b+op[1]+c+op[2]+d+ans)
        exit()

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

Solution (Python):
s=list(input())
a,b,c,d=s[0],s[1],s[2],s[3]
aa,bb,cc,dd=int(a),int(b),int(c),int(d)
ops=['+']*3
ans='=7'
def sumsum(a,b,c,d):
    return a+b+c+d

if sumsum(aa,bb,cc,dd)==7:
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb==7:
    ops[0]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc==7:
    ops[1]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*dd==7:
    ops[2]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc==7:
    ops[0],ops[1]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc-2*dd==7:
    ops[1],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*dd==7:
    ops[0],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc-2*dd==7:
    ops='-'*3
    print(a+ops[0]+b+ops[1]+c+ops[2]+d+ans)
    exit()

Solution (Python):
st=input()
a=[]
for i in range(0,4):
    a.append(int(st[i]))

for i in range(0,1<<3):
    temp=a[0]
    j=0
    for j in range(0,3):
        if i>>j&1 :temp+=a[j+1]
        else :temp-=a[j+1]
    if temp==7:
        ans=str(a[0])
        for k in range(0,3):
            if i>>k&1:ans+="+"
            else:ans+="-"
            ans+=str(a[k+1])
        ans+="=7"
        break

print(ans)

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

arr = [1, -1]
tmp = []
for i in arr:
	for j in arr:
		for k in arr:
			if n[0] + i*n[1] + j*n[2] + k*n[3] == 7:
				ar2 = [i,j,k]
				for l in ar2:
					if l == 1:
						tmp.append('+')
					else:
						tmp.append('-')
		
print(str(n[0]) + tmp[0] + str(n[1]) + tmp[1] + str(n[2]) + tmp[2] + str(n[3]) + '=7')

Solution (Python):
n=input()
a,b,c,d=n[0],n[1],n[2],n[3]
X=['+','-']
for x1 in X:
    for x2 in X:
        for x3 in X:
            if eval(a+x1+b+x2+c+x3+d)==7:
                print(a+x1+b+x2+c+x3+d+"=7")
                exit()

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

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

Solution (Python):
N = str(input())
A, B, C, D = N[0], N[1], N[2], N[3]
 
ops = ['+','-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
        if eval(A + op1 + B + op2 + C + op3 + D) == 7:
            print(A + op1 + B + op2 + C + op3 + D + "=7")
            exit()

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

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

Solution (Python):
N = input()

answer = ""

for i in range(1 << 3):
    exp = N[0]
    for j in range(3):
        if i >> j & 1:
            exp += "+"
        else:
            exp += "-"
        exp += N[j + 1]
    if eval(exp) == 7:
        answer = exp
        break

print(answer + "=7")

Solution (Python):
ABCD = input()

for i in range(1 << 3):
    exp = ABCD[0]
    for j in range(3):
        if i >> j & 1:
            exp += '+'
        else:
            exp += '-'
        exp += ABCD[j + 1]
    if eval(exp) == 7:
        print(exp + '=7')
        break

Solution (Python):
S = list(input())
N = list(map(int,S))
def minus(x,y):
    if y == 0:
        return x
    else:
        return -1*x
def sign(x):
    if x == 0:
        return '+'
    else:
        return '-'
ans = ''
for i in range(7):
    b = list(map(int,format(i,'b').zfill(3)))
    seven = N[0]
    for k in range(3):
        seven +=  minus(N[k+1],b[k])
    if 7 == seven:
        for j in range(3):
            ans += S[j] + sign(b[j])
        ans += S[3] + "=7"
        print(ans)
        quit()

Solution (Python):
N = list(map(int,input()))
def minus(x,y):
    if y == 0:
        return x
    else:
        return -1*x
def plmi(x):
    if x == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            if 7 == N[0] + minus(N[1],i) + minus(N[2],j) + minus(N[3],k):
                print(str(N[0])+plmi(i)+str(N[1])+plmi(j)+str(N[2])+plmi(k)+str(N[3])+"=7")
                quit()

Solution (Python):
N = input()
for i in range(2 ** (len(N) - 1)):
    s = ''
    for n in N:
        s += n
        if len(s) != len(N) + 3:
            if i % 2 != 0:
                s += '+'
            else:
                s += '-'
        else:
            break
        i //= 2
    if eval(s) == 7:
        print(s + '=7')
        break

Solution (Python):
import sys
S = input()
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            if eval(S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3]) == 7:
                print(S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3] + '=7')
                sys.exit()

Solution (Python):
num = input()


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

Solution (Python):
a,b,c,d=list(input())
from itertools import product
for p in product(['+','-'],repeat=3):
    s=a+p[0]+b+p[1]+c+p[2]+d
    if eval(s)==7:
        print(s+'=7')
        exit()

Solution (Python):
a, b, c, d = map(int, list(input()))
Lis = ["+", "-"]
for k in range(8):
    bi = list(map(int, bin(k).replace('b', '0')))
    bi.reverse()
    res = a+b if not bi[0] else a-b
    res += c if not bi[1] else -c
    res += d if not bi[2] else -d
    if res == 7:
        print(str(a)+Lis[bi[0]]+str(b)+Lis[bi[1]] +
              str(c)+Lis[bi[2]]+str(d)+"=7")
        break

Solution (Python):
s_str = input()
s = list(map(int, s_str))
 
for i in range(2**(len(s)-1)):
    tmp = s[0]
    ans = s_str[0]
        
    for j in range(len(s)-1):
        if i&(2**j) != 0:
            tmp += s[j+1]
            ans += '+'+ s_str[j+1]
        else:
            tmp -= s[j+1]
            ans += '-'+ s_str[j+1]
    if tmp == 7:
        print(ans+'=7')
        exit()

Solution (Python):
s=input()
num=[]
for i in range(4):
    num.append(int(s[i]))
ans=[]
lis=[-1,1]
for b in lis:
    for c in lis:
        for d in lis:
                if num[0]+b*num[1]+c*num[2]+d*num[3]==7:ans=[b,c,d]

res=str(num[0])
for i in range(3):
    if ans[i]==-1:res+='-'
    elif ans[i]==1:res+='+'
    res+=str(num[i+1])
res+='=7'
print(res)

Solution (Python):


ticket = list(input())

for i in range(1 << (len(ticket)-1)):
    exp = []
    for j in range(len(ticket)-1):
        if (i >> j) & 1:
            
            exp.append("{}+".format(ticket[j]))
        else:
            
            exp.append("{}-".format(ticket[j]))
    exp.append(ticket[-1])
    e = "".join(exp)
    if eval(e) == 7:
        print("{}={}".format(e, eval(e)))
        exit()

Solution (Python):
l=list(input())
plmi = [0 for i in range(3)] 
for i in range(1 << 3):
    p=int(l[0])
    for j in range(3):
        if (i >> j) & 1:
            p+=int(l[j+1])
            plmi[j]='+'
        else:
            p-=int(l[j+1])
            plmi[j]='-'
    if p==7:
        print(l[0]+plmi[0]+l[1]+plmi[1]+l[2]+plmi[2]+l[3]+'=7')
        break

Solution (Python):
num = list(map(int,list(input())))
plusminus= [0 for i in range(3)]

for i in range(1 << 3):
    p = num[0]
    for j in range(3):
        if ((i >> j) & 1):
            p += num[j+1]
            plusminus[j] = '+'
            
        else:
            p -= num[j+1]
            plusminus[j] = '-'
            
    if p == 7:
        print(num[0],plusminus[0],num[1],plusminus[1],num[2],plusminus[2],num[3],'=7',sep='')
        break

Solution (Python):
ABCD = input().strip()
answer = ''
for i in range(1 << 4-1):
    output = []
    for j in range(4-1):
        if (i>>j)&1 == 1:
            output.append(ABCD[j])
            output.append('+')
        else:
            output.append(ABCD[j])
            output.append('-')
    output.append(ABCD[3])
    formula = ''.join(output)
    if eval(formula) == 7:
        answer = answer.join(formula+'=7')
        break
    else:
        output.clear()
        
print(answer)

Solution (Python):
def solve():
    s = input()
    nums = [int(s[i]) for i in range(len(s))]

    for op in range(0, 1<<3):
        val = nums[0]

        bits = [((op>>i)&1)!=0 for i in range(3)]

        for i in range(3):
            if bits[i]:
                val = val + nums[i+1]
            else:
                val = val - nums[i+1]
        if val == 7:
            ans = str(nums[0])
            for i in range(3):
                if bits[i]:
                    ans += "+" + str(nums[i+1])
                else:
                    ans += "-" + str(nums[i+1])
            ans += "=7"
            print(ans)
            return

solve()

Solution (Python):
from itertools import product
li = list(map(int, input()))

for ops in product('+-', repeat=3):
    tmp = li[0]
    for o, n in zip(ops, li[1:]):
        if o == '+':
            tmp += n
        else:
            tmp -= n
    if tmp == 7:
        ans = str(li[0])
        for o, n in zip(ops, li[1:]):
            ans += o + str(n)
        ans += '=7'
        break

print(ans)

Solution (Python):


def main():
    a, b, c, d = input()
    for o1 in ["+", "-"]:
        for o2 in ["+", "-"]:
            for o3 in ["+", "-"]:
                s = "".join([a, o1, b, o2, c, o3, d])
                if eval(s) == 7:
                    return s + "=7"


if __name__ == "__main__":
    print(main())

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:s = s[0]+'+'+s[1]+'+'+s[2]+'+'+s[3]+'=7'
elif a+b+c-d == 7:s = s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'=7'
elif a+b-c+d == 7:s = s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'=7'
elif a+b-c-d == 7:s = s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'=7'
elif a-b-c-d == 7:s = s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'=7'
elif a-b-c+d == 7:s = s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'=7'
elif a-b+c-d == 7:s = s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'=7'
elif a-b+c+d == 7:s = s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'=7'

print(s)

Solution (Python):


import itertools

ABCD = input()
l = len(ABCD)
cs = itertools.product(['+', '-'], repeat=l-1)

ans = 0
for c in cs:
    ex = ''.join([ABCD[i] + c[i] for i in range(l-1)] + [ABCD[-1]])
    exec("ans = {}".format(ex))
    if ans == 7:
        break

print(ex + "=7")

Solution (Python):
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0:
  	break
  for j in range(2):
    if c!=0:
      	break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break

Solution (Python):


from itertools import product

def main():
    a, b, c, d = map(int, input())
    for x, y, z in product(("+", "-"), repeat=3):
        eq = "a{x}b{y}c{z}d".format(x=x, y=y, z=z)
        val = eval(eq)
        if val == 7:
            print("{a}{x}{b}{y}{c}{z}{d}=7".format(x=x, y=y, z=z, a=a, b=b, c=c, d=d))
            return

main()

Solution (Python):

import sys





"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = ip.S()
    h = ["+", "-"]

    for i in h:
        for j in h:
            for k in h:
                p = s[0] + i + s[1] + j + s[2] + k + s[3]

                if eval(p) == 7:
                    p += "=7"
                    ans = p

    print(ans)


main()

Solution (Python):
from itertools import product
l = list(map(int, input()))
comb = product((0, 1), repeat=3)

def can_calc(l, comb):
    val = l[0]
    for i in range(3):
        if comb[i] == 0:
            val += l[i+1]
        else:
            val -= l[i+1]
    if val == 7:
        return True
    else:
        return False

for c in comb:
    if can_calc(l, c):
        break
l = ''.join(map(str, l))
c = ''.join(map(lambda x: '+' if x==0 else '-', c))
print(l[0]+c[0]+l[1]+c[1]+l[2]+c[2]+l[3]+'=7')

Solution (Python):
s = input()
s0 = int(s[0])
s1 = int(s[1])
s2 = int(s[2])
s3 = int(s[3])

for i in range(2):
    a = s0
    if i == 0:
        b = s1
        x = '+'
    else:
        b = -s1
        x = ''
        
    for j in range(2):
        if j == 0:
            c = s2
            y = '+'
        else:
            c = -s2
            y = ''
            
        for k in range(2):
            if k == 0:
                d = s3
                z = '+'
            else:
                d = -s3
                z = ''
            
            if a+b+c+d == 7:
                e = [str(a),x,str(b),y,str(c),z,str(d),'=7']
                print(''.join(e))
                exit()

Solution (Python):
s = input()
l = []
ans = 7
for i in range(4):
    l.append(s[i])

for i in range(1 << 3):
    op = []
    for j in range(3):
        if i & (1 << j):
            op.append('+')
        else:
            op.append('-')

    tmp = str(l[0])
    for k in range(3):
        tmp += op[k]
        tmp += str(l[k+1])

    if eval(tmp) == ans:
        tmp += '=7'
        print(tmp)
        exit()

Solution (Python):
S = input()
opt = ['+', '-']

flag = 1
if flag:
    for i in opt:
        if flag:
            for j in opt:
                if flag:
                    for k in opt:
                        temp = S[0] + i + S[1] + j + S[2] + k + S[3]
                        ans = eval(temp)
                        if ans == 7:
                            flag = 0
                            break
                    
print(''.join(list(temp)), end = '')
print('=7')

Solution (Python):
inputs = list(map(int, list('1222')))
target = 7


def prepare():
    global inputs
    inputs = list(map(int, list(input())))


def dfs(depth, value, form):
    if depth == len(inputs):
        if value == target:
            return True, form + '=' + str(target)
        else:
            return False, form

    result1, form1 = dfs(depth + 1, value + inputs[depth],
                         (form + '+'
                          if depth > 0 else '') + str(inputs[depth]))
    if result1 is True:
        return result1, form1

    result2, form2 = dfs(depth + 1, value - inputs[depth],
                         (form + '-'
                          if depth > 0 else '') + str(inputs[depth]))
    if result2 is True:
        return result2, form2

    return False, ''


def solve():
    result, form = dfs(0, 0, '')
    if result is True:
        print(form)


prepare()
solve()

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    S = ii(str)
    A, B, C, D = (s for s in S)
    for i in ("+", "-"):
        for j in ("+", "-"):
            for k in ("+", "-"):
                s = A + i + B + j + C + k + D
                if eval(s) == 7:
                    return s + "=7"


if __name__ == "__main__":
    print(solve())

Solution (Python):
n=input()
a=('+','-')
flag=0
for i in range(2):
  for j in range(2):
    for k in range(2):
      siki=n[0]+a[i]+n[1]+a[j]+n[2]+a[k]+n[3]
      if eval(siki)==7 and flag==0:
        print(siki+'=7')
        flag=1

Solution (Python):
s = input()


def op(n):
    if n == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            eq = s[0]+op(i)+s[1]+op(j)+s[2]+op(k)+s[3]
            if eval(eq) == 7:
                print(eq+'=7')
                exit()

Solution (Python):
import sys
pm = ["+", "-"]








ABCD = str(input())
for s0 in pm:
    for s1 in pm:
        for s2 in pm:
            if(eval(ABCD[0] + s0 + ABCD[1] + s1 + ABCD[2] + s2 + ABCD[3] ) == 7):
                print(ABCD[0] + s0 + ABCD[1] + s1 + ABCD[2] + s2 + ABCD[3] + "=7")
                sys.exit()

Solution (Python):
D = input()

ops = []
for i in range(1 << 3):
    op = ""
    xx = bin(i)[2::].zfill(3)
    for x in xx:
        if x=="0":
            op += "+"
        else:
            op += "-"
    ops.append(op)

for op in ops:
    res = D[0]
    for i in range(3):
        res += op[i]+D[i+1]
    if eval(res)==7:
        print(res + "=7")
        break

Solution (Python):
def solve():
    a, b, c, d = input()
    for bit in range(2 ** 3):
        o1, o2, o3 = ['+' if bit & (1 << i) == 0 else '-' for i in range(3)]
        stmt = ''.join([a,o1,b,o2,c,o3,d])
        if eval(stmt) == 7:
            return stmt + "=7"

print(solve())

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


OP = list(itertools.product(op,repeat = 3))
def can_seven(li,op):
    m = len(op)
    n = len(op[0])
    for j in range(m):
        res = li[0]
        for i in range(n):
            if op[j][i] == "+": res += li[i+1]
            else: res -= li[i+1]
        if res == 7:
            return ("{0}"+op[j][0]+"{1}"+op[j][1]+"{2}"+op[j][2]+"{3}=7").format(li[0],li[1],li[2],li[3])
    return "Fail"

print(can_seven(ABCD,OP))

Solution (Python):
from itertools import product
number = list(input())

for c in product(range(2),repeat=3):
    formula = number[0]
    for i in range(3):
        if c[i] == 1:
            formula += '+' + number[i+1]
            
        else:
            formula += '-' + number[i+1]
    if eval(formula) == 7:
        print(formula + '=7')
        break

Solution (Python):
a, b, c, d = input()
for i in ['+', '-']:
    for j in ['+', '-']:
        for k in ['+', '-']:
            s = a + i + b + j + c + k + d
            if eval(s) == 7:
                print(s + '=7')
                exit()

Solution (Python):
s = list(map(int,list(input())))
check = [[0 for i in range(3)] for j in range(1 << 3)]

for i in range(1 << 3):

    for j in range(3):
        if ((i >> j) & 1) == 1:
            check[i][j] = '+'
        else:
            check[i][j] = '-'

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

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

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

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

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

Solution (Python):
abcd = input()
ans=''
for i in range(8):
    op1 = '+' if (1 & i) != 0 else '-'
    op2 = '+' if (2 & i) != 0 else '-'
    op3 = '+' if (4 & i) != 0 else '-'
    s = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3]
    if eval(s) == 7: ans = s + '=7'
print(ans)

Solution (Python):
from itertools import product

S = input()
op = list(product(["+","-"],repeat=3))

for i in range(len(op)) :
    calc = S[0]+op[i][0]+S[1]+op[i][1]+S[2]+op[i][2]+S[3]
    if eval(calc) == 7 :
        print(calc+"=7")
        break