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



Sample input:
1222


Sample output:
1+2+2+2=7

Submission status: Wrong Answer

Solution code:
from itertools import *

ABCD = input()

n = len(ABCD) - 1 # opの入力数

plumi_list = list(product(["+", "-"], repeat=n))

for bit in range(1 << n):
    formula = ABCD[0]
    for num, op in zip(ABCD[1:], plumi_list[bit]):
        formula += op + num
        ans = eval(formula)
        if ans == 7:
            print(formula + "=7")
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
ABCD = input()

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

Submission status: Wrong Answer

Solution code:
from itertools import *

ABCD = input()

n = len(ABCD) - 1 # opの入力数

plumi_list = list(product(["+", "-"], repeat=n))

print(plumi_list)

for bit in range(1 << n):
    formula = ABCD[0]
    for num, op in zip(ABCD[1:], plumi_list[bit]):
        formula += op + num
        ans = eval(formula)
        if ans == 7:
            print(formula + "=7")
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
A=input()
OP=["+++","-++","+-+","++-","--+","-+-","+--","---"]
for op in OP:
    if eval(A[0]+op[0]+A[1]+op[1]+A[2]+op[2]+A[3])==7:
        print(A[0]+op[0]+A[1]+op[1]+A[2]+op[2]+A[3]+"=7")

Submission status: Wrong Answer

Solution code:
def main():
    (A,B,C,D) = map(int, input())
    operation = ['+','-']
    for op1 in operation:
        sum = A
        if op1=='+':
            sum+=B
        else:
            sum-=B
        for op2 in operation:
            if op2=='+':
                sum+=C
            else:
                sum-=C
            if 7-sum==D:
                op3 = '+'
                print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
                return
            elif sum-7==D:
                op3 = '-'
                print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
                return

main()

Submission status: Wrong Answer

Solution code:
def main():
    (A,B,C,D) = map(int, input())
    operation = ['+','-']
    for op1 in operation:
        sum = A
        if op1=='+':
            sum+=B
        else:
            sum-=B
        for op2 in operation:
            if op1=='+':
                sum+=C
            else:
                sum-=C
            if 7-sum==D:
                op3 = '+'
                print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
                return
            elif sum-7==D:
                op3 = '-'
                print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7')
                return

main()

Submission status: Wrong Answer

Solution code:
In = [int(i) for i in input()]
flag = 0
for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            if eval("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}".format(In[3]))==7:
                print("{}".format(In[0])+op1+"{}".format(In[1])+op2+"{}".format(In[2])+op3+"{}=7".format(In[3]))
                flag = 1
                break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
l=[]
for i in s:
  l.append(int(i))
for i in range(2 ** n):
    check = []
    for j in range(n):
      if ((i >> j) & 1):  
        check.append(l[j]) 
      else:
        check.append(-l[j])         
    if sum(check)==7:
      print(str(check[0])+"+"+str(check[1])+"+"+str(check[2])+"+"+str(check[3])+"=7")
      exit()

Submission status: Wrong Answer

Solution code:
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(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
if A - B - C - D == 7:print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
if A + B + C - D == 7:print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
if A - B + C + D == 7:print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
if A - B - C + D == 7:print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
if A - B + C - D == 7:print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
if A + B - C + D == 7:print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')

Submission status: Wrong Answer

Solution code:
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(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3])
if A - B - C - D == 7:print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3]) 
if A + B + C - D == 7:print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3])
if A - B + C + D == 7:print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3])
if A - B - C + D == 7:print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3])
if A - B + C - D == 7:print(S[0] + '-' + S[1] + '+' + S[2] + '-' + S[3])
if A + B - C + D == 7:print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3])

Submission status: Wrong Answer

Solution code:
def Ans(x, y, z, w):
  if(x+ y+ z+ w == 7):
    return "{}+{}+{}+{}=7".format(x, y, z, w)
  elif(x- y+ z+ w == 7):
    return "{}-{}+{}+{}=7".format(x, y, z, w)
  elif(x- y- z+ w == 7):
    return "{}-{}-{}+{}=7".format(x, y, z, w)
  elif(x- y- z- w == 7):
    return "{}-{}-{}-{}=7".format(x, y, z, w)
  elif(x- y+ z- w == 7):
    return "{}-{}+{}-{}=7".format(x, y, z, w)
  elif(x+ y- z+ w == 7):
    return "{}+{}-{}+{}=7".format(x, y, z, w)
  elif(x+ y- z- w == 7):
    return "{}+{}-{}-{}=7".format(x, y, z, w)
  elif(x- y- z- w == 7):
    return "{}-{}-{}-{}=7".format(x, y, z, w)


ABCD = input()
N = list(ABCD)

x = int(N.pop(0))
y = int(N.pop(0))
z = int(N.pop(0))
w = int(N.pop(0))

ans = Ans(x, y, z, w)
print(ans)

Submission status: Wrong Answer

Solution code:
def Ans(x, y, z, w):
  if(x+ y+ z+ w == 7):
    return "{}+{}+{}+{}=7".format(x, y, z, w)
  elif(x- y+ z+ w == 7):
    return "{}-{}+{}+{}=7".format(x, y, z, w)
  elif(x- y- z+ w == 7):
    return "{}-{}-{}+{}=7".format(x, y, z, w)
  elif(x- y- z- w == 7):
    return "{}-{}-{}-{}=7".format(x, y, z, w)
  elif(x- y+ z- w == 7):
    return "{}-{}+{}-{}=7".format(x, y, z, w)
  elif(x+ y- z+ w == 7):
    return "{}+{}-{}+{}=7".format(x, y, z, w)
  elif(x+ y- z- w == 7):
    return "{}+{}-{}-{}=7".format(x, y, z, w)
  elif(x+ y+ z+ w == 7):
    return "{}-{}-{}-{}=7".format(x, y, z, w)


ABCD = input()
N = list(ABCD)

x = int(N.pop(0))
y = int(N.pop(0))
z = int(N.pop(0))
w = int(N.pop(0))

ans = Ans(x, y, z, w)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
inp = int(input())


a = int(inp / 1000)
b = int((inp % 1000)/100)
c = int((inp % 100)/10)
d = int((inp % 10))
'''

d = inp % 10
inp //= 10

c = inp % 10
inp //= 10

b = inp % 10
inp //= 10

a = inp % 10
inp //= 10
'''

pm = 8
total = a


for i in range(8):
    total = a
    siki = str(a)
    if(i & 1):
        total += b
        siki += '+' +str(b)
    elif((i&1) != 1):
        total -= b
        siki += '-' +str(b)

    if((i>>1) &1 ):
        total += c
        siki += '+' +str(c)
    else:
        total -= c
        siki += '-' +str(c)

    if((i>>2) &1):
        total += d
        siki += '+' +str(d)
    else:
        total -= d
        siki += '-' +str(d)

    if (total == 7):
        siki += "=7"
        print(siki)

Submission status: Wrong Answer

Solution code:
import math
inp = int(input())


a = int(inp / 1000)
b = int((inp % 1000)/100)
c = int((inp % 100)/10)
d = int((inp % 10))
'''

d = inp % 10
inp //= 10

c = inp % 10
inp //= 10

b = inp % 10
inp //= 10

a = inp % 10
inp //= 10
'''

pm = 8
total = a

siki = "a"

for i in range(8):
    total = a
    siki = "a"
    if(i & 1):
        total += b
        siki += "+b"
    elif((i&1) != 1):
        total -= b
        siki += "-b"

    if((i>>1) &1 ):
        total += c
        siki += "+c"
    else:
        total -= c
        siki += "-c"

    if((i>>2) &1):
        total += d
        siki += "+d"
    else:
        total -= d
        siki += "-d"

    if (total == 7):
        print(siki)

Submission status: Wrong Answer

Solution code:
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

if A + B + C + D == 7 or A - B - C - D == 7 or A + B + C - D == 7 or A - B + C + D == 7 or A - B - C + D == 7 or A - B + C - D == 7 or A + B - C + D == 7:
  print('YES')

Submission status: Wrong Answer

Solution code:
S=input()

ans=0
for i in range(1<<3):
    f=S[0]
    ans=1
    for j in range(3):

        if((i>>j) & 1==1):
            ans=ans+int(S[j+1])
            f=f+'+'+S[j+1]
        else:
            ans=ans-int(S[j+1])
            f=f+'-'+S[j+1]
    print(f)
    print(ans)
    if(ans==7):
        print(f+'=7')

Submission status: Wrong Answer

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

lis=[[i,-i] for i in [b,c,d]]
#print(lis)
for i in range(8):
    sam=[a]
    #print(sam)
    for j in range(3):
        boolen=((i>>j)&1)
        sam.append(lis[j][int(boolen)])
    #print(sam)
    if sum(sam)==7:
        #print(sam)
        dis=[str(sam[0])]
        for num in sam[1:]:
            if num>=0:
                dis.append('+'+str(num))
            else:
                dis.append(str(num))
        print('%s%s%s%s=7'%(dis[0],dis[1],dis[2],dis[3]))

Submission status: Wrong Answer

Solution code:
n=list(input())
for i in range(1<<3):
    cnt=int(n[0])
    l=[n[0]]
    for j in range(3):
        if (i>>j)%2==1:
            cnt+=int(n[j+1])
            l+="+"+n[j]
        else:
            cnt-=int(n[j+1])
            l+="-"+n[j]
    if cnt==7:
        print("".join(l)+"=7")
        break

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc079/tasks/abc079_c

num = list(input())

for i in range(2 ** 3):
    t = int(num[0])
    op = []
    for j in range(3):
        if (i >> j) & 1:
            t += int(num[j + 1])
            op.append('+')
        else:
            t -= int(num[j - 1])
            op.append('-')
    op.append('=')
    if t == 7:
        ans = []
        for i, j in zip(num, op):
            ans.append(i)
            ans.append(j)
        print(''.join(ans) + '7')
        break

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(str,input())

n = 3
pt = []
for i in range(2 ** n):
  tmp = ["+"] * n
  for j in range(n):
    if i >> j == 1:
      tmp[j] = "-"
  pt.append(tmp)
for x in pt:
  fr = a + x[0] + b + x[1] + c+ x[2] + d 
  if eval(fr) == 7 :
    print(fr+"=7")
    exit()

Submission status: Wrong Answer

Solution code:
S=str(input())
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
PM=['+','-']

for op1 in PM:
  if op1 == '-':
    B *= -1
  for op2 in PM:
    if op2 == '-':
      C *= -1
    for op3 in PM:
      if op3 == '-':
        D *= -1
      if A+B+C+D==7:
        print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+'=7')
        exit()

Submission status: Wrong Answer

Solution code:
s=input()
l=[]
for i in s:
  l.append(int(i))
print(l)

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input())

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

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input())

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

Submission status: Wrong Answer

Solution code:
num = list(input())
n = len(num) - 1
lst = ["-"]*n

for i in range(2**n):
    temp = [0]*(len(num)+n)
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    temp[::2] = num
    temp[1::2] = lst
    wa = eval("".join(temp[:]))
    if wa == 7:
        print("".join(temp[:]) + "=7")
        exit()

Submission status: Wrong Answer

Solution code:
x = str(input())
l = [x[0], x[1], x[2], x[3]]
m = [int(s) for s in l]
N = 2 ** 3
for i in range(N):
  n = [m[0], 0, 0, 0]
  o = [] # +か-かを記憶
  for j in range(3):
    if (i >> j) & 1:
      n[-j-1] = -m[-j-1]
      o.append('-')
    else:
      n[-j-1] = m[-j-1]
      o.append('+')
  if sum(n) == 7:
    print(str(m[0]) + o[0] + str(m[1]) + o[1] + str(m[2]) + o[2] + str(m[3]) + '=7')
    exit()

Submission status: Wrong Answer

Solution code:
x = str(input())
l = [x[0], x[1], x[2], x[3]]
m = [int(s) for s in l]
N = 2 ** 3
for i in range(N):
  n = [m[0], 0, 0, 0]
  o = [] # +か-かを記憶
  for j in range(3):
    if (i >> j) & 1:
      n[-j-1] = -m[-j-1]
      o.append('-')
    else:
      n[-j-1] = m[-j-1]
      o.append('+')
  if sum(n) == 7:
    print(str(m[0]) + o[0] + str(m[1]) + o[1] + str(m[2]) + o[2] + str(m[3]))
    exit()

Submission status: Wrong Answer

Solution code:
abcd=input()

for i in range(2**3):
    op=['-']*3
    for j in range(3):
        if (i>>j) and 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

Submission status: Wrong Answer

Solution code:
abcd=input()

for i in range(2**3):
    op=['+']*3
    for j in range(3):
        if (i>>j) and 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

Submission status: Wrong Answer

Solution code:
s = list(input())
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = s[0]+op1+s[1]+op2+s[2]+op3+s[3]
            if eval(ans) ==7:
                print(ans + '=7')
                break

Submission status: Wrong Answer

Solution code:
n = input()
for i in range(2 ** 3):
    result = int(n[0])
    formura = n[0]
    for j in range(1,4):  
        if ((i >> j) & 1): 
            result -= int(n[j])
            formura += "-"+n[j]
        else:
            result += int(n[j])
            formura += "+"+n[j]
    if result == 7:
        print(formura+"=7")
        break

Submission status: Wrong Answer

Solution code:
n = input()
for i in range(2 ** 4):
    result = 0
    formura = ""
    for j in range(4): 
        formura += n[j]
        if ((i >> j) & 1): 
            result -= int(n[j])
            formura += "-"
        else:
            result += int(n[j])
            formura += "+"
    if result == 7:
        print(formura[:-1]+"=7")
        break

Submission status: Wrong Answer

Solution code:
n = input()
for i in range(2 ** 4):
    result = 0
    formura = ""
    for j in range(4):  # このループが一番のポイント
        formura += n[j]
        if ((i >> j) & 1): 
            result -= int(n[j])
            formura += "-"
        else:
            result += int(n[j])
            formura += "+"
    if result == 7:
        print(formura+"=7")
        break

Submission status: Wrong Answer

Solution code:
s_list = str(input())
A, B, C, D = [int(s) for s in s_list ]
for x in range(2):
    if x==0:
        X = A + B
        px = '+'
    else:
        X = A - B
        px = '-'
    for y in range(2):
        if y==0:
            Y = X + C
            py = '+'
        else:
            Y = X - C
            py = '-'
        for z in range(2):
            if z==0:
                Z = Y + D
                pz = '+'
            else:
                Z = Y - D
                pz = '-'
                
            if Z==7:
                print(A, px, B, py, C, pz, D, sep='')
                exit()

Submission status: Wrong Answer

Solution code:
s_list = str(input())
A, B, C, D = [int(s) for s in s_list ]
for x in range(2):
    if x==0:
        X = A + B
        px = '+'
    else:
        X = A - B
        px = '-'
    for y in range(2):
        if y==0:
            Y = X + C
            py = '+'
        else:
            Y = X - C
            py = '-'
        for z in range(2):
            if z==0:
                Z = Y + D
                pz = '+'
            else:
                Z = Y - D
                pz = '-'
                
            if Z==7:
                print(A, px, B, py, C, pz, D, sep='')

Submission status: Wrong Answer

Solution code:
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, d = map(int, input())
#print(a, b, c, d)
if a+b+c+d == 7:
    print(a, '+', b, '+', c, '+', d, '=', 7)
    exit()
if a+b-c+d == 7:
    print(a, '-', b, '+', c, '-', d, '=', 7)
    exit()
if a+b+c-d == 7:
    print(a, '+', b, '+', c, '-', d, '=', 7)
    exit()
if a+b-c-d == 7:
    print(a, '+', b, '-', c, '-', d, '=', 7)
    exit()
if a-b+c+d == 7:
    print(a, '-', b, '+', c, '+', d, '=', 7)
    exit()
if a-b-c+d == 7:
    print(a, '-', b, '-', c, '+', d, '=', 7)
    exit()
if a-b+c-d == 7:
    print(a, '-', b, '+', c, '-', d, '=', 7)
    exit()
if a-b-c-d == 7:
    print(a, '-', b, '-', c, '-', d, '=', 7)
    exit()

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
a = ""
for i in range(1 << 3):
    bit = bin(i)[2:].zfill(3)
    total = int(s[0])
    for j in range(3):
        if bit[j] == "1":
            total += int(s[j + 1])
        else:
            total -= int(s[j + 1])
    if total == 7:
        a = bit
        break
print(a)
ans = ""
for i in range(4):
    if i == 0:
        ans += s[i]
    else:
        if bit[i - 1] == "1":
            ans += "+" + s[i]
        else:
            ans += "-" + s[i]
print(ans + "=7")

Submission status: Wrong Answer

Solution code:
S = input()

def saiki(i,s = S[0]):
    if i == 3:
        if eval(s) == 7:
            print(str(s) + "=7")
            exit()
            
    saiki(i + 1, s + "+" + S[i+1])
    saiki(i + 1, s + "-" + S[i+1])

Submission status: Wrong Answer

Solution code:
S = input()
a = len(str(S))-1
 
for i in range(2**a):  
    temp = str(S)[0]  
    for j in range(a):
        if i & (1<<j):
            temp += "+"
        else:
            temp += "-"
        temp+=str(S)[j+1]
    
    if eval(temp) == 7:
        print("{}=7".format(temp))

Submission status: Wrong Answer

Solution code:
S = input()
a = len(str(S))-1
 
for i in range(2**a):  
    temp = str(S)[0]  
    for j in range(a):
        if i & (1<<j):
            temp += "+"
        else:
            temp += "-"
        temp+=str(S)[j+1]
    
    if eval(temp) == 7:
        print(temp)

Submission status: Wrong Answer

Solution code:
S = input()
S_damy = S
sum_S = int(S[0])
plus = 8
c = 0
for i in range(plus):
    for j in range(3):
        if (i >> j) & 1:
            sum_S += int(S[-(j+1)])
        else: sum_S -= int(S[-(j+1)])
    
    if sum_S == 7:
        c = i
        break
    sum_S = int(S[0])

score = ""
for k in range(3):
    score += S[k]
    if c >> 2-k == 0:
        score += "-"
    else:
        score += "+"
score += S[3]
score += "=7"

print(score)

Submission status: Wrong Answer

Solution code:
listi = list(input())
a=listi[0]
b=listi[1]
c=listi[2]
d=listi[3]

 

res = ""


def hugou(i):
    if z[int(i)]=="0":
        return "+"
    else:
        return "-"
    

for x in range(2 ** 3):

    z = str(format(x, '03b')) #2進数に変換
    ans = 0
    ans += int(a)
    if z[0]=="0":
        ans += int(b)
    else:
        ans += int(b) * -1
    if z[1]=="0":
        ans += int(c)
    else:
        ans += int(c) * -1   
    if z[2]=="0":
        ans += int(d)
    else:
        ans += int(d) * -1        
        
    
    
    if ans == 7:
        res += a
        res += hugou(z[0])
        res += b
        res += hugou(z[1]) 
        res += c
        res += hugou(z[2])
        res += d 
        
        res += "=7"
        print(res)
        break

Submission status: Wrong Answer

Solution code:
listi = list(input())
a=listi[0]
b=listi[1]
c=listi[2]
d=listi[3]

 

res = ""


def hugou(i):
    if z[int(i)]=="0":
        return "+"
    else:
        return "-"
    
def hugou1(i):
    if z[int(i)]=="0":
        return 1
    else:
        return -1

for x in range(2 ** 3):

    z = str(format(x, '03b')) #2進数に変換
    ans = 0
    ans += int(a)
    ans += int(b) * hugou1(z[0])
    ans += int(c) * hugou1(z[1])
    ans += int(d) * hugou1(z[2])

    
    if ans == 7:
        res += a
        res += hugou(z[0])
        res += b
        res += hugou(z[1]) 
        res += c
        res += hugou(z[2])
        res += d 
        
        res += "=7"
        print(res)
        break

Submission status: Wrong Answer

Solution code:
def op(x):
    return '+' if x==0 else '-'
# -*- coding: utf-8 -*-
N = int(input())
a=N//1000
b=N%1000//100
c=N%100//10
d=N%10
for i in range(2**3):
    total=0
    for j,num in zip(range(3),[b,c,d]):
        if (i>>j)&1==0:
            total+=num
        else:
            total-=num
    if a+total==7:
        print('{}{}{}{}{}{}{}=7'.format(a,op(i>>0&1),b,op(i>>1&1),c,op(i>>2&1),d))

Submission status: Wrong Answer

Solution code:
s = list(input())
a , b , c , d = map(int , s)
op = [0 , 1]
pm = ['+' , '-']
for i in op:
  for j in op:
    for k in op:
      if i == 0:
        ans = a + b
      else:
        ans = a - b
      if j == 0:
        ans += c
      else:
        ans -= c
      if j == 0:
        ans += d
      else:
        ans -= d
      if ans == 7:
        break
    else:
      continue
    break
  else:
    continue
  break
print('{a}{i}{b}{j}{c}{k}{d}=7'.format(a = a , i = pm[i] , b = b , j = pm[j] , c  = c  , k = pm[k] , d = d))

Submission status: Wrong Answer

Solution code:
s=input()
op=['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp=s[0]+op1+s[1]+op2+s[2]+op3+s[3]
            if eval(tmp)==7:
                print(tmp+'=7')
                break

Submission status: Wrong Answer

Solution code:
s=input()
op=['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp=s[0]+op1+s[1]+op2+s[2]+op3+s[3]
            if eval(tmp)==7:
                print(tmp)
                break

Submission status: Wrong Answer

Solution code:
import itertools
s = list(input())
for ops in itertools.product(['+','-'],repeat=3):
  s_i = []
  for i in range(3):
    s_i.append(s[i])
    s_i.append(ops[i])
  s_i.append(s[-1])
  s_i = "".join(s_i)
  if eval(s_i)==7:
    print(s_i+"=7")

Submission status: Wrong Answer

Solution code:
S = input()

def func(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ''
    opP = func(i + 1, x + int(S[i]), op+'+'+str(S[i]))
    if opP != '':
        return opP
    opM = func(i + 1, x - int(S[i]), op+'-'+str(S[i]))
    if opM != '':
        return opM
    return ''

print(func(1, int(S[0]), str(S[0])))

Submission status: Wrong Answer

Solution code:
A=input()

for i in range(2**3):
  tmp=['-','-','-']
  for j in range(3):
    if ((i>>j)&1):
      tmp[j]='+'
  if eval(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3])==7:
    print(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3]+"=7")

Submission status: Wrong Answer

Solution code:
s = str(input())
opl = []
op = [''] * 3
for i in range(2):
  if i % 2 == 0:
    op[0] = '+'
  else:
    op[0] = '-'
  for j in range(2):
    if j % 2 == 0:
      op[1] = '+'
    else:
      op[1] = '-'
    for k in range(2):
      if k % 2 == 0:
        op[2] = '+'
      else:
        op[2] = '-'
      opn = op[:]
      opl.append(opn)    
for i in range(2 * 3):
  if eval(s[0]+opl[i][0]+s[1]+opl[i][1]+s[2]+opl[i][2]+s[3]) == 7:
    ss = s[0]+opl[i][0]+s[1]+opl[i][1]+s[2]+opl[i][2]+s[3]+"=7"
    print(ss)
    break

Submission status: Wrong Answer

Solution code:
s = str(input())
opl = []
op = [''] * 3
for i in range(2):
  if i % 2 == 0:
    op[0] = '+'
  else:
    op[0] = '-'
  for j in range(2):
    if j % 2 == 0:
      op[1] = '+'
    else:
      op[1] = '-'
    for k in range(2):
      if k % 2 == 0:
        op[2] = '+'
      else:
        op[2] = '-'
      opn = op[:]
      opl.append(opn)    
for i in range(2 * 3):
  if eval(s[0]+opl[i][0]+s[1]+opl[i][1]+s[2]+opl[i][2]+s[3]) == 7:
    ss = s[0]+opl[i][0]+s[1]+opl[i][1]+s[2]+opl[i][2]+s[3]
    print(ss,"=7")
    break

Submission status: Wrong Answer

Solution code:
L = [int(i) for i in str(input())]
for i in range(2 ** 3):
    l = ['+'] * 3
    for j in range(3):
        if ((i >> j) & 1):
            l[j] = '-'
    s = L[0]
    for k in range(3):
        if l[k] == '+':
            s += L[k + 1]
        else:
            s -= L[k + 1]
    if s == 7:
        for m in range(3):
            print(str(L[m]) + str(l[m]), end='')
        print(str(L[3]) + '=7')

Submission status: Wrong Answer

Solution code:
s = list(input())
a = s[0]
b = s[1]
c = s[2]
d = s[3]
e = int(a)+int(b)+int(c)+int(d)
f = e - 7
if e == 7:
  print(a+'+'+b+'+'+c+'+'+d+'=7')
else:
  if b*2 == f:
    print(a+'-'+b+'+'+c+'+'+d+'=7')
  elif c*2 == f:
    print(a+'+'+b+'-'+c+'+'+d+'=7')
  elif d*2 == f:
    print(a+'+'+b+'+'+c+'-'+d+'=7')
  elif (b+c)*2 == f:
    print(a+'-'+b+'-'+c+'+'+d+'=7')
  elif (b+d)*2 == f:
    print(a+'-'+b+'+'+c+'-'+d+'=7')
  elif (c+d)*2 == f:
    print(a+'+'+b+'-'+c+'-'+d+'=7')
  elif (b+c+d)*2 == f:
    print(a+'-'+b+'-'+c+'-'+d+'=7')