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
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    E = list(map(int, list(input())))
    

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

        f = '{}{}{}{}{}{}{}'.format(E[0], op[0], E[1], op[1], E[2], op[2], E[3])
        e = eval(f)
        if e == 7:
            print(f + '=7')
            return



if __name__ == '__main__':
    solve()

Solution (Python):
n=[int(x) for x in input()]
for i in range(2**(len(n)-1)):
    s=n[0]
    result=[str(n[0])]
    for j in range(len(n)-1):
        if (i>>j &1)==1:
            s+=n[j+1]
            result.append("+")
        else:
            s-=n[j+1]
            result.append("-")
        result.append(str(n[j+1]))
    result.append("=7")
    if s==7:
        print("".join(result))
        break

Solution (Python):
S = input()
s = S[0]
score = int(S[0])
def rec(n, s, score):
    if n == 1:
        if score == 7:
            print(s + "=7")
            exit()
            
    else:
        rec(n-1, s+"+"+S[-n+1], score+int(S[-n+1]))
        rec(n-1, s+"-"+S[-n+1], score-int(S[-n+1]))
    
print(rec(len(S), s, score))

Solution (Python):
ABCD=list(map(int,list(input())))
for i in range(2**3):
    op=[0]*3
    for j in range(3):
        op[j]=i%2
        i//=2
    val=ABCD[0]
    for j in range(3):
        if op[j]==1:
            val+=ABCD[j+1]
        else:
            val-=ABCD[j+1]
    if val==7:
        ans=str(ABCD[0])
        for j in range(3):
            if op[j]==1:
                ans+="+"
            else:
                ans+="-"
            ans+=str(ABCD[j+1])
        print(ans+"=7")
        exit()

Solution (Python):
N=int(input())
A=[0,0,0,0]
for i in range(4):
  A[3-i]=N%10
  N=int(N/10)


for bit in range(2**3+1):
  a=A[0]
  for i in range(3):
    if (bit>>i)&1:
      a-=A[i+1]
    else:
      a+=A[i+1]
  
  if a==7:
    text=str(A[0])
    for i in range(3):
      if (bit>>i)&1:
        text+="-"
      else:
        text+="+"
      text+=str(A[i+1])
    print(text+"=7")
    break

Solution (Python):
import copy
Input = [i for i in input()]

for i in range(2**3):
    AltInput=Input.copy()
    formula = AltInput.pop(0)
    for j in range(3):
        if((i >> j) & 1):
            formula += '+'
        else:
            formula += '-'
        formula += AltInput.pop(0)
    if(eval(formula) == 7):
        print(formula + '=7')
        break

Solution (Python):

def main():
    import sys
    import itertools as ite
    nums = list(map(int, list(sys.stdin.readline().rstrip())))
    ope = list(ite.product(['+', '-'], repeat=3))
    
    
    def calc(L):
        ans = L[0]
        for i in range(1, len(L)-1, 2):
            if L[i] =='+':
                ans +=L[i+1]
            elif L[i] =='-':
                ans -=L[i+1]
        if ans ==7:
            L = ''.join(list(map(str, L)))
            print(L+'=7')
            return True
    
    for op in ope:
        L=[]
        for i in range(3):
            L += [nums[i], op[i]]
        L+=[nums[3]]
        
        if calc(L) ==True:
            break
        


if __name__=='__main__':
    main()

Solution (Python):
ticket = list(input())
if int(ticket[0])+int(ticket[1])+int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"+"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])+int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"+"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])-int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"-"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])+int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"+"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])-int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"-"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])+int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"+"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])-int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"-"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])-int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"-"+ticket[2]+"-"+ticket[3]+"=7")

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

opt1, opt2, opt3 = "","",""
if a+b+c+d==7:
    opt1,opt2,opt3="+", "+", "+"
elif a-b+c+d==7:
    opt1,opt2,opt3="-", "+", "+"
elif a+b-c+d==7:
    opt1,opt2,opt3="+", "-", "+"
elif a+b+c-d==7:
    opt1,opt2,opt3="+", "+", "-"
elif a-b-c+d==7:
    opt1,opt2,opt3="-", "-", "+"
elif a-b+c-d==7:
    opt1,opt2,opt3="-", "+", "-"
elif a+b-c-d==7:
    opt1,opt2,opt3="+", "-", "-"
elif a-b-c-d==7:
    opt1,opt2,opt3="-", "-", "-"
print("%d%s%d%s%d%s%d=7" %(a,opt1,b,opt2,c,opt3,d))

Solution (Python):
ticket = list(input())
if int(ticket[0])+int(ticket[1])+int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"+"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])+int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"+"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])-int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"-"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])+int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"+"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])-int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"-"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])+int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"+"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])-int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"-"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])-int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"-"+ticket[2]+"-"+ticket[3]+"=7")

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):
a, b, c, d = input()
op_cnt = 3

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        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 itertools

abcd = input()
for op in itertools.product(['+', '-'], repeat=3):
    formula = abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3]
    if eval(formula) == 7:
        print(formula + "=7")
        exit()

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):
a,*x=list(map(int,input()))
for i in range(8):
    k=a
    ans=str(a)
    for j in range(3):
        if i>>j&1:
            k+=x[j]
            ans+="+"+str(x[j])
        else:
            k-=x[j]
            ans+="-"+str(x[j])
    if k==7:
        print(ans+"=7")
        exit()

Solution (Python):
S = input()

for i in range(2 ** 3):
  op = ['+','+','+','+']
  ans = int(S[0])
  bit = bin(i)
  bit = bit[2:len(bit)].zfill(3)
  for j in range(len(S)-1):
    if bit[j] == "0":
      ans += int(S[j+1])
      op[j] = '+'
      
    else:
      ans -= int(S[j+1])
      op[j] = '-'
      
  if ans == 7:
    print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+"=7")
    break

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

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

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

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):
def q3():
    import itertools
    li = [int(i) for i in list(input())]

    ans_op = None
    ops = list(itertools.product(['+','-'], repeat=3))
    for op in ops:
        tmp_sum = li[0]
        for i, o in enumerate(op):
            if o == '+':
                tmp_sum += li[i+1]
            else:
                tmp_sum -= li[i+1]
        if tmp_sum == 7:
            ans_op = op
            break

    return '{}{}{}{}{}{}{}=7'.format(li[0], op[0], li[1], op[1], li[2], op[2], li[3])


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

Solution (Python):
a,b,c,d = map(int,input())
op1,op2,op3 = "","",""
if a+b+c+d==7:
  op1,op2,op3 = "+","+","+"
elif a+b+c-d==7:
  op1,op2,op3 = "+","+","-"
elif a+b-c+d==7:
  op1,op2,op3 = "+","-","+"
elif a+b-c-d==7:
  op1,op2,op3 = "+","-","-"
elif a-b-c-d==7:
  op1,op2,op3 = "-","-","-"
elif a-b-c+d==7:
  op1,op2,op3 = "-","-","+"
elif a-b+c-d==7:
  op1,op2,op3 = "-","+","-"
elif a-b+c+d==7:
  op1,op2,op3 = "-","+","+"
print("%d%s%d%s%d%s%d=7" % (a,op1,b,op2,c,op3,d))

Solution (Python):
A = list(input())
B = list(map(int, A))
for i in range(2**3):
  ans = B[0]
  for j in range(3):
    if ((i>>j) & 1):
      ans += B[j+1]
    else:
      ans -= B[j+1]
  if ans == 7:
    for k in range(3):
      print(B[k], end = "")
      if ((i>>k) & 1):
        print("+", end = "")
      else:
        print("-", end = "")
    print(B[3], end = "")
    print("=7")
    break

Solution (Python):
import itertools
def solve(a, b, c, d):

    for operators in itertools.product(["+", "-"], repeat=3):
        ans = str(a)
        tmp = a
        for n, op in zip([b,c,d], operators):
            ans += op + str(n)
            if op == "+":
                tmp += n
            else:
                tmp -= n
        if tmp == 7:
            break

    return ans + "=7"

if __name__ == "__main__":
    a,b,c,d = [int(i) for i in input()]
    print(solve(a, b, c, d))

Solution (Python):

number = input()

n = 3

for bit in range(2 ** n):
    ope = ['-'] * n
    for i in range(n):
        if ((bit >> i) & 1):
            ope[n - 1 - i] = '+'
    
    ans = ''

    for num, op in zip(number, ope):
        ans += num + op
    ans += number[-1]
    if eval(ans) == 7:
        print(ans + '=7')
        exit()

Solution (Python):

import sys


def solve(ABCD: str):
    from itertools import product
    base = '{}{{}}{}{{}}{}{{}}{}'.format(*ABCD)
    for ops in product('+-', repeat=3):
        exp = base.format(*ops)
        if eval(exp) == 7:
            return exp + '=7'
    raise



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

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
ABCD=input()
dic={}
dic[1]="+"
dic[0]="-"
for i in range(8):
  result=int(ABCD[0])
  kigou=[]
  for j in range(3):
    if ((i >> j) & 1):
      kigou+=[dic[1]]
      result+=int(ABCD[3-j])
    else:
      kigou+=[dic[0]]
      result-=int(ABCD[3-j])
  if result==7:
    print(ABCD[0]+kigou[2]+ABCD[1]+kigou[1]+ABCD[2]+kigou[0]+ABCD[3]+"=7")
    break

Solution (Python):
import sys
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]
if int(A) + int(B) + int(C) + int(D) == 7:
    print(A + '+' + B + '+' + C + '+' + D + '=7')
    sys.exit()
if int(A) - int(B) + int(C) + int(D) == 7:
    print(A + '-' + B + '+' + C + '+' + D + '=7')
    sys.exit()
if int(A) + int(B) - int(C) + int(D) == 7:
    print(A + '+' + B + '-' + C + '+' + D + '=7')
    sys.exit()
if int(A) - int(B) - int(C) + int(D) == 7:
    print(A + '-' + B + '-' + C + '+' + D + '=7')
    sys.exit()
if int(A) + int(B) + int(C) - int(D) == 7:
    print(A + '+' + B + '+' + C + '-' + D + '=7')
    sys.exit()
if int(A) - int(B) + int(C) - int(D) == 7:
    print(A + '-' + B + '+' + C + '-' + D + '=7')
    sys.exit()
if int(A) + int(B) - int(C) - int(D) == 7:
    print(A + '+' + B + '-' + C + '-' + D + '=7')
    sys.exit()
if int(A) - int(B) - int(C) - int(D) == 7:
    print(A + '-' + B + '-' + C + '-' + D + '=7')
    sys.exit()

Solution (Python):
ABCD = input()
ans = ''
def dfs(i, s):
    global ans
    s += ABCD[i]
    if i == 3:
        if eval(s) == 7:
            ans = s
        return
    i += 1
    dfs(i, s+'+')
    dfs(i, s+'-')
dfs(0, '')
print(ans+'=7')

Solution (Python):
import sys











stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n = str(stdin.readline().rstrip())






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

Solution (Python):
nums = list(input())
for i in range(2**3):
    seven = int(nums[0])
    opt = []
    for j in range(3):
        if i >> j & 1:
            seven += int(nums[j+1])
            opt.append("+")
        else:
            seven -= int(nums[j+1])
            opt.append("-")
    if seven == 7:
        print(nums[0]+opt[0]+nums[1]+opt[1]+nums[2]+opt[2]+nums[3]+"=7")
        exit()

Solution (Python):
x=[int(k) for k in input()]
for i in range(2**3):
  total=x[0]
  bag=[""]*3
  for j in range(3):
    if (i>>j)&1:
      bag[j]="+"
      total+=x[j+1]
    else:
      bag[j]="-"
      total-=x[j+1]
  if total==7:
    print("{}{}{}{}{}{}{}=7".format(x[0],bag[0],x[1],bag[1],x[2],bag[2],x[3]))
    break

Solution (Python):
import numpy as np

abcd = input()


for i in range(2**3):
    ops = ["-","-","-",""]
    for j in range(3):
        if i>>j&1: ops[j] = "+"
    equa = ""
    for s,op in zip(abcd,ops): equa += s+op
    if eval(equa) == 7 : break

ans = equa + "=7"
print(ans)

Solution (Python):
import numpy as np

abcd = input()


for i in range(2**3):
    ops = ["-","-","-",""]
    for j in range(3):
        if i>>j&1: ops[j] = "+"
    equa = ""
    for s,op in zip(abcd,ops): equa += (s+op)
    if eval(equa) == 7 : break

ans = equa + "=7"
print(ans)

Solution (Python):
s = input()
for i in range(2**3):
    l=[]
    for j in range(3):
        if (i>>j)&1:
            l.append("+")
        else:
            l.append("-")
    x = ""
    for k,lp in zip(s,l):
        x+=k
        x+=lp
    x+=s[-1]
    if eval(x)==7:
        print(x+"=7")
        break

Solution (Python):


num = [int(i) for i in input()]

for s in range(2**3):
    total = num[0]
    op = [""] * 3
    for i in range(3):
        if (s >> i & 1):
            total += num[i+1]
            op[i] = "+"
        else:
            total -= num[i+1]
            op[i] = "-"
    if (total == 7):
        print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
        break

Solution (Python):
S = input()
num = [int(S[i]) for i in range(4)]

for i in range(2 ** 3):
    ans = ''
    total = 0
    k = 3
    for j in range(3):
        if (i >> j) & 1:
            total += num[k]
            ans = ('+' + str(num[k])) + ans
        else:
            total -= num[k]
            ans = ('-' + str(num[k])) + ans
        k -= 1
    
    if total + num[0] == 7:
        print(str(num[0]) + ans + '=7')
        break

Solution (Python):
from itertools import product
s = list(input())
n = len(s)-1

for x in list(product(["+", "-"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    if eval("".join(strs)) == 7:
        print("".join(strs) + "=7")
        break

Solution (Python):
n = input()

for i in range(2**3):
    calcu=['-']*3
    for j in range(3):
        if (i>>j)&1:
            calcu[3-1-j]='+'
    formula=''
    for tmp_1,tmp_2 in zip(n,calcu+['']):
        formula+=(tmp_1+tmp_2)
    if eval(formula)==7:
        print(formula+'=7')
        break

Solution (Python):
from itertools import product

a = list(str(input()))


for bit in product([0,1],repeat=3): 
    x = ["+","+","+"]
    for i,j in enumerate(bit): 
        
        if j == 1:
            x[i] = "-"
    if eval(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]) == 7:
        print(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]+"=7")
        break 


"""       i j
(0, 0, 0) 0 0
(0, 0, 0) 1 0
(0, 0, 0) 2 0

(0, 0, 1) 0 0
(0, 0, 1) 1 0
(0, 0, 1) 2 1

(0, 1, 0) 0 0
(0, 1, 0) 1 1
(0, 1, 0) 2 0

(0, 1, 1) 0 0
(0, 1, 1) 1 1
(0, 1, 1) 2 1

(1, 0, 0) 0 1
(1, 0, 0) 1 0
(1, 0, 0) 2 0

(1, 0, 1) 0 1
(1, 0, 1) 1 0
(1, 0, 1) 2 1

(1, 1, 0) 0 1
(1, 1, 0) 1 1
(1, 1, 0) 2 0

(1, 1, 1) 0 1
(1, 1, 1) 1 1
(1, 1, 1) 2 1
"""

Solution (Python):
S = list(input())
L = len(S)

for i in range(0, 1 << L-1):
    f = S[0]
    ans = int(S[0])
    for j in range(L-1):
        if (i >> j) & 1:
            f += "+"
            f += S[j+1]
            ans += int(S[j+1])
        else:
            f += "-"
            f += S[j+1]
            ans -= int(S[j+1])
    if ans == 7:
        print(f, "=7", sep="")
        exit()

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


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

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

Solution (Python):
s = input()
for i in range(2**3):
    ls = ['+','+','+']
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = '-'
    if eval(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]) == 7:
        print(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]+"=7")
        break

Solution (Python):
A = list(input())
S = [-1,1]
res = ["-","+"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if int(A[0])+int(A[1])*S[i]+int(A[2])*S[j]+int(A[3])*S[k] == 7:
                print(A[0]+res[i]+A[1]+res[j]+A[2]+res[k]+A[3]+"=7")
                exit()

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

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

Solution (Python):
from sys import exit
def dfs(i,f,sum):
  if i == n-1:
    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()
n=len(s)
dfs(0, s[0],int(s[0]))

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

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

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

ls = ["+"] * 3


for i in range(2**3):
    ls = ["+"] * 3
    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):
import sys
s = input()
n = len(s)

ans = 7

for bit in range(2**(n-1)):
    tmp = s[0]
    for i in range(n-1):
        if (1<<i)&bit:
            tmp += '+'
        else:
            tmp += '-'
        tmp += s[i+1]
    total = eval(tmp)
    if total == ans:
        print(tmp + '=7')
        sys.exit()

Solution (Python):
s = input()
for i in range(8):
    fom_lst = []
    for j in range(3):
        if (i >> j) & 1:
            fom_lst.append('+')
        else:
            fom_lst.append('-')
        S = ''
    for num, fom in zip(s, fom_lst):
        S += num + fom
    S += s[-1]
    if eval(S) == 7:
        print(S + '=7')
        break

Solution (Python):

abcd = input()
ans = ""





if int(abcd[0]) + int(abcd[1]) + int(abcd[2]) + int(abcd[3]) == 7:
    ans = abcd[0] + "+" + abcd[1] + "+" + abcd[2] + "+" + abcd[3] + "=7"
elif int(abcd[0]) + int(abcd[1]) + int(abcd[2]) - int(abcd[3]) == 7:
    ans = abcd[0] + "+" + abcd[1] + "+" + abcd[2] + "-" + abcd[3] + "=7"
elif int(abcd[0]) + int(abcd[1]) - int(abcd[2]) + int(abcd[3]) == 7:
    ans = abcd[0] + "+" + abcd[1] + "-" + abcd[2] + "+" + abcd[3] + "=7"
elif int(abcd[0]) + int(abcd[1]) - int(abcd[2]) - int(abcd[3]) == 7:
    ans = abcd[0] + "+" + abcd[1] + "-" + abcd[2] + "-" + abcd[3] + "=7"
elif int(abcd[0]) - int(abcd[1]) + int(abcd[2]) + int(abcd[3]) == 7:
    ans = abcd[0] + "-" + abcd[1] + "+" + abcd[2] + "+" + abcd[3] + "=7"
elif int(abcd[0]) - int(abcd[1]) + int(abcd[2]) - int(abcd[3]) == 7:
    ans = abcd[0] + "-" + abcd[1] + "+" + abcd[2] + "-" + abcd[3] + "=7"
elif int(abcd[0]) - int(abcd[1]) - int(abcd[2]) + int(abcd[3]) == 7:
    ans = abcd[0] + "-" + abcd[1] + "-" + abcd[2] + "+" + abcd[3] + "=7"
elif int(abcd[0]) - int(abcd[1]) - int(abcd[2]) - int(abcd[3]) == 7:
    ans = abcd[0] + "-" + abcd[1] + "-" + abcd[2] + "-" + abcd[3] + "=7"

print(ans)

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

for bit in range(1<<(length-1)):  
  ans = 0
  f = s[0]  
  for i in range(length-1): 
    if bit & (1 << i):   
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  
  ans = eval(f)
  
  if ans == 7:
    print(f+'=7')
    exit()

Solution (Python):

num_list = list(map(int, list(input())))
i = 0
for i in range(2 ** 3):
    result = num_list[0]
    result += num_list[1] * (1 if (i & 0b001) != 0 else -1)
    result += num_list[2] * (1 if (i & 0b010) != 0 else -1)
    result += num_list[3] * (1 if (i & 0b100) != 0 else -1)
    if result == 7:
        break

print("{}{}{}{}{}{}{}=7".format(
    num_list[0],
    '+' if (i & 0b001) != 0 else '-',
    num_list[1],
    '+' if (i & 0b010) != 0 else '-',
    num_list[2],
    '+' if (i & 0b100) != 0 else '-',
    num_list[3]
))

Solution (Python):
def main():
    S = input()
    n = len(S)
    bit = 0
    total = 0
    ans = ''
    for bit in range(1<<n-1):
        tmp_total = int(S[0])
        ops = ''
        for i in range(n-1):
            if (1<<i) & bit:
                tmp_total += int(S[i+1])
                ops += '+'
            else:
                tmp_total -= int(S[i+1])
                ops += '-'
        if tmp_total == 7:
            ans = S[0]
            for i,op in enumerate(ops):
                ans += op + S[i+1]
            ans += '=7'
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
line = input()
List = [int(line[x]) for x in range(4)]
A,B,C,D = List
List_ans = []

for i in range(8):
  s = A
  List_mark = []
  for j in range(3):
    if ((i>>j) & 1)== 0:
      s = s - List[-(j+1)]
      x_j = '-'
    else:
      s = s + List[-(j+1)]
      x_j = '+'
    List_mark.append(x_j)
  if s ==7:
    List_ans.append(List_mark)

x = List_ans[0]
print(str(A)+x[-1]+str(B)+x[-2]+str(C)+x[-3]+str(D)+'=7')

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

Solution (Python):
abcd = input()
answers =[]

for i in range(2**3):
    a = int(abcd[0])
    b = int(abcd[1])
    c = int(abcd[2])
    d = int(abcd[3])
    plus_minus = [1,1,1]
    for j in range(3):
        if (i >> j)& 1:
            plus_minus[j] = -1
    ans = a + b*plus_minus[0] + c*plus_minus[1] + d*plus_minus[2]
    if ans == 7:
        pmw =[]
        for j in range(3):
            if plus_minus[j] == -1:
                pmw.append("-")
            else:
                pmw.append("+")
        print(str(a)+pmw[0]+str(b)+pmw[1]+str(c)+pmw[2]+str(d)+"=7")
        break

Solution (Python):

s=input()

for i in range(2**3):
    t=["-"]*3
    for j in range(3):
        if((i>>j)&1)==1:
            t[2-j]="+"
    fomula=s[0]+t[0]+s[1]+t[1]+s[2]+t[2]+s[3]
    if eval(fomula)==7:
        print(fomula+"=7")
        break

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

if a+b+c+d==7:
    print("{}+{}+{}+{}=7".format(a, b, c, d))
elif a+b+c-d==7:
    print("{}+{}+{}-{}=7".format(a, b, c, d))
elif a+b-c+d==7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
elif a-b+c+d==7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
elif a+b-c-d==7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
elif a-b-c+d==7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
elif a-b+c-d==7:
    print("{}-{}+{}-{}=7".format(a, b, c, d))
elif a-b-c-d==7:
    print("{}-{}-{}-{}=7".format(a, b, c, d))

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

a=s[0]
b=s[1]
c=s[2]
d=s[3]

ops = ['+','-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            equation = "".join([a,op1,b,op2,c,op3,d])
            solution = eval(equation)
            if solution ==7:
                answer = equation + "=7"



print(answer)

Solution (Python):
import itertools
kouho = list(itertools.product([0,1],repeat=3))

ABCD = str(input())

result = ""

for i in kouho:
    
    cnt=0
    sum =0
    result=""
    
    for j in i:
        
        if j==0:
            
            if cnt==0:
                sum   += int(ABCD[cnt]) +int(ABCD[cnt+1])
                result +=ABCD[cnt] + "+" + ABCD[cnt+1]
            else:
                sum += int(ABCD[cnt+1])
                result += "+" + ABCD[cnt+1]
        else:
            
            if cnt==0:
                sum   +=  int(ABCD[cnt]) - int(ABCD[cnt+1])
                result +=  ABCD[cnt] +  "-" + ABCD[cnt+1]
            else:
                sum = sum - int(ABCD[cnt+1])
                result +="-"+ ABCD[cnt+1]
            
        cnt+=1
        
    if sum==7:
        result += "=7"
        print(result)
        break

Solution (Python):
abcd=input()

for i in range(8):
    op=['-']*3
    for j in range(3):
        if (i>>j)&1:
            op[j]='+'
    if eval(abcd[0]+op[0]+abcd[1]+op[1]+abcd[2]+op[2]+abcd[3]) ==7:
        print(abcd[0]+op[0]+abcd[1]+op[1]+abcd[2]+op[2]+abcd[3]+'=7')
        break

Solution (Python):
ABCD = str(input())
n = len(ABCD)-1
ABCD_ = ''
output = ''
for i in range(2**n):
  ABCD_ = ABCD[0]
  for j in range(n):
    if ((i  >> j)&1) == 1:
      ABCD_ = ABCD_ + '+' + ABCD[j+1]
    else:
      ABCD_ = ABCD_ + '-' + ABCD[j+1]
  if eval(ABCD_) == 7:
    output = ABCD_ + '=7'
print(output)

Solution (Python):
S = input()

def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            exit()
        else:
            return False
    
    
    pos = i - len(S)

    
    s1 = s[:pos]+"+"+s[pos:]
    num1 = num+int(s[pos])
    
    s2 = s[:pos]+"-"+s[pos:]
    num2 = num-int(s[pos])
    
    if not(ticket_sum(i+1, s1, num1)):
        if not(ticket_sum(i+1, s2, num2)):
            return False

ticket_sum(1, S, int(S[0]))

Solution (Python):
import sys

S = input()

def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            sys.exit()
        else:
            return False
    
    
    pos = i - len(S)

    
    s1 = s[:pos]+"+"+s[pos:]
    num1 = num+int(s[pos])
    
    s2 = s[:pos]+"-"+s[pos:]
    num2 = num-int(s[pos])
    
    if ticket_sum(i+1, s1, num1):
        return
    elif ticket_sum(i+1, s2, num2):
        return
    
    return False

ticket_sum(1, S, int(S[0]))

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    A, B, C, D = [s for s in input().rstrip()]

    ops = ["+", "-"]
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                eq = "".join([A, op1, B, op2, C, op3, D])
                res = eval(eq)
                if res == 7:
                    ans = eq + "=7"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    A, B, C, D = [s for s in input().rstrip()]

    ops = ["+", "-"]
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                eq = "".join([A, op1, B, op2, C, op3, D])
                res = eval(eq)
                if res == 7:
                    ans = eq + "=" + str(res)
                    break

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
S = input()

def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            exit()
        else:
            return False
    
    
    pos = i - len(S)

    
    s1 = s[:pos]+"+"+s[pos:]
    num1 = num+int(s[pos])
    
    s2 = s[:pos]+"-"+s[pos:]
    num2 = num-int(s[pos])
    
    if ticket_sum(i+1, s1, num1):
        return
    elif ticket_sum(i+1, s2, num2):
        return
    
    return False

ticket_sum(1, S, int(S[0]))