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:
import math

def dig(x,d):
  return (x%(10**(d+1)))//(10**d)

def main():
  N=int(input())
  D=int(math.log10(N))
  ans=0
  s=['']*D
  for bits in range(2*N):
    ans=dig(N,D)
    for i in range(1,D+1):
      if (bits>>(D-i))&1:
        ans+=dig(N,D-i)
        s[i-1]='+'
      else:
        ans-=dig(N,D-i)
        s[i-1]='-'
    if ans==7:
      print(dig(N,3),end="")
      for i in range(3):
        print(s[i],end="")
        print(dig(N,2-i),end="")
      print('=7')
      return

Submission status: Wrong Answer

Solution code:
import math

def dig(x,d):
  return (x%(10**(d+1)))/(10**d)

N=int(input())
D=int(math.log10(N))
ans=0
for bits in range(2*N):
  for i in range(D):
    if (bits>>i)&1:
      ans+=dig(N,i)
    else:
      ans-=dig(N,i)
      
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(input())
for i in range(8):
    b = []
    for j in range(4):
        b.append(a[j])
        if j == 3:
            pass
        else:
            if((i>>j)&1):
                b.append('+')
            else:
                b.append('-')
    c = ''.join(b)
    if eval == 7:
        break
    else:
        pass
print(c+'=7')

Submission status: Wrong Answer

Solution code:
a = list(input())
for i in range(8):
    b = []
    for j in range(4):
        b.append(a[j])
        if j == 3:
            pass
        else:
            if((i>>j)&1):
                b.append('+')
            else:
                b.append('-')
    c = ''.join(b)
    if eval == 7:
        break
    else:
        pass
print(c+'=4')

Submission status: Wrong Answer

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

if a + b + c + d == 7:
  print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))

if a + b + c - d == 7:
  print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))

if a + b - c - d == 7:
  print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
  
if a - b - c - d == 7:
  print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))

if a + b - c + d == 7:
  print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
  
if a - b + c + d == 7:
  print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))

if a - b - c + d == 7:
  print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))

if a - b + c - d == 7:
  print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))

Submission status: Wrong Answer

Solution code:
N = [int(i) for i in str(input())]
output = list()
num_op = 3

for i in range(2**num_op):
  ans = '{}'.format(str(N[0]))
  res = N[0]
  for j in range(num_op):
    if (i>>j) & 1:
      res += N[j+1]
      ans += '+{}'.format(str(N[j+1]))
    else:
      res -= N[j+1]
      ans += '-{}'.format(str(N[j+1]))
  if res == 7:
    output.append(ans+'=7')
    exit()

Submission status: Wrong Answer

Solution code:
s = input()
lst = [int(i) for i in s]
f1 = lambda x: '+' if x else '-'
f2 = lambda x: 1 if x else - 1
for i in range(16):
  tmp1 = [f1(i >> x & 1) for x in range(3)]
  tmp2 = [f2(i >> x & 1) * lst[ - x - 1] for x in range(3)]
  if lst[0] + sum(tmp2) == 7:
    print(''.join([s[i] + tmp1[i] for i in range(3)] + [s[3] + '=7']))
    break

Submission status: Wrong Answer

Solution code:
import sys
a,b,c,d = map(int, list(input()))
x = [1,-1]
for i in x:
  for j in x:
    for k in x:
      if a+i*b+j*c+k*d==7:
        ans = str(a)
        ans += "+" if i==1 else"-"
        ans += str(b)
        ans += "+" if j==1 else"-"
        ans += str(c)
        ans += "+" if k==1 else"-"
        ans += str(d)
        print(ans)
        sys.exit()

Submission status: Wrong Answer

Solution code:
n=input()

c=len(n)-1
for i in range(2**c):
      L=['-']*c
      for j in range(c):
            if ((i>>j)&1):#「>>」自体に二進数演算が含まれている
                  L[c-1-j]="+"#右詰めにする
      L+=['']
      f=""
      for a,b in zip(n,L):
            f+=a+b
      if eval(f)==7:
            print(f + '7')
            break

Submission status: Wrong Answer

Solution code:
n = [int(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] = "+"  # フラグが立っていた箇所を "+" で上書き
        formula = ""
        for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
            formula += str(p_n)
            formula += str(p_o)
        if eval(formula) == 7:
            print(formula + "=7")
            break

Submission status: Wrong Answer

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

import random


def main():
    # a,b,c,d = map(int, input().strip().split())
    l_abcd = list(map(int,input().strip()))
    eprint("l_abcd ",end=": ")
    eprint(l_abcd)
    for case in range(2 ** 3):     # 場合ループ # nは人とかモノとかの個数
        l_op_bin = list(map(int,(format(case,'b').zfill(3))))
        # eprint("l_op_bin ",end=": ")
        # eprint(l_op_bin)
        
        #flag=0
        sum_x=l_abcd[0]
        stack_op=[]
        for index_location in range(3):      # 人とかモノとかループ
            if l_op_bin[index_location]==1:                   # その桁がyesだと仮定している場合
               sum_x += l_abcd[1+index_location]
               stack_op.append("+")
            else:                                 # その桁がnoだと仮定している場合
               sum_x -= l_abcd[1+index_location]
               stack_op.append("-")
        if sum_x==7:
            print(l_abcd[0], end="")
            print(stack_op.pop(),end="")
            print(l_abcd[1], end="")    
            print(stack_op.pop(),end="")
            print(l_abcd[2], end="")    
            print(stack_op.pop(),end="")
            print(l_abcd[3], end="=7\n")
            return
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S=[int(s) for s in list(input())]
op=['+','-']
for (op1, op2, op3) in zip([0,1], [0,1],[0,1]):
  x=S[0]+(1-2*op1)*S[1]+(1-2*op1)*S[2]+(1-2*op1)*S[3]
  if x==7:
    ls=[S[0],op[op1],S[1],op[op2],S[2],op[op3],S[3],'=7']
    print(*ls,sep="")
    break

Submission status: Wrong Answer

Solution code:
S=[int(s) for s in list(input())]
op=['+','-']
for (op1, op2, op3) in zip([0,1], [0,1],[0,1]):
  x=S[0]+(1-2*op1)*S[1]+(1-2*op1)*S[2]+(1-2*op1)*S[3]
  if x==7:
    ls=[S[0],op[op1],S[1],op[op2],S[2],op[op3],S[3]]
    print(*ls,sep="")
    break

Submission status: Wrong Answer

Solution code:
s = list(input())

def calc(i, a, b,tag):
  a ,b = int(a), int(b)
  if i==0:
    c = a+b
    tag.append('+')
  elif i==1:
    c = a-b
    tag.append('-')
  return c, tag
    
for i in range(2):
  tag = []
  c ,tag= calc(i,s[0],s[1],tag)
  for j in range(2):
    d ,tag = calc(j,c,s[2],tag)
    for k in range(2):
      e ,tag = calc(k,d,s[3],tag)
      if e == 7:
        print(s[0]+tag[0]+s[1]+tag[1]+s[2]+tag[2]+s[3]+'=7')
        exit()

Submission status: Wrong Answer

Solution code:
s = list(input())

def calc(i, a, b,tag):
  a ,b = int(a), int(b)
  if i==0:
    c = a+b
    tag.append('+')
  elif i==1:
    c = a-b
    tag.append('-')
  return c, tag
    
for i in range(2):
  tag = []
  c ,tag= calc(i,s[0],s[1],tag)
  for j in range(2):
    d ,tag = calc(j,c,s[2],tag)
    for k in range(2):
      e ,tag = calc(k,d,s[3],tag)
      if e == 7:
        print(s[0]+tag[0]+s[1]+tag[1]+s[2]+tag[2]+s[3])
        exit()

Submission status: Wrong Answer

Solution code:
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


S = input()
A, B, C, D = map(int, [S[0], S[1], S[2], S[3]])
dump(A, B, C, D)
for x in it.product(['+', '-'], repeat=3):
    op1, op2, op3 = x[0], x[1], x[2]
    dump(op1, op2, op3)

    def f(op, a): return a * (1 if op == '+' else -1)
    ans = A + f(op1, B) + f(op2, C)+f(op2, D)
    if(ans == 7):
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7")
        break

Submission status: Wrong Answer

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

idx = [0, 1, 2]
output = []
for i in range(1 << len(idx)):
    ops = ['+', '+', '+']
    if A+B+C+D == 7: 
        print(A,ops[0],B,ops[1],C,ops[2],D,'=7')
        exit()
    
    ans = A
    for j in range(len(idx)):
        if ((i >> j) & 1) == 1:
            ops[j] = '-'
    
    if ops[0] == '+' : ans += B
    else : ans -= B
    
    if ops[1] == '+' : ans += C
    else : ans -= C
    
    if ops[2] == '+' : ans += D
    else : ans -= D
    
    if ans == 7:
        print(A,ops[0],B,ops[1],C,ops[2],D,'=7')
        exit()

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

S = F.readline().rstrip()
A = int(S[:1])
B = int(S[1:2])
C = int(S[2:3])
D = int(S[3:4])

sum = A
nums = [B, C, D]
N = 3
l = [0, 0, 0]
ans = str(A)

# pdb.set_trace()
for bit in range(1<<N):
    for i in range(N):
        if bit & (1<<i):
            sum -= nums[i]
            l[i] = 1
            continue
        sum += nums[i]

    if sum == 7:
        break

    sum = A

for j in range(N):
    if l[j] == 0:
        ans += ('+' + str(nums[j]))
        continue
    ans += ('-' + str(nums[j]))

ans += '=7'

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    A, B, C, D = input()
    op = '+-'
    
    for op1 in op:
        for op2 in op:
            for op3 in op:
                left_hand = A + op1 + B + op2 + C + op3 + D
                if eval(left_hand) == 7:
                    return left_hand + '=7'

solve()

Submission status: Wrong Answer

Solution code:
import copy


def main():
    A = list(input())
    AA = list(map(int, A))

    s = AA[0]
    A = copy.deepcopy(AA)
    A.pop(0)
    A = sorted(A)

    op = []
    for _ in range(3):
        if s < 7:
            s += A[-1]
            op.append(["+", A[-1]])
        else:
            s -= A[-1]
            op.append(["-", A[-1]])
        A.pop(-1)

    if s != 7:
        s == AA[0]
        A = copy.deepcopy(AA)
        A.pop(0)
        A = sorted(A)
        op = []
        for _ in range(3):
            if s <= 7:
                s += A[-1]
                op.append(["+", A[-1]])
            else:
                s -= A[-1]
                op.append(["-", A[-1]])
            A.pop(-1)

    ans = [str(AA[0])]
    for i in range(1, 4):
        for j in range(len(op)):
            if AA[i] == op[j][1]:
                ans.append(op[j][0] + str(op[j][1]))
                op.pop(j)
                break
    ans.append("=7")
    print(''.join(ans))


main()

Submission status: Wrong Answer

Solution code:
import copy


def main():
    A = list(input())
    AA = list(map(int, A))

    s = AA[0]
    A = copy.deepcopy(AA)
    A.pop(0)
    A = sorted(A)

    op = [str(s)]
    for _ in range(3):
        if s < 7:
            s += A[-1]
            op.append(["+", A[-1]])
        else:
            s -= A[-1]
            op.append(["-", A[-1]])
        A.pop(-1)

    if s != 7:
        s == AA[0]
        A = copy.deepcopy(AA)
        A.pop(0)
        A = sorted(A)
        op = [str(AA[0])]
        for _ in range(3):
            if s <= 7:
                s += A[-1]
                op.append(["+", A[-1]])
            else:
                s -= A[-1]
                op.append(["-", A[-1]])
            A.pop(-1)

    ans = [str(AA[0])]
    for i in range(1, 4):
        for j in range(1, 4):
            if AA[i] == op[j][1]:
                ans.append(op[j][0] + str(op[j][1]))
                break
    ans.append("=7")
    print(''.join(ans))


main()

Submission status: Wrong Answer

Solution code:
ABCD = input()

for i in range(2**(len(ABCD)-1)):
    n = int(ABCD[0])
    ans = ABCD[0]
    for j, c in enumerate(format(i, '0' + str(len(ABCD)-1) + 'b')):
        if c == '0':
            n += int(ABCD[j+1])
            ans += '+'
        else:
            n -= int(ABCD[j+1])
            ans += '-'
        ans += ABCD[j+1]
    if n == 7:
        print(ans)
        exit(0)

Submission status: Wrong Answer

Solution code:
a,b,c,d=input()
lst_1=[]
lst_2= ["+","-"]
for i in lst_2:
  for j in lst_2:
    for k in lst_2:
      lst_1.append(a+i+b+j+c+k+d)
for l in lst_1:
  if eval(l)==7:
    print(l+"=7")

Submission status: Wrong Answer

Solution code:
a,b,c,d=input()
lst_1=[]
lst_2= ["+","-"]
for i in lst_2:
  for j in lst_2:
    for k in lst_2:
      lst_1.append(a+i+b+j+c+k+d)
for l in lst_1:
  if eval(l)==7:
    print(l)

Submission status: Wrong Answer

Solution code:
s = input()
li = [-1,1]
a = '+'
b = '+'
c = '+'
for i in li:
	for j in li:
		for k in li:
			if int(s[0])+(i*int(s[1]))+(j*int(s[2]))+(k*int(s[3])) == 7:
				if i == -1:
					a = '-'
				if j == -1:
					b = '-'
				if k == -1:
					c = '-'
				print(s[0] + a + s[1] + b + s[2] + c + s[3] + '=7')
				break

Submission status: Wrong Answer

Solution code:
s = input()
li = [-1,1]
a = '+'
b = '+'
c = '+'
for i in li:
	for j in li:
		for k in li:
			if int(s[0])+(i*int(s[1]))+(j*int(s[2]))+(k*int(s[3])) == 7:
				if i == -1:
					a = '-'
				if i == -1:
					b = '-'
				if i == -1:
					c = '-'
				print(s[0] + a + s[1] + b + s[2] + c + s[3] + '=7')
				break

Submission status: Wrong Answer

Solution code:
n=input()
op_cnt=len(n)-1
for i in range(2**op_cnt):
    s=n[0]
    for j in range(op_cnt):
        if ((i<<j)&1):
            s+="+"
        else:
            s+="-"
        s+=n[j+1]
    if eval(s)==7:
        print(s+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    otos=lambda x:"+" if x==1 else "-"
    abcd=int(input())
    abc,d=divmod(abcd,10)
    ab,c=divmod(abc,10)
    a,b=divmod(ab,10)
    for o1 in [1,-1]:
        for o2 in [1, -1]:
            for o3 in [1, -1]:
                s=a+o1*b+o2*c+o3*d
                if s==7:
                    ans=str(a)+otos(o1)+str(b)+otos(o2)+str(c)+otos(o3)+str(d)+"=7"
                    print(ans)
                    break

main()

Submission status: Wrong Answer

Solution code:
n = str(input())
N = []
Y = []
for m in n:
    N.append(m)

for i in range(1<<3):
    Y = []
    tot = int(N[0])
    for j in range(3):
        if (i>>j)&1 == 1:
            tot += int(N[j+1])
            Y.append('+')
        else:
            tot -= int(N[j+1])
            Y.append('+')
    if tot == 7:
        ans = N[0]+Y[0]+N[1]+Y[1]+N[2]+Y[2]+N[3]+'=7'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
b_l = []
for i in range(8):
  b = bin(i)[2:]
  le = len(b)
  b_l.append((3 - le)*"0" + b)


    

s_l = [int(n[i]) for i in range(4)]
    
for b in b_l:
  ans = s_l[0]
  f = 0
  b_s_l = ["+" if b[i] == "0" else "-" for i in range(3)]
  for i in range(3):
    if b_s_l[i] == "+":
      ans += s_l[i+1]
    else:
      ans -= s_l[i+1]
  if ans == 7:
    print(str(s_l[0]) + b_s_l[0] + str(s_l[1]) + b_s_l[1] + str(s_l[2]) + 
          b_s_l[2] + str(s_l[3])) 
    break

Submission status: Wrong Answer

Solution code:
import operator
s = [int(i) for i in list(input())]

op = []
op.append( operator.add )
op.append( operator.sub )


for i in range(2) :
  for j in range(2) :
    for k in range(2) :

      r = op[i](s[0],s[1])

      r = op[j](r,s[2])

      r = op[k](r,s[3])

      if r == 7 :
        op1 = "+" if i == 0 else "-"
        op2 = "+" if j == 0 else "-"
        op3 = "+" if k == 0 else "-"
        print(str(s[0])+op1+str(s[1])+op2+str(s[2])+op3+str(s[3]))
        exit()

Submission status: Wrong Answer

Solution code:
s = input()
num_digits = len(s)


def dfs(index, formula, sum_number):
    print(formula)
    if index + 1 == num_digits:
        if sum_number == 7:
            print(formula + "=7")
            exit()
    else:
        dfs(index + 1, formula + "+" + s[index + 1], sum_number + int(s[index + 1]))
        dfs(index + 1, formula + "-" + s[index + 1], sum_number - int(s[index + 1]))


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

Submission status: Wrong Answer

Solution code:
s = input()
num_digits = len(s)


def dfs(index, formula, sum_number):
    if index + 1 == num_digits:
        if sum_number == 7:
            print(formula + "=7")
            exit()
    else:
        dfs(index + 1, formula + "+" + s[index + 1], sum_number + int(s[index + 1]))
        dfs(index + 1, formula + "-" + s[index + 1], sum_number - int(s[index + 1]))


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

Submission status: Wrong Answer

Solution code:
def examC():
    ABCD = S()
    loop = 2**3
    for i in range(loop):
        cur = int(ABCD[0])
        for j in range(3):
            if (i>>j)^1==1:
                cur += int(ABCD[j+1])
            else:
                cur -= int(ABCD[j+1])
        if cur==7:
            cur = i
            break
    ans = str(ABCD[0])
    for i in range(3):
        if (cur>>i)^ 1 == 1:
            ans += "+"
        else:
            ans += "-"
        ans += str(ABCD[i+1])
    ans += "=7"
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Wrong Answer

Solution code:
def examC():
    ABCD = S()
    loop = 2**3
    for i in range(loop):
        cur = int(ABCD[0])
        for j in range(3):
            if (i>>j)^1==1:
                cur += int(ABCD[j+1])
            else:
                cur -= int(ABCD[j+1])
        if cur==7:
            cur = i
            break
    ans = str(ABCD[0])
    for i in range(3):
        if cur^ 1 == 1:
            ans += "+"
        else:
            ans += "-"
        cur >>=1
        ans += str(ABCD[i+1])
    ans += "=7"
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
en = ["+", "-"]
for x in en:
  for y in en:
    for z in en:
      s = a + x + b + y + c + z + d
      if eval(s) == 7:
        print(s + "=7")
        break
      break
    break

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
en = ["+", "-"]
for x in en:
  for y in en:
    for z in en:
      s = a + x + b + y + c + z + d
      if eval(s) == 7:
        print(s + "=7")
  break

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
en = ["+", "-"]
for x in en:
  for y in en:
    for z in en:
      s = a + x + b + y + c + z + d
      if eval(s) == 7:
        print(s + "=7")
        break

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
en = ["+", "-"]
for x in en:
  for y in en:
    for z in en:
      s = a + x + b + y + c + z + d
      if eval(s) == 7:
        print(s)
        break

Submission status: Wrong Answer

Solution code:
import sys
s=input()
s=list(s)
for i in range(4):
  s[i]=int(s[i])

if s[0]+s[1]+s[2]+s[3]==7:
  print('s[0]+s[1]+s[2]+s[3]=7')
  sys.exit()
if s[0]+s[1]+s[2]-s[3]==7:
  print('s[0]+s[1]+s[2]-s[3]=7')
  sys.exit()
if s[0]+s[1]-s[2]+s[3]==7:
  print('s[0]+s[1]-s[2]+s[3]=7')
  sys.exit()
if s[0]-s[1]+s[2]+s[3]==7:
  print('s[0]-s[1]+s[2]+s[3]=7')
  sys.exit()
if s[0]-s[1]+s[2]-s[3]==7:
  print('s[0]-s[1]+s[2]-s[3]=7')
  sys.exit()
if s[0]-s[1]-s[2]+s[3]==7:
  print('s[0]-s[1]-s[2]+s[3]=7')
  sys.exit()
if s[0]+s[1]-s[2]-s[3]==7:
  print('s[0]+s[1]-s[2]-s[3]=7')
  sys.exit()
if s[0]-s[1]-s[2]-s[3]==7:
  print('s[0]-s[1]-s[2]-s[3]=7')
  sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
s=input()
s=list(s)
for i in range(4):
  s[i]=int(s[i])

if s[0]+s[1]+s[2]+s[3]==7:
  print('s[0]+s[1]+s[2]+s[3]=7')
  sys.exit()
elif s[0]+s[1]+s[2]-s[3]==7:
  print('s[0]+s[1]+s[2]-s[3]=7')
  sys.exit()
elif s[0]+s[1]-s[2]+s[3]==7:
  print('s[0]+s[1]-s[2]+s[3]=7')
  sys.exit()
elif s[0]-s[1]+s[2]+s[3]==7:
  print('s[0]-s[1]+s[2]+s[3]=7')
  sys.exit()
elif s[0]-s[1]+s[2]-s[3]==7:
  print('s[0]-s[1]+s[2]-s[3]=7')
  sys.exit()
elif s[0]-s[1]-s[2]+s[3]==7:
  print('s[0]-s[1]-s[2]+s[3]=7')
  sys.exit()
elif s[0]+s[1]-s[2]-s[3]==7:
  print('s[0]+s[1]-s[2]-s[3]=7')
  sys.exit()
elif s[0]-s[1]-s[2]-s[3]==7:
  print('s[0]-s[1]-s[2]-s[3]=7')
  sys.exit()

Submission status: Wrong Answer

Solution code:
s=input()
s=list(s)
for i in range(4):
  s[i]=int(s[i])

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

Submission status: Wrong Answer

Solution code:
s=list(str(input()))
for i in range(4):
  s[i]=int(s[i])

if s[0]+s[1]+s[2]+s[3]==7:
  print('s[0]+s[1]+s[2]+s[3]=7')
if s[0]+s[1]+s[2]-s[3]==7:
  print('s[0]+s[1]+s[2]-s[3]=7')
if s[0]+s[1]-s[2]+s[3]==7:
  print('s[0]+s[1]-s[2]+s[3]=7')
if s[0]-s[1]+s[2]+s[3]==7:
  print('s[0]-s[1]+s[2]+s[3]=7')
if s[0]-s[1]+s[2]-s[3]==7:
  print('s[0]-s[1]+s[2]-s[3]=7')
if s[0]-s[1]-s[2]+s[3]==7:
  print('s[0]-s[1]-s[2]+s[3]=7')
if s[0]+s[1]-s[2]-s[3]==7:
  print('s[0]+s[1]-s[2]-s[3]=7')
if s[0]-s[1]-s[2]-s[3]==7:
  print('s[0]-s[1]-s[2]-s[3]=7')

Submission status: Wrong Answer

Solution code:
s=list(input())
for i in range(4):
  s[i]=int(s[i])

if s[0]+s[1]+s[2]+s[3]==7:
  print('s[0]+s[1]+s[2]+s[3]=7')
if s[0]+s[1]+s[2]-s[3]==7:
  print('s[0]+s[1]+s[2]-s[3]=7')
if s[0]+s[1]-s[2]+s[3]==7:
  print('s[0]+s[1]-s[2]+s[3]=7')
if s[0]-s[1]+s[2]+s[3]==7:
  print('s[0]-s[1]+s[2]+s[3]=7')
if s[0]-s[1]+s[2]-s[3]==7:
  print('s[0]-s[1]+s[2]-s[3]=7')
if s[0]-s[1]-s[2]+s[3]==7:
  print('s[0]-s[1]-s[2]+s[3]=7')
if s[0]+s[1]-s[2]-s[3]==7:
  print('s[0]+s[1]-s[2]-s[3]=7')
if s[0]-s[1]-s[2]-s[3]==7:
  print('s[0]-s[1]-s[2]-s[3]=7')

Submission status: Wrong Answer

Solution code:
s=list(input())
for i in range(4):
  s[i]=int(s[i])

if s[0]+s[1]+s[2]+s[3]==7:
  print('s[0]+s[1]+s[2]+s[3]=7')
if s[0]+s[1]+s[2]-s[3]==7:
  print('s[0]+s[1]+s[2]-s[3]=7')
if s[0]+s[1]-s[2]+s[3]==7:
  print('s[0]+s[1]-s[2]+s[3]=7')
if s[0]-s[1]+s[2]+s[3]==7:
  print('s[0]-s[1]+s[2]+s[3]=7')
if s[0]-s[1]+s[2]-s[3]==7:
  print('s[0]-s[1]+s[2]-s[3]=7')
if s[0]-s[1]-s[2]+s[3]==7:
  print('s[0]-s[1]-s[2]+s[3]=7')
if s[0]+s[1]-s[2]-s[3]==7:
  print('s[0]+s[1]-s[2]-s[3]=7')
if s[0]-s[1]-s[2]-s[3]==7:
  print('s[0]-s[1]-s[2]-s[3]=7')

Submission status: Wrong Answer

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

F=["+","-"]

for x in range(2):
    for y in range(2):
        for z in range(2):
            if eval(A+F[x]+B+F[y]+C+F[z]+D)==7:
                print(A+F[x]+B+F[y]+C+F[z]+D+"=7")

Submission status: Wrong Answer

Solution code:
A,B,C,D = list(map(int,list(input())))
def plus(x):
    if x == 0:
        return '+'
    else:
        return '-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+(1-2*i)*B+(1-2*j)*C+(1-2*k)*D
            if ans == 7:
                print(str(A)+plus(i)+str(B)+plus(j)+str(C)+plus(k)+str(D)+'=7')
                break
        else:
            continue
        break

Submission status: Wrong Answer

Solution code:
a,b,c,d = input()
ls = ["+","+","+"]
p = 0
for i in range(3**2):
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

Submission status: Wrong Answer

Solution code:
n = list(input())
gaps = (len(n) - 1) * ["-"]
for i in range(2 ** len(gaps)):
    for j in range(len(gaps)):
        if (i>>j) & 1:
            gaps[len(gaps) - j - 1] = "+"
    formula = ""
    for nn, gap in zip(n, gaps + [""]):
        formula += (nn + gap)
    result = eval(formula)
    if result == 7:
        print(formula + "=7")
        quit()

Submission status: Wrong Answer

Solution code:
n = list(input())
gaps = (len(n) - 1) * ["-"]
for i in range(2 ** len(gaps)):
    for j in range(len(gaps)):
        if (i>>j) & 1:
            gaps[len(gaps) - j - 1] = "+"
    formula = ""
    for nn, gap in zip(n, gaps + [""]):
        formula += nn + gap
    result = eval(formula)
    if result == 7:
        print(formula + "=7")
        quit()

Submission status: Wrong Answer

Solution code:
s = list(input())

for i in range(2**3):
	res = int(s[0])
	m = []
	for j in range(3):
		if i>>j&1:
			res += int(s[j+1])
			m.append("+")
		else:
			res -= int(s[j+1])
			m.append("-")
	if res == 7:
		m.append("")
		break
		
for i in range(4):
	print(s[i] + m[i], end = "")
print()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ABCD = list(map(int, list(input())[: -1]))
t = [[] for _ in range(4)]
t[0].append((ABCD[0], ""))
for i in range(3):
  for j in range(len(t[i])):
    t[i + 1].append((t[i][j][0] + ABCD[i + 1], t[i][j][1] + "+"))
    t[i + 1].append((t[i][j][0] - ABCD[i - 1], t[i][j][1] + "-"))
#print(t)
for i in range(len(t[-1])):
  if t[-1][i][0] == 7:
    print(str(ABCD[0]) + t[-1][i][1][0] + str(ABCD[1]) + t[-1][i][1][1] + str(ABCD[2]) + t[-1][i][1][2] + str(ABCD[3]) + "=7")
    exit(0)

Submission status: Wrong Answer

Solution code:
ss=input()
s=[0]*4
for i in range(len(ss)):
  s[i]=int(ss[i])
dif=7-s[0]
ans=str(s[0])
for b in [s[1],-s[1]]:
  for c in [s[2],-s[2]]:
    for d in [s[3],-s[3]]:
      if b+c+d==dif:
        if b==s[1]:
          ans+="+"
        else:
          ans+="-"
        ans+=str(s[1])
        if c==s[2]:
          ans+="+"
        else:
          ans+="-"
        ans+=str(s[2])
        if d==s[3]:
          ans+="+"
        else:
          ans+="-"
        ans+=str(s[3])
print(ans+"=7")

Submission status: Wrong Answer

Solution code:
S = input()

ans = ""

def F(total,i):
  global ans
  if i == 4:
    if total == 7:
      return ans
  else:
    ans += "+"
    return F(total + int(S[i]),i + 1)
    ans += "-"
    return F(total - int(S[i]),i + 1)

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

A = S[0]  

for i in range(0,3):
  A = A + ans[i]
  A = A + S[i + 1]

A += "=7"

print(A)

Submission status: Wrong Answer

Solution code:
N = input()

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

Submission status: Wrong Answer

Solution code:
N = input()

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

Submission status: Wrong Answer

Solution code:
s=input()
a,b,c,d=s[0],s[1],s[2],s[3]
ans=int(a)
o=['+','-']
p=[1,int(-1)]
x,y,z='','',''
e,f,g=0,0,0
for i in range(2):
  e=int(b)*((-1)**i)
  ans+=e
  x=o[i]
  for j in range(2):
    f=int(c)*((-1)**j)
    ans+=f
    y=o[j]
    for k in range(2):
      g=int(d)*((-1)**k)
      ans+=g
      z=o[k]
      #print(a+x+b+y+c+z+d+'='+str(ans),int(a)+e+f+g)
      if ans==7:
        print(a+x+b+y+c+z+d+'=7')
        exit()
      ans=int(a)

Submission status: Wrong Answer

Solution code:
x = input()
s = [int(i) for i in list(str(x))]
a, b, c, d = s

sm = 0
for i in range(2):
	for j in range(2):
		for k in range(2):
			if(i == 0):
				b *= -1
			if(j == 0):
				c *= -1
			if(k == 0):
				d *= -1
			sm = a + b + c + d
			if(sm == 7):
				if(b >= 0):
					b = "+" + str(b)
				if(c >= 0):
					c = "+" + str(c)
				if(d >= 0):
					d = "+" + str(d)
				break
		else:
			continue
		break
	else:
		continue
	break
print (str(a) + str(b) + str(c) + str(d) + "=7")

Submission status: Wrong Answer

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

def dfs(i, f):

    if i == n-1:
        if eval(f)==7: 
            print(f+"=7")
            return True
        else: 
            return False
    else:
        dfs(i+1,f + "+" + s[i+1])
        dfs(i+1,f + "-" + s[i+1])
    
def main():
    if dfs(0,s[0]):
        pass

if __name__ == '__main__':
    main()

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])
lists = [A,B,C,D]
lists.sort(reverse=True)
ans = lists[0]
lists_2 = [lists[1],lists[2],lists[3]]
op_list = []
for i in lists_2:
    if ans < 7:
        ans += i
        op_list.append("+")
    else:
        ans -= i
        op_list.append("-")
print(str(lists[0]) + op_list[0] + str(lists[1]) + op_list[1] + str(lists[2]) + op_list[2] + str(lists[3]) + "=" + "7")

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])
lists = [A,B,C,D]
lists.sort(reverse=True)
ans = lists[0]
lists_2 = [lists[1],lists[2],lists[3]]
op_list = []
for i in lists_2:
    if ans < 7:
        ans += i
        op_list.append("+")
    else:
        ans -= i
        op_list.append("-")
print(str(lists[0]) + op_list[0] + str(lists[1]) + op_list[1] + str(lists[2]) + op_list[2] + str(lists[3]) + "=" + str(ans))