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

Solution (Python):
s = input()
ls = [int(i) for i in s]
n = len(ls)
i = 1
ans = ls[0]

def dfs(i, s, ans):
    if i==n:
        
        return ans==7, s, ans
    else:
        
        p = i + s.count('+') + s.count('-')
        s_temp = s[:p]+'-'+s[p:]
        ans_temp = ans - ls[i]
        tf, s_temp, ans_temp = dfs(i+1, s_temp, ans_temp)
        if tf:
            return True, s_temp, ans_temp
        else:
            
            p = i + s.count('+') + s.count('-')
            s_temp = s[:p]+'+'+s[p:]
            ans_temp = ans + ls[i]
            tf, s_temp, ans_temp = dfs(i+1, s_temp, ans_temp)
            return tf, s_temp, ans_temp
            

tf, s, ans = dfs(1, s, ans)
print(s+'=7')

Solution (Python):
def dfs(array: list, index: int, calc: str, result: int):
    if index == len(array):
        if result == 7:
            print("{}=7".format(calc))
            exit(0)

    if index == 0:
        dfs(array, index + 1, array[index], int(array[index]))
    elif index < len(array):
        dfs(array, index + 1, calc + "-" + array[index], result - int(array[index]))
        dfs(array, index + 1, calc + "+" + array[index], result + int(array[index]))

array = list(input())
dfs(array, 0, "", 0)

Solution (Python):
def dfs(i: int, t: int, op: str):
  if i == 3:
    if t == 7:
      return op
    else:
      return ""

  return dfs(i + 1, t + s[i + 1], op + "+") + dfs(i + 1, t - s[i + 1], op + "-")

s = list(map(int, list(input())))
op = ""

op = dfs(0, s[0], op)
ans = str(s[0]) + op[0] + str(s[1]) + op[1] + str(s[2]) + op[2] + str(s[3]) + "=7"
print(ans)

Solution (Python):
a = input()

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

Solution (Python):
def test(array: list, index: int, calc: str, result: int):
    
    
    
    if index == len(array):
        if result == 7:
            print("{}=7".format(calc))
            exit(0)
    if index == 0:
        test(array,
             index + 1,
             array[index],
             int(array[index]))
    elif index <= len(array) - 1:
        test(array,
             index + 1,
             calc + "-" + array[index],
             result - int(array[index]))
        test(array,
             index + 1,
             calc + "+" + array[index],
             result + int(array[index]))


array = list(input())
test(array, 0, "", 0)

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

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

    formula = ""
    for num, op in zip(S, OP + [""]):
        formula += str(num) + op
    if eval(formula) == 7:
        print(formula + "=7")
        break

Solution (Python):
a=input()
for i in range(8):
    s=int(a[0])
    ans=[a[0]]
    for j in range(3):
        if (i>>j)&1:
            s+=int(a[j+1])
            ans+=["+"]+[a[j+1]]
        else:
            s-=int(a[j+1])
            ans+=["-"]+[a[j+1]]
    if s==7:
        print(*ans,sep="",end="")
        print("=7")
        break

Solution (Python):
from sys import stdin 

ABCD = stdin.readline().rstrip()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

def func1(ABCD,k):
    if k==len(ABCD)-1:
        return [[ABCD[k]],["-"+ABCD[k]]]
    prev_output = func1(ABCD,k+1)
    output = []
    if k==0:
        for ele in prev_output:
            temp = [ABCD[k]]
            temp.extend(ele)
            output.append(temp)
        return output

    for ele in prev_output:
        temp = [ABCD[k]]
        temp.extend(ele)
        output.append(temp)

        temp = ["-"+ABCD[k]]
        temp.extend(ele)
        output.append(temp)
    return output

def search_combi(combinations):
    for combi in combinations:
        tot_sum = 0
        for ele in combi:
            tot_sum+=int(ele)
        if tot_sum==7:
            return combi

combinations = func1(ABCD,0)

def make_answer(numbers):
    output_string=""
    for i,num in enumerate(numbers):
        num_int = int(num)
        if i==0:
            output_string += num
        else:
            if num_int<0:
                output_string += "-"+num[1]
            else:
                output_string += "+"+num
    return output_string+"=7"


print(make_answer(search_combi(combinations)))

Solution (Python):

n = input()
m = len(n)-1
for i in range(2 ** m):
    ops = []
    N = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
    for j in range(m):
        if (i >> j) & 1:
            ops.append("+")
        else:
            N[j + 1] *= -1
            ops.append("-")
    if sum(N) == 7:
        print(n[0]+ops[0]+n[1]+ops[1]+n[2]+ops[2]+n[3]+"=7")
        break

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

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

for bit in range(1 << (n-1)):
    f = s[0]

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

    ans = eval(f)
    if ans == 7:
        res = f + "=7"
        break

print(res)

Solution (Python):
n = [x for x in input()]
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    fomula = list(sum(zip(n,op),()))
    fomula.append(n[-1]) 

    if eval(''.join(fomula))== 7:
    	print(''.join(fomula) +'=7')
    	break

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

s = ''
f = lambda i, op: abcdStr[0] + ("+" if i < 2 else "-") + abcdStr[1] + ("+" if i % 2 == 0 else "-") + abcdStr[2] + op + abcdStr[3] + "=7"
for i in range(4):
    n = abcd[0]
    n = n + abcd[1] if i < 2 else n - abcd[1]
    n = n + abcd[2] if i % 2 == 0 else n - abcd[2]
    if n + abcd[3] == 7:
        s = f(i, "+")
        break
    elif n - abcd[3] == 7:
        s = f(i, "-")
        break
print(s)

Solution (Python):
s = input()
for i in range(8):
    op = list("-".join(list(s)))
    for j in range(3):
        if i & (1 << j):
            op[j + j + 1] = '+'
    op = "".join(op)
    if eval(op) == 7:
        print(op + "=7")
        break

Solution (Python):
s = input()
ans = []
def pm(i,h,k):
  if i == 3:
    if k == 7:
      ans.append(s[0]+h[0]+s[1]+h[1]+s[2]+h[2]+s[3]+'='+'7')

      
  else:
    pm(i+1,h + ['+'],k+int(s[i+1]))
    pm(i+1,h + ['-'],k-int(s[i+1]))
pm(0,[],int(s[0]))
print(ans[0])

Solution (Python):
from itertools import product

abcd = input()

for pattern in product(["-", "+"],repeat=3):
    pattern = list(pattern)
    res = int(abcd[0])
    f = [abcd[0]]
    for v, op in zip(abcd[1:], pattern):
        f.append(op)
        f.append(v)
        if op == "+":
            res += int(v)
        elif op == "-":
            res -= int(v)
    if res == 7:
        f.append("=7")
        print("".join(f))
        break

Solution (Python):


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

def calc():
    for op1 in op:
        for op2 in op:
            for op3 in op:
                res=a+op1+b+op2+c+op3+d
                if eval(res)==7:
                    return res

print(calc()+'=7')

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

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

Solution (Python):
*A, = list(input())
s = ['+', '-']
for i in range(2**3):
    formula = A[0]
    for j in range(3):
        if i >> j & 1:
            formula += s[0]
        else:
            formula += s[1]
        formula += A[j+1]
    if eval(formula) == 7:
        print(formula+'=7')
        exit()

Solution (Python):
s=input()

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

Solution (Python):
n = list(input())
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
tmp = 0
ans = ''
for i in range(8):
    j = i

    if bin(j & 1) == bin(1):
        tmp = a + b
        ans = str(a) + '+' + str(b)
    else:
        tmp = a - b
        ans = str(a) + '-' + str(b)
    if bin(j>>1 & 1) == bin(1):
        tmp += c
        ans += '+' + str(c)
    else:
        tmp -= c
        ans += '-' + str(c)
    if bin(j>>2 & 1) == bin(1):
        tmp += d
        ans += '+' + str(d)
    else:
        tmp -= d
        ans += '-' + str(d)
    

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    Num = list(map(int, list(input().strip("\n"))))
    for i in range(8): 
        ans = Num[0]
        d = i
        toPrint = str(Num[0])
        for k in range(3):
            if d % 2 == 0: 
                ans += Num[k + 1]
                toPrint += "+" + str(Num[k + 1])
            else: 
                ans -= Num[k + 1]
                toPrint += "-" + str(Num[k + 1])
            d //= 2
        if ans == 7:
            toPrint += "=7"
            print(toPrint)
            break


    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
a = list(input())
a = [int(i) for i in a]
for bit in range(1<<3):
    ans = a[0]
    ans1 = []
    for i in  range(3):
        mask = 1<<i
        if mask&bit:
            ans = (ans+a[i+1])
            ans1.append('+')
        else:
            ans = (ans-a[i+1])
            ans1.append('-')
    
    if ans==7:
        ans2 = ans1
ans3 = []
for i in range(3):
    ans3.append(str(a[i]))
    ans3.append(ans2[i])
ans3.append(str(a[3]))
ans3.append('=7')
ans4 =''.join(ans3)
print(ans4)

Solution (Python):
x = input()
p = ['+','-']
def cal(a,b,c,x):
    res = int(x[0])
    if a:res-=int(x[1])
    else:res+=int(x[1])
    if b:res-=int(x[2])
    else:res+=int(x[2])
    if c:res-=int(x[3])
    else:res+=int(x[3])
    if res == 7:
        return True
    else:return False
    
        
for i in range(2):
    for j in range(2):
        for k in range(2):
            if cal(i,j,k,x):
                print(x[0]+p[i]+x[1]+p[j]+x[2]+p[k]+x[3]+'=7')
                exit(0)

Solution (Python):



ABCD = input()
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]


pattern_list = []
for i in range(2**3):
    p = ['-']*3
    for j in range(3):
        if (i>>j)&1:
            p[j] = '+'
    pattern_list.append(p)


for p in pattern_list:
    calc_str = A + p[0] + B + p[1] + C + p[2] + D
    if eval(calc_str)==7:
        calc_str += '=7'
        print(calc_str)
        break

Solution (Python):
S = list(input())
opt = ['-', '+']
for i in range(8):
    now = S[0]
    for j in range(3):
        if i >> j & 1:
            now += opt[1]
        else:
            now += opt[0]
        now += S[j + 1]
    if eval(now) == 7:
        print(now + "=7")
        exit()

Solution (Python):
def kipp(i,f):
    if i == 3:
        if eval(f) == 7:
            print(f+"=7")
            exit()
    else:
        kipp(i+1,f+"+"+s[i+1])
        kipp(i+1,f+"-"+s[i+1])

s = input()
kipp(0,s[0])

Solution (Python):
s=input()

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

Solution (Python):
string = input()
a, b, c, d = [int(string[i]) for i in range(4)]
op_dict = {"1": "+", "0": "-"}

for i in range(8):
    ops = bin(i)[2:].zfill(3)
    res = a
    if op_dict[ops[0]] == "+":
        res += b
    else:
        res -= b
    if op_dict[ops[1]] == "+":
        res += c
    else:
        res -= c
    if op_dict[ops[2]] == "+":
        res += d
    else:
        res -= d

    if res == 7:
        print("".join([str(a), op_dict[ops[0]], str(b), op_dict[ops[1]], str(c), op_dict[ops[2]], str(d), "=7"]))
        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(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c+d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Solution (Python):
n = input()
op = [bin(i)[2:].zfill(3) for i in range(8)]
for i in range(8):
    cnt = int(n[0])
    ans = [n[0]]
    for j in range(3):
        if op[i][j] == "0":
            cnt += int(n[j+1])
            ans.append("+")
        else:
            cnt -= int(n[j+1])
            ans.append("-")
        ans.append(n[j+1])
    if cnt == 7:
        ans += ["=", "7"]
        print("".join(ans))
        exit()

Solution (Python):
s=input()
N=list(map(int,s))
for p in range(1<<3):
    t = N[0]
    ans = str(t)
    for i in range(1,4):
        if p&1:
            t+=N[i]
            ans+='+'+str(N[i])
        else:
            t-=N[i]
            ans+='-'+str(N[i])
        p>>=1
    if t==7:
        print(ans+'=7')
        exit()

Solution (Python):
S = input()
k = []
for i in range(4):
    k.append(S[i])
flag = 0
a = k[0]
b = k[1]
c = k[2]
d = k[3]
A = int(a)
B = int(b)
C = int(c)
D = int(d)
if A+B+C+D == 7:
    print(a+"+"+b+"+"+c+"+"+d+"="+"7")
    flag += 1
elif A+B+C-D == 7:
    if flag == 0:
        print(a+"+"+b+"+"+c+"-"+d+"="+"7")
        flag += 1
elif A+B-C+D == 7:
    if flag == 0:
        print(a+"+"+b+"-"+c+"+"+d+"="+"7")
        flag += 1
elif A+B-C-D == 7:
    if flag == 0:
        print(a+"+"+b+"-"+c+"-"+d+"="+"7")
        flag += 1
elif A-B-C+D == 7:
    if flag == 0:
        print(a+"-"+b+"-"+c+"+"+d+"="+"7")
        flag += 1
elif A-B+C-D == 7:
    if flag == 0:
        print(a+"-"+b+"+"+c+"-"+d+"="+"7")
        flag += 1
elif A-B+C+D == 7:
    if flag == 0:
        print(a+"-"+b+"+"+c+"+"+d+"="+"7")
        flag += 1
elif A-B-C-D == 7:
    if flag == 0:
        print(a+"-"+b+"-"+c+"-"+d+"="+"7")
        flag += 1

Solution (Python):
from itertools import product
A, B, C, D = list(input())
l = len(A)

for ops in product(["+", "-"], repeat=3):
  eq = A + ops[0] + B + ops[1] + C + ops[2] + D
  x = eval(eq)
  if x == 7:
    break
print(eq + "=7")

Solution (Python):
from itertools import product


def main():
    op = ['+', '-']
    numbers = list(map(int, list(input())))
    for now_op in product(op, repeat=3):
        now = numbers[0]
        for i in range(3):
            if now_op[i] == '+':
                now += numbers[i + 1]
            else:
                now -= numbers[i + 1]
        if now == 7:
            answer = ""
            for i in range(3):
                answer += str(numbers[i]) + now_op[i]
            answer += str(numbers[3]) + "=7"
            print(answer)
            break


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a = [int(i) for i in STR()]

op = ['+', '-']
ops = ['', '', '']
for ops[0] in op:
    for ops[1] in op:
        for ops[2] in op:
            tmp = a[0]
            for i in range(3):
                if ops[i] == '+':
                    tmp += a[i + 1]
                else:
                    tmp -= a[i + 1]
            if tmp == 7:
                ans = str(a[0])
                for i in range(3):
                    ans += ops[i] + str(a[i + 1])
                ans += '=7'
                print(ans)
                exit()

Solution (Python):
def main():
    S = input()
    for bit in range(1 << 3):
        op = []
        for i in range(3):
            if bit & (1 << i):
                op.append("+")
            else:
                op.append("-")
        ans = int(S[0])
        for opc, s in zip(op, S[1:]):
            if opc == "+":
                ans += int(s)
            else:
                ans -= int(s)
        if ans == 7:
            for s, opc in zip(S, op):
                print(s+opc, end="")
            print(S[-1]+"=7")
            return


if __name__ == '__main__':
    main()

Solution (Python):
A,B,C,D = input()
for a in '+-':
    for b in '+-':
        for c in '+-':
            f = "{0}{1}{2}{3}{4}{5}{6}".format(A,a,B,b,C,c,D)
            if eval(f)==7:
                print(f + '=7')
                exit()

Solution (Python):
a = input()

for i in range(8):
    l = []
    for j in range(3):
        if i & (1 << j):
            l.append('+')
        else:
            l.append('-')
    s = ''
    l.append(' ')
    for p, q in zip(list(a), l):
        s += p + q
    if eval(s) == 7:
        print(s[:-1] + '=7')
        exit(0)

Solution (Python):
s = input()

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

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

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

def calc(x, y, sym):
    if sym == 0:
        return x + y
    else:
        return x - y

def symbol(sym):
    if sym == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            tmp = calc(a[0], a[1], i)
            tmp = calc(tmp, a[2], j)
            tmp = calc(tmp, a[3], k)
            if tmp == 7:
                b = list(map(symbol, [i, j, k]))
                print("{}{}{}{}{}{}{}=7".format(a[0], b[0], a[1], b[1], a[2], b[2], a[3]))
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
a = list(input())
op = [bin(i)[2:].zfill(3) for i in range(8)]
for i in range(8):
    ans = int(a[0])
    ans_ar = [a[0]]
    for j in range(3):
        if op[i][j] == "0":
            ans += int(a[j+1])
            ans_ar.append("+")
        else:
            ans -= int(a[j+1])
            ans_ar.append("-")
        ans_ar.append(a[j+1])
    if ans == 7:
        ans_ar = ans_ar + ["=", "7"]
        print("".join(ans_ar))
        exit()

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

for i in range(1<<n):
    sum=0
    st=''
    for j in range(n):

        
        
        if i & (1 <<j):st+= '+' + a[j] 
        else:  st+= '-' + a[j]

    
    if eval(st[1:]) == 7:break

print(st[1:] + '=7')

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

for i in range(1<<n):
    sum=0
    st=''
    for j in range(n):

        if i & (1 <<j):sum +=int(a[j]); st+= '+' + a[j] 
        else: sum -=int(a[j]); st+= '-' + a[j]

    if sum==7:break

print(st[1:] + '=7')

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

Solution (Python):

if __name__ == '__main__':

	s = input()
	s_len = len(s) -1
	A = ""
	for i in range(2**s_len):
		A = s[0]
		for j in range(s_len):
			if i & (1 << j):
				A += "+" + s[j+1]
			else:
				A += "-" + s[j+1]
		if eval(A) == 7:
			break

	print(A + "=7")

Solution (Python):
l=input()
num=[int(l[i]) for i in range(4)]
pm=['+','-']
for i in pm:
  a,b,c,d=num[0],num[1],num[2],num[3]
  for j in pm:
    for k in pm:
      if i=='-':
        b=b*(-1)
      if j=='-':
        c=c*(-1)
      if k=='-':
        d=d*(-1)
      if a+b+c+d==7:
        print(str(a)+i+str(abs(b))+j+str(abs(c))+k+str(abs(d))+'='+'7')
        exit()
      a,b,c,d=num[0],num[1],num[2],num[3]

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

for i in range(8):
    sum=s[0]
    marks=[]
    for k in range(3):
        if 1&(i>>k):
            sum+=s[k+1]
            marks.append('+')
        else:
            sum-=s[k+1]
            marks.append('-')
    if sum==7:
        for l in range(3):
            print('{}{}'.format(s[l],marks[l]),end='')
        print('{}=7'.format(s[3]))
        exit()

Solution (Python):

s = input()

n = len(s) - 1

for i in range(n**2):
    tmp = ""
    for j in range(n+1):
        tmp += s[j]
        
        if (i >> j)&1 :
            tmp += '+'
        else:
            tmp += '-'
            
    tmp = tmp[:-1]
    
    if eval(tmp) == 7:
        print(tmp+'=7')
        break

Solution (Python):
s = list(input())
import sys
def bitlist(n, a, b):
  res = []
  for i in range(2**n):
    pattern = []
    for j in range(n):
      if (i >> j) & 1:
        pattern.insert(0, a)
      else:
        pattern.insert(0, b)
    res.append(pattern)
  return res

n = len(s)
lst = bitlist(n-1, "+", "-")
for i in range(2**(n-1)):
  calc = s[0]
  for j in range(n-1):
    calc += lst[i][j] + s[j+1]
  if eval(calc) == 7:
    calc += "=7"
    print(calc)
    sys.exit()

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

    for i in range(1<<n-1):
        t = ''
        for j in range(n-1):
            t += S[j]
            if i & (1<<j):
                t += '+'
            else:
                t += '-'
        t += S[n-1]
        if eval(t) == 7:
            print(t+'=7')
            break


if __name__ == '__main__':
    main()

Solution (Python):
s = list(input())
import sys
def bitlist(n, a, b):
  res = []
  for i in range(2**n):
    pattern = []
    for j in range(n):
      if (i >> j) & 1:
        pattern.insert(0, a)
      else:
        pattern.insert(0, b)
    res.append(pattern)
  return res

n = len(s)
lst = bitlist(n-1, "+", "-")
for i in range(2**n):
  calc = int(s[0])
  for j in range(n-1):
    if lst[i][j] == "+":
      calc += int(s[j+1])
    else:
      calc -= int(s[j+1])
  if calc == 7:
    res = s[0]
    for k in range(n-1):
      res += lst[i][k] + s[k+1]
    res += "=7"
    print(res)
    sys.exit()

Solution (Python):
ABCD = input()
res = 0
for i in range(1 << 3):
    l = []
    for j in range(3):
        if i >> j & 1 == 1:
            l.append(ABCD[j])
            l.append("+")
        else:
            l.append(ABCD[j])
            l.append("-")
    l.append(ABCD[-1])
    l = ''.join(l)
    res = eval(l)
    if res == 7:
        print(l + "=7")
        exit()

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

v = [1, -1]
ans = 0
for j in v:
    for k in v:
        for l in v:
            if a + j*b + k*c + l*d == 7:
                if j == 1:
                    lb = "+"
                else:
                    lb = "-"
                if k == 1:
                    lk = "+"
                else:
                    lk = "-"
                if l == 1:
                    ll = "+"
                else:
                    ll = "-"
                print(str(a)+lb+str(b)+lk+str(c)+ll+str(d)+"=7")
                exit()

Solution (Python):
s = input()

num_cases = 2 ** 3
patterns = [0] * num_cases
for i in range(num_cases):
    patterns[i] = [0] * 3
    for j in range(3):
        if ((i>>j) & 1):
            patterns[i][j] = '+'
        else:
            patterns[i][j] = '-'
for pattern in patterns:
    res = int(s[0])
    for i in range(3):
        op = pattern[i]
        if op == '+':
            res += int(s[i+1])
        else:
            res -= int(s[i+1])
    if res == 7:
        ans_p = pattern
        break

ans = s[0] + ans_p[0] + s[1] + ans_p[1] + s[2] + ans_p[2] + s[3] + '=7'

print(ans)

Solution (Python):
A = input()

num = [int(A[0])]
hugou = ['']*3
ans = [0]*4
ans[0] = int(A[0])

for i in range(1,len(A)):
    num.append(A[i])

for i in range(2**3):
    tmp = format(i,'03b')
    for j in range(len(tmp)):
        if tmp[j] == "0":
            ans[j+1] = -int(num[j+1])
            hugou[j] = '-'
        else:
            ans[j+1] = int(num[j+1])
            hugou[j] = '+'
    if sum(ans) == 7:
        print(str(ans[0]) + hugou[0] \
              + str(abs(ans[1])) + hugou[1] \
              + str(abs(ans[2])) + hugou[2] \
              + str(abs(ans[3]))+"=7")
        exit()

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

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

def dfs(i,f,ans):
  
  if i == len(s)-1:
    
    if ans == 7:
      print(f + '=7')
      exit()
    
  else:
    dfs(i+1, f + '+' + s[i+1], ans+int(s[i+1]))
    dfs(i+1, f + '-' + s[i+1], ans-int(s[i+1]))
      
dfs(0,s[0], int(s[0]))

Solution (Python):
x = list(input())
for i in range(2**3):
  a = []
  for j in range(3):
    if (i >> j) & 1:
      a.append('+')
    else:
      a.append('-')
  b = x[0]+a[0]+x[1]+a[1]+x[2]+a[2]+x[3]
  if eval(b) == 7:
    print(b+'=7')
    break

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



for i in range(2**3):
    ls=["+","+","+"]
    for j in range(3):
        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):
k=input()
a=int(k[0])
b=int(k[1])
c=int(k[2])
d=int(k[3])
if (a+b+c+d)==7:print(k[0]+'+'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a-b+c+d)==7:print(k[0]+'-'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c+d)==7:print(k[0]+'+'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b+c-d)==7:print(k[0]+'+'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c+d)==7:print(k[0]+'-'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c-d)==7:print(k[0]+'+'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')
elif (a-b+c-d)==7:print(k[0]+'-'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c-d)==7:print(k[0]+'-'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')

Solution (Python):
S = input()

for i in range(8):
    ans = int(S[0])
    ops = []
    for j in range(3):
        if i & (1 << j):
            ans += int(S[j + 1])
            ops.append("+")
        else:
            ans -= int(S[j + 1])
            ops.append("-")

    if ans == 7:
        print(S[0], ops[0], S[1], ops[1], S[2], ops[2], S[3], "=7", sep="")
        break

Solution (Python):

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

Solution (Python):
s = input()
A, B, C, D = s[0], s[1], s[2], s[3]
ans = 7
siki = [[] for _ in range(2**3)]
for i in range(2 ** 3):
    for j in range(3):
        if (i >> j) & 1:
            siki[i].append("+")
        else:
            siki[i].append("-")

for o1, o2, o3 in siki:
    temp = A + o1 + B + o2 + C + o3 + D
    if eval(temp) == ans:
        print(temp + "=7")
        break

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

Solution (Python):
import sys

s=list(input())

def f(i,tmp,func):
  if i==4:
    if tmp == 7:
      print(func+"=7")
      sys.exit()
  else:
    f(i+1,tmp+int(s[i]),func+"+"+s[i])
    f(i+1,tmp-int(s[i]),func+"-"+s[i])
    
f(1,int(s[0]),s[0])

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

for i in range(2**3):
    l = ['+','+','+']
    for j in range(3):
        if (i>>j) & 1 == 1:
            l[j] = '-'
    if eval(a+l[0]+b+l[1]+c+l[2]+d) == 7:
        print(a+l[0]+b+l[1]+c+l[2]+d+'=7')
        sys.exit()

Solution (Python):
n = input()

a = len(n)-1
for i in range(2**a):
  l = ["-"]*a
  for j in range(a):
    if ((i>>j)&1):
      l[a-1-j] = "+"

  f = ""
  for aa,bb in zip(n,l+[""]):
    f  += (aa+bb)
  if eval(f)==7:
    print(f+'=7')
    break

Solution (Python):
s = 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 = input()
for i in range(2**3):
  a = int(s[0])
  ans = s[0]
  for j in range(3):
    a += ((-1)**((i >> j & 1) == 1))*int(s[j+1])
    ans += "+"*((i >> j & 1) == 0)
    ans += "-"*((i >> j & 1) == 1)
    ans += s[j+1]
  if a == 7:
    print(ans+"=7")
    quit()

Solution (Python):
abcd = list(map(int, input()))
op = {'0':'+', '1':'-'}
for i in range(8):
    result = abcd[0]
    code = str(abcd[0])
    pointer = 1
    for k in bin(i)[2:].zfill(3):
        if op[k] == '+':
            code += '+'
            result += abcd[pointer]
        else:
            code += '-'
            result -= abcd[pointer]
        code += str(abcd[pointer])
        pointer += 1
    if result == 7:
        code += "=7"
        break
print(code)