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

Solution (Python):
a,b,c,d=map(int,input())
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):
def func(ABCD, n, acc, output):
    if n == 0:
        if int(ABCD) + acc == 7:
            print(ABCD + output + '=7')
            exit()
    else:
        func(ABCD[:-1], n-1, acc + int(ABCD[-1]), '+' + ABCD[-1] + output)
        func(ABCD[:-1], n-1, acc - int(ABCD[-1]), '-' + ABCD[-1] + output)
S = input()
func(S, len(S)-1, 0, '')

Solution (Python):
s = list(input())
ans = 0
for i in range(2**(3)):
    f = (s[0])
    for j in range(3):
        if i&(1<<j):
            f = f+"+"
        else:
            f = f+"-"
        f = f+s[j+1]
    if eval(f)==7:
        print(f+"=7")
        exit()

Solution (Python):
s=list(input())
n=len(s)
insert=0
ans=0
for i in range(2**(3)):
    f=(s[0])
    for j in range(3):
        if i&(1<<j):
            f=f+"+"
        else:
            f=f+"-"
        f=f+s[j+1]
      
   
    if eval(f)==7:
        print(f+"=7")
        exit()

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = list(input().rstrip())
    N = len(S)

    for bit in range(1<<N-1):
        total = int(S[0])
        res = S[0]
        for i in range(N-1):
            if bit & 1<<i:
                total += int(S[i+1])
                res += '+'
                res += S[i+1]
            else:
                total -= int(S[i+1])
                res += '-'
                res += S[i+1]
        if total == 7:
            res += '=7'
            print(res)
            return 0


if __name__ == '__main__':
    main()

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

for i in range(7):  
  if i==0 and a+b+c+d==7:
    print('%d+%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==1 and a+b+c-d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==2 and a+b-c+d==7:
    print('%d+%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==3 and a+b-c-d==7:
    print('%d+%d-%d-%d=7' %(a,b,c,d))
    exit()
  elif i==4 and a-b+c+d==7:
    print('%d-%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==5 and a-b+c-d==7:
    print('%d-%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==6 and a-b-c+d==7:
    print('%d-%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==7 and a-b-c-d==7:
    print('%d-%d-%d-%d=7' %(a,b,c,d))
    exit()

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

for i in range(8) :
    ret = ABCD[0]
    for j in range(3) :
        if (i >> j) & 1 :
            ret += ABCD[j+1]
        else :
            ret -= ABCD[j+1]
    
    if ret == 7 :
        op1 = '+' if (i >> 0) & 1 else '-'
        op2 = '+' if (i >> 1) & 1 else '-'
        op3 = '+' if (i >> 2) & 1 else '-'
        print('{}{}{}{}{}{}{}=7'.format(ABCD[0], op1, ABCD[1], op2, ABCD[2], op3, ABCD[3]))
        break

Solution (Python):
def dfs(i, now,  count):
    if count == len(s):
        if i == 7:
            print(str(s[0]),end="")
            for j in range(len(s)-1):
                print(now[j+1] + str(s[j+1]), end="")
            print('=7')
            exit()
    else:
        dfs(i + s[count], now + '+', count + 1)
        dfs(i - s[count], now + '-', count + 1)


s = list(map(int, input().strip()))

dfs(0, '', 0)

Solution (Python):
def resolve():
    import copy
    s = list(input())
    t = list(map(int, s))
    for i in range(8):
        tmp = copy.deepcopy(s)
        d = 0
        ans = t[0]
        for j in range(3):
            if (i // 2**j)%2 == 1:
                tmp.insert(j+d+1, '+')
                ans += t[j+1]
            else:
                tmp.insert(j+d+1, '-')
                ans -= t[j+1]
            d += 1
        if ans == 7:
            print(''.join(tmp)+'=7')
            return
resolve()

Solution (Python):

"""
Created on Thu Sep  5 15:21:54 2019

@author: Owner
"""

S = input()

A = [int(S[0]), int(S[1]), int(S[2]), int(S[3])]

flg = [True, True, True]

def dfs(n, flg, goal):
    if goal == True:
        return True
    
    if n == 3:
        ops = ["+", "+", "+"]
        tot = A[0]
        for i in range(len(flg)):
            if flg[i]:
                tot += A[i+1]
            else:
                tot -= A[i+1]
                ops[i] = "-" 
        
                
        if tot == 7:
            print(str(A[0])+ops[0]+str(A[1])+ops[1]+str(A[2])+ops[2]+str(A[3])+"=7")
            return True
        else:
            return False
    
    flg1 = flg.copy()
    flg1[n] = True
    flg2 = flg.copy()
    flg2[n] = False
    
    goal = dfs(n+1, flg1, goal) or dfs(n+1, flg2, goal)
    
    return goal
    
dfs(0, flg, False)

Solution (Python):

def calc(a, b, plus_minus):
  if plus_minus == 0:
    return a + b
  elif plus_minus == 1:
    return a - b

import itertools as it
list_prm = it.product([0, 1], repeat=3)
list_prm = list(list_prm)

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

def calc4(list_abcd, list_pm):
  ans = calc(list_abcd[0], list_abcd[1], list_pm[0])
  ans = calc(ans, list_abcd[2], list_pm[1])
  ans = calc(ans, list_abcd[3], list_pm[2])
  return ans

def serch_7(list_abcd, list_prm):
  for list_pm in list_prm:
    if calc4(list_abcd, list_pm) == 7:
      return list_pm

    
def convert(num):
  if num == 0:
    return "+"
  else:
    return "-"

sol = serch_7(list_abcd, list_prm)

s = str(list_abcd[0])
s += convert(sol[0])
s += str(list_abcd[1])
s += convert(sol[1])
s += str(list_abcd[2])
s += convert(sol[2])
s += str(list_abcd[3])
s += "=7"

print(s)

Solution (Python):
def main():
    abcd = list(input())
    flag = False
    for op1 in ['+', '-']:
        for op2 in ['+', '-']:
            for op3 in ['+', '-']:
                ans = abcd[0]+op1+abcd[1]+op2+abcd[2]+op3+abcd[3]
                if eval(ans) == 7:
                    flag = True
                    print(ans+'=7')
                    break
            if flag:
                break
        if flag:
            break

if __name__ == '__main__':
    main()

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

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

n = len(lis) - 1
for i in range(2**n):
    a = ["-", "-", "-"]
    for j in range(n):
        if (i >> j & 1):
            a[j] = "+"
    ans = "".join(["{}{}".format(k, kk) for (k, kk) in zip(lis, a+[''])])
    if (eval(ans)) == 7:
        print(ans + "=7")
        break

Solution (Python):
n=input()

n1=int(n[0])
n2=int(n[1])
n3=int(n[2])
n4=int(n[3])

if n1+n2+n3+n4==7:
    print ("{}+{}+{}+{}=7".format(n1,n2,n3,n4))
    exit()
elif n1+n2+n3-n4==7:
    print ("{}+{}+{}-{}=7".format(n1,n2,n3,n4))
    exit()
elif n1+n2-n3+n4==7:
    print ("{}+{}-{}+{}=7".format(n1,n2,n3,n4))
    exit()    
elif n1+n2-n3-n4==7:
    print ("{}+{}-{}-{}=7".format(n1,n2,n3,n4))
    exit() 
elif n1-n2-n3-n4==7:
    print ("{}-{}-{}-{}=7".format(n1,n2,n3,n4))
    exit()
elif n1-n2-n3+n4==7:
    print ("{}-{}-{}+{}=7".format(n1,n2,n3,n4))
    exit()
elif n1-n2+n3-n4==7:
    print ("{}-{}+{}-{}=7".format(n1,n2,n3,n4))
    exit()
elif n1-n2+n3+n4==7:
    print ("{}-{}+{}+{}=7".format(n1,n2,n3,n4))
    exit()

Solution (Python):
s = []
for c in input():
    s.append(int(c))


def dfs(list, ops, index, sum):
    if len(list) <= index:
        if sum == 7:
            return "{}{}{}{}{}{}{}=7".format(list[0], ops[0], list[1], ops[1], list[2], ops[2], list[3])
        else:
            return None
    candidate = dfs(list, ops + ['+'], index + 1, sum + list[index])
    if candidate:
        return candidate
    candidate = dfs(list, ops + ['-'], index + 1, sum - list[index])
    if candidate:
        return candidate
    return None


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

Solution (Python):
a, b, c, d = map(int, input())
if a + b + c + d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a - b + c + d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b - c + d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c - d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b - c - d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")

Solution (Python):


s = input()

for bit in range(1<<(len(s)-1)):
    sum_ = int(s[0])
    ops_str = []
    for i in range(len(s)-1):
        if (bit & (1<<i)):
            sum_ += int(s[i+1])
            ops_str.append("+")
        else:
            sum_ -= int(s[i+1])
            ops_str.append("-")
    if sum_ == 7:
        ans_str = s[0]
        for k in range(len(ops_str)):
            ans_str += (ops_str[k] + s[k+1])
        print(ans_str+"=7")
        break

Solution (Python):
Input = list(input())
for i in range(4):
    Input[i] = int(Input[i])
Kouho = [[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
flag = 0
for i in range(8):
    tmp = Input[0]
    if Kouho[i][0] == 0:
        tmp -= Input[1]
    else:
        tmp += Input[1]
    if Kouho[i][1] == 0:
        tmp -= Input[2]
    else:
        tmp += Input[2]
    if Kouho[i][2] == 0:
        tmp -= Input[3]
    else:
        tmp += Input[3]
    if tmp == 7:
        for j in range(4):
            Input[j] = str(Input[j])
        for j in range(3):
            if Kouho[i][j] == 0:
                Kouho[i][j] = '-'
            else:
                Kouho[i][j] ='+'
        Input.insert(1,Kouho[i][0])
        Input.insert(3,Kouho[i][1])
        Input.insert(5,Kouho[i][2])
        Input.insert(7,'=7')
        ans = ''.join(Input)
        print(ans)

        break

Solution (Python):




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



puramai = []
for i in range(8):
    bs = format(i,'03b')
    for j in range(3):

        if bs[j] == "0":
            ans = ans - int(s[j+1])
            puramai.append("-")
        if bs[j] == "1":
            ans = ans + int(s[j+1])
            puramai.append("+")

    if ans == 7:
        print(s[0] + puramai[0] + s[1] + puramai[1] + s[2] + puramai[2] + s[3] + "=7")
        break
    else:
        ans = a
        puramai = []
else:
    print("NO")

Solution (Python):
a=input()
flag=False
for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            cnt=int(a[0])
            if i=="+":
                cnt+=int(a[1])
            else:
                cnt-=int(a[1])
            if j=="+":
                cnt+=int(a[2])
            else:
                cnt-=int(a[2])
            if k=="+":
                cnt+=int(a[3])
            else:
                cnt-=int(a[3])
            if cnt==7:
                print(a[0]+i+a[1]+j+a[2]+k+a[3]+"=7")
                flag=True
                break
        if flag==True:
            break
    if flag==True:
        break

Solution (Python):
abcd = input()

for i in range(2 ** 3):
    check = int(abcd[0])
    op_list = []
    for j in range(3):
        if i >> j & 1:
            check += int(abcd[j+1])
            op_list.append('+')
        else:
            check -= int(abcd[j+1])
            op_list.append('-')
    if check == 7:
        m = abcd[0] + op_list[0] + abcd[1] + op_list[1] + abcd[2] + op_list[2] + abcd[3] + '=7'
        print(m)
        break

Solution (Python):
import sys
S = input()
length = 4

for i in range(1 << (length - 1)):
    s = S[0]
    for j in range(length - 1):
        if i & (1 << j):
            s += "+"
        else:
            s += "-"
        s += S[j + 1]
    if eval(s) == 7:
        print(s + "=7")
        sys.exit(0)

Solution (Python):
s=input()

for bit in range(1 << 3):
    f=int(s[0])
    for i in range(0,3):
        if bit & (1 << i):
            f=f+int(s[i+1])
        else:
            f=f-int(s[i+1])
    if f==7:
        break

F=s[0]
for i in range(0,3):
    if bit & (1 << i):
        F=F+"+"+s[i+1]
    else:
        F=F+"-"+s[i+1]

print(F+"=7")

Solution (Python):
import itertools as it

s = input()
l = [i for i in s]
ans = 7
op = 3

for (a, b, c) in it.product([0,1],repeat=op):
  eq = l[0]
  w = int(l[0])
  for i,x in enumerate((a, b, c)):
    if x == 0:
      eq += "+" + l[i+1]
      w += int(l[i+1])
    else:
      eq += "-" + l[i+1]
      w -= int(l[i+1])
  if w == ans:
    print(eq+"=7")
    break

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

def f(i,cnt):
	if i == 3:
		if cnt == 7:
			return True
		else:
			return False

	if f(i+1, cnt+K[i+1]):
		ans.append("+")
		return True
	if f(i+1, cnt-K[i+1]):
		ans.append("-")
		return True
	
	

ans = []

f(0,K[0])

ans = ans[::-1]

for i in range(4):
	if i == 3:
		print(str(K[-1])+"=7")

	else:
		print(K[i], end="")
		print(ans[i], end="")

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

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

for l in range(2 ** (len(s)-1)):
    s3 = list(s)
    h = 0
    for i in range(len(s)-1):
        if (l >> i) & 1:
            s3.insert(i+h+1,'+')
            h += 1
        else:
            s3.insert(i+h+1,'-')
            h += 1
    e = ''.join(s3)
    if eval(e) == 7:
        print(str(e)+'=7')
        break

Solution (Python):
l=tuple(input())
for i in range(8):
    c=1
    s=list(l)
    for j in range(3):
        s.insert(j+c,"+-"[(i>>j)&1::2])
        c+=1
    a="".join(s)
    if eval(a)==7:
        print(a+"=7")
        exit()

Solution (Python):
a, b, c, d = map(int, list(input()))
if a+b+c+d == 7: print(a,"+", b, "+", c, "+", d, "=7", sep="")
elif a+b+c-d == 7: print(a,"+", b, "+", c, "-", d, "=7", sep="")
elif a+b-c+d == 7: print(a,"+", b, "-", c, "+", d, "=7", sep="")
elif a-b+c+d == 7: print(a,"-", b, "+", c, "+", d, "=7", sep="")
elif a+b-c-d == 7: print(a,"+", b, "-", c, "-", d, "=7", sep="")
elif a-b-c+d == 7: print(a,"-", b, "-", c, "+", d, "=7", sep="")
elif a-b+c-d == 7: print(a,"-", b, "+", c, "-", d, "=7", sep="")
else: print(a,"-", b, "-", c, "-", d, "=7", sep="")

Solution (Python):
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d = input()
li = ["+", "-"]
def calc(a, b, c, d):
    for i in range(2):
        if i == 0:
            e = a + b
        else:
            e = a - b
        for j in range(2):
            if j == 0:
                f = e + c
            else:
                f = e - c
            for k in range(2):
                if k == 0:
                    g = f + d
                else:
                    g = f - d
                if g == 7:
                    print(str(a) + li[i] + str(b) + li[j] + str(c) + li[k] + str(d) + "=7")
                    return
calc(int(a),int(b), int(c), int(d))

Solution (Python):
S = input()
for op1 in [1, -1]:
    for op2 in [1, -1]:
        for op3 in [1, -1]:
            num = int(S[0]) + op1 * int(S[1]) + op2 * int(S[2]) + op3 * int(S[3])
            if num == 7:
                ans = S[0]
                ans += '+' if op1 == 1 else '-'
                ans += S[1]
                ans += '+' if op2 == 1 else '-'
                ans += S[2]
                ans += '+' if op3 == 1 else '-'
                ans += S[3]
                ans += '=7'
                print(ans)
                exit(0)

Solution (Python):
import itertools
s = list(input())
ops = itertools.product('+-',repeat = 3)
for x,y,z in ops:
  if eval(s[0]+x+s[1]+y+s[2]+z+s[3]) == 7:
    print(s[0]+x+s[1]+y+s[2]+z+s[3]+'=7')
    exit()

Solution (Python):


def resolve():
    ops = ['+', '-']
    s = input()

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

if __name__ == "__main__":
    resolve()

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


for i in itertools.product([0,1], repeat=3): 
    tmp = li[0]
    for j,k in enumerate(i):
        if k:
            tmp += li[j+1]
        else:
            tmp -= li[j+1]
    if tmp == 7:
        L = str(li[0])
        for _ in range(3):
            if i[_]:
                L += '+' + str(li[_+1])
            else:
                L += '-' + str(li[_+1])
        print(L+'=7')
        break

Solution (Python):
ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[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 = list(input())
num = [0]*4
num[0] = int(s[0])
for i in range(1,4):
  num[i] = [0]*2
  num[i][0] = int(s[i])
  num[i][1] = -(int(s[i]))
  
patern = [0] * 8

p = ['+', '-']

count = 0
for i in range(2):
  for j in range(2):
    for k in range(2):
      temp = num[0] + num[1][i] + num[2][j] + num[3][k]
      patern[count] = [p[i], p[j], p[k]]
      if temp == 7:
        ans_count = count
      count += 1

print(s[0] + patern[ans_count][0] + s[1] + patern[ans_count][1] + s[2] + patern[ans_count][2] + s[3] + '=7')

Solution (Python):
S = str(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])
E = ["-", "+"]
ans = []
for i in range(0, 2):
    for j in range(0, 2):
        for k in range(0, 2):
            tmp = A
            if i & 1:
                tmp += B
            else:
                tmp -= B
            if j & 1:
                tmp += C
            else:
                tmp -= C
            if k & 1:
                tmp += D
            else:
                tmp -= D
            if tmp == 7:
                ans.append(i)
                ans.append(j)
                ans.append(k)
print("{0}{1}{2}{3}{4}{5}{6}=7".format(
    A, E[ans[0]], B, E[ans[1]], C, E[ans[2]], D))

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

flag = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			B = (N[1] if i == 0 else -N[1])
			C = (N[2] if j == 0 else -N[2])
			D = (N[3] if k == 0 else -N[3])
			if sum([N[0], B, C, D]) == 7:
				print(N[0],end='')
				if i == 0:
					print('+',end='')
				else:
					print('-',end='')
				print(N[1],end='')
				if j == 0:
					print('+',end='')
				else:
					print('-',end='')
				print(N[2],end='')
				if k == 0:
					print('+',end='')
				else:
					print('-',end='')
				print(N[3],end='')
				print('=7')
				flag = True
				break
		if flag:
			break
	if flag:
		break

Solution (Python):
s=input()

for i in range(8):
	li=[]
	for j in range(3):
		if i>>j &1:
			li += '+'
		else:
			li += '-'
	ans=s[0] +li[0] +s[1]+li[1]+s[2]+li[2]+s[3]
	val=eval(ans)
	if val == 7:
		print( ''.join(ans)+'=7')
		break

Solution (Python):
import sys
from pprint import pprint
from operator import add, sub

from collections import deque

s =[int(s_i) for s_i in sys.stdin.readline().strip()] 


for op1 in (add, sub):
    for op2 in (add, sub):
        for op3 in (add, sub):
             if op3 ( op2 ( op1 (s[0], s[1]), s[2]), s[3]) == 7:
                 tmp1 = "+" if op1 == add else "-"
                 tmp2 = "+" if op2 == add else "-"
                 tmp3 = "+" if op3 == add else "-"
                 print(str(s[0]) + tmp1 + str(s[1]) + tmp2 + str(s[2]) + tmp3 + str(s[3]) + "=7")
                 sys.exit()

Solution (Python):
def make_fomula(s, ops):
    f = ''
    for v, op in zip(s, ops):
        f += v + op
    else:
        f += s[-1]
    return f


s = input()
n = len(s) - 1
bit = 0
while bit < (1 << n):
    ops = ['-'] * n
    for i in range(n):
        if bit & 1 << i:
            ops[i] = '+'

    fomula = make_fomula(s, ops)
    if eval(fomula) == 7:
        print(fomula+'=7')
        break

    bit += 1

Solution (Python):
A,B,C,D=input()
op='+-'
for a in op:
    for b in op:
        for c in op:
            _ = A+a+B+b+C+c+D
            if eval(_)==7:
                print(_+'=7')
                exit()

Solution (Python):
ABCD=input()
A,B,C,D=[ABCD[_] for _ in range(4)]
a,b,c,d=int(A),int(B),int(C),int(D)
if a+b+c+d==7:
    print(A+'+'+B+'+'+C+'+'+D+'=7')
elif a+b+c-d==7:
    print(A+'+'+B+'+'+C+'-'+D+'=7')
elif a+b-c+d==7:
    print(A+'+'+B+'-'+C+'+'+D+'=7')
elif a+b-c-d==7:
    print(A+'+'+B+'-'+C+'-'+D+'=7')
elif a-b+c+d==7:
    print(A+'-'+B+'+'+C+'+'+D+'=7')
elif a-b+c-d==7:
    print(A+'-'+B+'+'+C+'-'+D+'=7')
elif a-b-c+d==7:
    print(A+'-'+B+'-'+C+'+'+D+'=7')
elif a-b-c-d==7:
    print(A+'-'+B+'-'+C+'-'+D+'=7')

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

for i in range(1<<(len(l)-1)):
  s = l[0]
  for j in range(len(l)-1):
    if (i>>j) & 1:
      s += "+"
    else:
      s += "-"
    s += l[j+1]
  if eval(s) == 7:
    print(s+"=7")
    quit()

print("wrong input.")

Solution (Python):
A, B, C, D = list(input())
op = {'+': 1, '-': -1}
for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp = A + op1 + B + op2 + C + op3 + D
            if eval(tmp) == 7:
                print(tmp + '=7')
                exit()

Solution (Python):
A, B, C, D = map(int, list(input()))
op = {'+': 1, '-': -1}
for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp = A + B * op[op1] + C * op[op2] + D * op[op3]
            if tmp == 7:
                A, B, C, D = map(str, [A, B, C, D])
                print(A + op1 + B + op2 + C + op3 + D + '=7')
                exit()

Solution (Python):
l = list(map(str, input()))
n = len(l)
for i in range(2 ** (n-1)):
    bag = ['' for _ in range(n-1)]
    m = l[:]
    idx = n
    for j in range(n-1):
        if (i>>j) & 1:
            bag[j] = '+'
        else:
            bag[j] = '-'        
    for op in bag[::-1]:
        m.insert(idx-1, op)
        idx -= 1

    if eval(''.join(m)) == 7:
        print(''.join(m), "=7", sep="")
        break

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

N = 3
bcd = [b, c, d]
for i in range(2**N):
    tmp = a
    ch = str(a)
    for j in range(N):
        if i&1 == 0:
            tmp += bcd[j]
            ch += "+" + str(bcd[j])
        else:
            tmp -= bcd[j]
            ch += "-" + str(bcd[j])
        i >>= 1
    if tmp == 7:
        print(ch+"=7")
        break

Solution (Python):
def main():
    n = list(map(int,list(input())))
    if n[0]+n[1]+n[2]+n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]+n[1]+n[2]-n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
    elif n[0]+n[1]-n[2]-n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")
    elif n[0]-n[1]-n[2]-n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")
    elif n[0]+n[1]-n[2]+n[3] == 7:
        print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]-n[1]-n[2]+n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]-n[1]+n[2]+n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
    elif n[0]-n[1]+n[2]-n[3] == 7:
        print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
    
if __name__ == '__main__':
    main()

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

kotae=''

if a+b+c+d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a+b+c-d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a+b-c+d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a+b-c-d==7:
    kotae+=str(a)
    kotae+='+'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b+c+d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b+c-d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='+'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b-c+d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='+'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
elif a-b-c-d==7:
    kotae+=str(a)
    kotae+='-'
    kotae+=str(b)
    kotae+='-'
    kotae+=str(c)
    kotae+='-'
    kotae+=str(d)
    kotae+='='
    kotae+=str(7)
print(kotae)

Solution (Python):
def calc(s, n):
    if n == 0:
        ans = int(s[0])
        for i in range(2, len(s), 2):
            if s[i-1] == "+":
                ans += int(s[i])
            else:
                ans -= int(s[i])
        if ans == 7:
            global answer
            answer = s[0:len(s)-1] + "=7"
    if(n != 0): calc(s[0:n]+"+"+s[n:], n-1)
    if(n != 0): calc(s[0:n]+"-"+s[n:], n-1)

s = input()
answer = ""
calc(s, len(s))
print(answer)

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

if n[0] + n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}-{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] + n[3] == 7:
    print("{}+{}-{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] - n[3] == 7:
    print("{}+{}-{}-{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] + n[3] == 7:
    print("{}-{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] - n[3] == 7:
    print("{}-{}+{}-{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] + n[3] == 7:
    print("{}-{}-{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] - n[3] == 7:
    print("{}-{}-{}-{}=7".format(n[0],n[1],n[2],n[3]))
else:
    print("error")

Solution (Python):
A, B, C, D = map(int, list(input()))
for i in range(1<<3):
  r = A
  if i&(1<<2) == 0:
    r += B
  else:
    r -= B
  if i&(1<<1) == 0:
    r += C
  else:
    r -= C
  if i&(1<<0) == 0:
    r += D
  else:
    r -= D
  if r == 7:
    s = str(A)+("+" if i&(1<<2) == 0 else "-")+str(B)+("+" if i&(1<<1) == 0 else "-")+str(C)+("+" if i&(1<<0) == 0 else "-")+str(D)+"=7"
    print(s)
    exit()
print()

Solution (Python):
x=input()


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

    formula=""
    for k in range(3):
        formula += x[k]+op[k]

    formula+=x[3]
    if eval(formula) == 7:
        print(formula+"=7")
        exit()

Solution (Python):


s = list(input())
n = len(s)
v = 7


for i in range((n-1)*(n-1)):
    summation = int(s[0])
    str_equation = [s[0]]
    for j in range(n-1):
        
        if (i >> j) & 1:
            summation += int(s[j+1])
            str_equation.append("+")
            str_equation.append(s[j+1])
        
        else:
            summation -= int(s[j+1])
            str_equation.append("-")
            str_equation.append(s[j+1])

    if summation == v:
        str_equation.append("=")
        str_equation.append(str(v))
        print("".join(str_equation))
        break

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

import sys
ops = '+-'
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = '{}{}{}{}{}{}{}'.format(a, op1, b, op2, c, op3, d)
            if eval(s) == 7:
                print('{}=7'.format(s))
                sys.exit(0)

Solution (Python):
A = input()
a = [int(c) for c in A]
for i in range(2**3):
    tmp = a[0]
    op = []
    for j in range(3):
        if (i >> j) & 1:
            op.append("+")
            tmp += a[j+1]
        else:
            op.append("-")
            tmp -= a[j+1]
    if tmp == 7:
        a = A
        print(a[0]+op[0]+a[1]+op[1]+a[2]+op[2]+a[3]+"=7")
        exit(0)

Solution (Python):
x = input()
x = [int(i) for i in x]
xCount = len(x)

aaa = 0
for i in range(2**(xCount -1)):
    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(xCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    for i in range(xCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+' 
        
        if binaryNumber[i] == 0 :
            binaryNumber[i] = '-'
            
    
    result = []
    for i in range(xCount):
        result.append(x[i])
        if i < (xCount -1):
            result.append(binaryNumber[i])
    
    
    
    
    
    result = map(str, result)
    resultStr = ''.join(result)
    a = eval(resultStr)    
    
    
    if (a == 7) :
        print(str(resultStr) + '=7')
        break