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: Runtime Error

Solution code:
n=input().split()
a=int(n[0][0])
b=int(n[0][1])
c=int(n[0][2])
d=int(n[0][3])
if a+b+c+d==7:
  print(a+b+c+d=7)
if a+b+c-d==7:
  print(a+b+c-d=7)
if a+b-c+d==7:
  print(a+b-c+d=7)
if a-b+c+d==7:
  print(a-b+c+d=7)
if a+b-c-d==7:
  print(a+b-c-d=7)
if a-b+c-d==7:
  print(a-b+c-d=7)
if a-b-c+d==7:
  print(a-b-c+d=7)
if a-b-c-d==7:
  print(a-b-c-d=7)

Submission status: Runtime Error

Solution code:
n=input().split()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])
if a+b+c+d==7:
  print('a+b+c+d=7')
if a+b+c-d==7:
  print('a+b+c-d=7')
if a+b-c+d==7:
  print('a+b-c+d=7')
if a-b+c+d==7:
  print('a-b+c+d=7')
if a+b-c-d==7:
  print('a+b-c-d=7')
if a-b+c-d==7:
  print('a-b+c-d=7')
if a-b-c+d==7:
  print('a-b-c+d=7')
if a-b-c-d==7:
  print('a-b-c-d=7')

Submission status: Runtime Error

Solution code:
n=input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])
if a+b+c+d==7:
  print(a+b+c+d=7)
if a+b+c-d==7:
  print(a+b+c-d)
if a+b-c+d==7:
  print(a+b-c+d)
if a-b+c+d==7:
  print(a-b+c+d)
if a+b-c-d==7:
  print(a+b-c-d)
if a-b+c-d==7:
  print(a-b+c-d)
if a-b-c+d==7:
  print(a-b-c+d)
if a-b-c-d==7:
  print(a-b-c-d)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())
if a+b+c+d==7:
  print(a+b+c+d=7)
if a+b+c-d==7:
  print(a+b+c-d)
if a+b-c+d==7:
  print(a+b-c+d)
if a-b+c+d==7:
  print(a-b+c+d)
if a+b-c-d==7:
  print(a+b-c-d)
if a-b+c-d==7:
  print(a-b+c-d)
if a-b-c+d==7:
  print(a-b-c+d)
if a-b-c-d==7:
  print(a-b-c-d)

Submission status: Runtime Error

Solution code:
def main():
    li = [int(i) for i in input()]
    t = li[1:]
    op = ["+", "+", "+"]
    t_sum = sum(t)
    if t_sum == 7:
        print("{}+{}+{}+{}=7".format(t[0], t[1], t[2], t[3]))
    else:
        for i in range(3):
            if t_sum - 2*t[i] == 7:
                op[i] = "-"
                print("{}{}{}{}{}{}{}=7".format(li[0], op[0], li[1], op[1], li[2], op[2], li[3]))
                return
            elif t_sum - 2*t[i] > 7:
                for j in range(1, 3):
                    if t_sum - (t[i] + t[i-j])*2 == 7:
                        op[i] = "-"
                        op[i-j] = "-"
                        print("{}{}{}{}{}{}{}=7".format(li[0], op[0], li[1], op[1], li[2], op[2], li[3]))
                        return

main()

Submission status: Runtime Error

Solution code:
s = input()
S = [0]*len(s)
for i in range(len(s)):
    S[i] = int(s[i])
# 0:-, 1:+
for i in range(2**len(op)):
    op = [0]*(len(S) - 1)
    for j in range(len(op)):
        if (i >> j & 1):
            op[j] = 1
    tmp = S[0]
    for j in range(len(op)):
        if op[j] == 0:
            tmp -= S[j+1]
        else:
            tmp += S[j+1]
    if tmp == 7:
        ans = op[:]
ans_str = s[0]
for i in range(len(S)-1):
    if ans[i] == 0:
        ans_str = ans_str + "-"
    else:
        ans_str = ans_str + "+"
    ans_str = ans_str + s[i+1]
ans_str = ans_str + "=7"
print(ans_str)

Submission status: Runtime Error

Solution code:
def conv(c): return '+' if c==1 else '-'
def main():
	num = [int(c) for c in input()]
	choices = [-1,1]
    for a in choices:
		for b in choices:
			for c in choices:
				if num[0]+num[1]*a+num[2]*b+num[3]*c==7:
					print("{}{}{}{}{}{}{}=7".format(num[0],conv(a),num[1],conv(b),num[2],conv(c),num[3]))
                    return
main()

Submission status: Runtime Error

Solution code:
n_str = input()

op_count = len(n) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Runtime Error

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(f'{a}+{b}+{c}+{d}=7')
elif a+b+c-d==7:
  print(f'{a}+{b}+{c}-{d}=7')
elif a+b-c+d==7:
  print(f'{a}+{b}-{c}+{d}=7')
elif a-b+c+d==7:
  print(f'{a}-{b}+{c}+{d}=7')
elif a+b-c-d==7:
  print(f'{a}+{b}-{c}-{d}=7')
elif a-b+c-d==7:
  print(f'{a}-{b}+{c}-{d}=7')
elif a-b-c+d==7:
  print(f'{a}-{b}-{c}+{d}=7')
elif a-b-c-d==7:
  print(f'{a}-{b}-{c}-{d}=7')

Submission status: Runtime Error

Solution code:
s = input()
def dfs(i,f,sum):
  if i == 3:
    if sum == 7:
      print(f + "=7")
      exit()
  dfs(i+1,f + "+" + s[i+1],sum+int(s[i+1]))
  dfs(i+1,f + "-" + s[i+1],sum-int(s[i+1]))
dfs(0,s[0],int(s[0]))

Submission status: Runtime Error

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
op = ["+","-"]
def pc(x,y,op):
    if op == "+":
        return x + y
    elif op == "-":
        return x - y
li = []
ope = []
ans = 0
for i in op:
    ans = pc(a,b,i)
    for j in op:
        ans = pc(ans,c,j)
        for k in op:
            ans = pc(ans,d,k)
            li.append(ans)
            ope.append(str(a)+i+str(b)+j+str(c)+k+str(d)+"=7")
print(ope[li.index(7)])

Submission status: Runtime Error

Solution code:
S = input()


for i in range(2**3):
    formula = ""

    for j in range(4):
        formula += S[j]
        if (i >> j) & 1:
            formula += "+"
        else:
            formula += "-"

    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Runtime Error

Solution code:

#print(x)
y = [int(c) for c in x]
#print(y)
a = y[0]
b = y[1]
c = y[2]
d = y[3]
if a+b+c+d == 7:
  print("a+b+c+d=",a+b+c+d,sep='')
  exit()
if a+b+c-d == 7:
  print("a+b+c-d=",a+b+c-d,sep='')
  exit()
if a+b-c+d == 7:
  print("a+b-c+d=",a+b-c+d,sep='')
  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: Runtime Error

Solution code:
abcd=[int(i) for i in input()]
sums=sum(abcd)
dif=sums-7
op =['+', '+', '+']
if sums==7:
  pass
elif sums == 11:
  indx = abcd.index(2)
  op[indx-1] = '-'
elif 18 >= dif > 11:
  indx = abcd.index(dif/2)
  op[indx-1] = '-'
elif dif > 18:
  indxs = [i for i, x in enumerate(abcd) if x == dif/4]
  for i, x in enumerate(abcd):
    if x == dif/4:
	    op[i-1] = '-'
  
print('{}{}{}{}{}{}{}=7'.format(abcd[0], op[0], abcd[1], op[1], abcd[2], op[2], abcd[3]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = list(input())
def search(a, b, c, d):
  if a+b+c+d == 7:
    print(a '+' b '+'c '+' d '=' 7)
    
search(1, 2, 2, 2)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう
is_ok = False

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - c
            if work_3 == 7:
                is_ok = True
                op_list = [op1, op2, op3]
                break
        if is_ok:
            break
    if is_ok:
        break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc079/tasks/abc079_c
# C - Train Ticket

a, b, c, d = list(input().split()[0])
a, b, c, d = [int(x) for x in [a, b, c, d]]

# 2 ** 3通りなので全探索でいけそう

for op1 in [True, False]:
    work_1 = a + b if op1 else a - b
    for op2 in [True, False]:
        work_2 = work_1 + c if op2 else work_1 - c
        for op3 in [True, False]:
            work_3 = work_2 + d if op3 else work_2 - c
            if work_3 == 7:
                op_list = [op1, op2, op3]
                break

op_list = ['+' if op else '-' for op in op_list]
ans = str(a) + op_list[0] + str(b) + op_list[1] + str(c) + op_list[2] + str(d) + '=7'
print(ans)

Submission status: Runtime Error

Solution code:
A = [int(v) for v in input()]

for i in range(2):
  total = A[0]
  if i == 0:
    total += A[1]
  else:
    total -= A[1]
  for j in range(2):
    if j == 0:
      total += A[2]
    else:
      total -= A[2]
    for k in range(2):
      if k == 0:
        total += A[3]
      else:
        total -= A[3]
      if total == 7:
        print(A[0], end='')
        if i == 0:
          print('+{}'.format(A[1]), end='')
        else:
          print('-{}'.format(A[1]), end='')
        if j == 0:
          print('+{}'.format(A[2]), end='')
        else:
          print('-{}'.format(A[2]), end='')
        if k == 0:
          print('+{}=7'.format(A[3]))
        else:
          print('-{}=7'.format(A[3]))
        return

Submission status: Runtime Error

Solution code:
from typing import *

a, b, c, d = list(input())

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()

Submission status: Runtime Error

Solution code:
a, b, c, d = input().split()

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()

Submission status: Runtime Error

Solution code:
i = int(input())
lst = []
while i > 0:
    lst.append(i%10)
    i //= 10 
lst.reverse()
a=lst[0]
b=lst[1]
c=lst[2]
d=lst[3]
sa=str(a)
sb=str(b)
sc=str(c)
sd=str(d)

if(a+b+c+d==7):
    print(sa+"+"+sb+"+"+sc+"+"+sd+"=7")
elif (a+b+c-d==7):
    print(sa+"+"+sb+"+"+sc+"-"+sd+"=7")
elif (a+b-c+d==7):
    print(sa+"+"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c+d==7):
    print(sa+"-"+sb+"+"+sc+"+"+sd+"=7")
elif(a-b-c+d==7):
    print(sa+"-"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c-d==7):
    print(sa+"-"+sb+"+"+sc+"-"+sd+"=7")
elif(a+b-c-d==7):
    print(sa+"+"+sb+"-"+sc+"-"+sd+"=7")
elif(a-b-c-d==7):
    print(sa+"-"+sb+"-"+sc+"-"+sd+"=7")

Submission status: Runtime Error

Solution code:
i = int(input())
lst = []
while i > 0:
    lst.append(i%10)
    i //= 10 
lst.reverse()
a=lst[0]
b=lst[1]
c=lst[2]
d=lst[3]
sa=str(a)
sb=str(b)
sc=str(c)
sd=str(d)

if(a+b+c+d==7):
    print(sa+"+"+sb+"+"+sc+"+"+sd+"=7")
elif (a+b+c-d==7):
    print(sa+"+"+sb+"+"+sc+"-"+sd+"=7")
elif (a+b-c+d==7):
    print(sa+"+"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c+d==7):
    print(sa+"-"+sb+"+"+sc+"+"+sd+"=7")
elif(a-b-c+d==7):
    print(sa+"-"+sb+"-"+sc+"+"+sd+"=7")
elif(a-b+c-d==7):
    print(sa+"-"+sb+"+"+sc+"-"+sd+"=7")
elif(a+b-c-d==7):
    print(sa+"+"+sb+"-"+sc+"-"+sd+"=7")
elif(a-b-c-d==7):
    print(sa+"-"+sb+"-"+sc+"-"+sd+"=7")
else:
  print('none')

Submission status: Runtime Error

Solution code:
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=A+op1+B+op2+C+op3+D
      if eval(ans)==7:
        print('{}=7'.format(ans))
        exit()
      else:
        pass

Submission status: Runtime Error

Solution code:
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=A+op1+B+op2+C+op3+D
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input().split())
opes = ['-', '+']
for op1 in opes:
  for op2 in opes:
    for op3 in opes:
      result = 0
      if op1 == '-':
        result += A-B
      else:
        result += A+B
      if op2 == '-':
        result -= C
      else:
        result += C
      if op3 == '-':
        result -= D
      else:
        result += D
      if result == 7:
        print(str(A)+ope1+str(B)+ope2+str(C)+ope3+str(D))
        exit()

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input().split())
opes = ['-', '+']
for op1 in range(2):
  for op2 in range(2):
    for op3 in range(2):
      result = 0
      if op1 == '-':
        result += A-B
      else:
        result += A+B
      if op2 == '-':
        result -= C
      else:
        result += C
      if op3 == '-':
        result -= D
      else:
        result += D
      if result == 7:
        print(str(A)+ope1+str(B)+ope2+str(C)+ope3+str(D))
        exit()

Submission status: Runtime Error

Solution code:
def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval('{}{}{}{}{}{}{}'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                )) == 7:
                    return '{}{}{}{}{}{}{}=7'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                    )
 
 S = input()
print(solve(S))

Submission status: Runtime Error

Solution code:
def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval(
                        S[0]+ a+ S[1]+ b+ S[2]+ c+ S[3]
                ) == 7:
                    return S[0]+ a+ S[1]+ b+ S[2]+ c+ S[3]+ '=7'
                       
                    
 
 S = input()
solve(S)

Submission status: Runtime Error

Solution code:
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]') == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break
 
S = input()
print(solve(S))

Submission status: Runtime Error

Solution code:
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]) == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break

S = input()
print(solve(S))

Submission status: Runtime Error

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(str(a)+"+"str(b)+"+"str(c)+"+"+str(d)+"=7")
  break
elif a+b+c-d==7:
  print(str(a)+"+"str(b)+"+"str(c)+"-"+str(d)+"=7")
  break
elif a+b-c+d==7:
  print(str(a)+"+"str(b)+"-"str(c)+"+"+str(d)+"=7")
  break
elif a+b-c-d==7:
  print(str(a)+"+"str(b)+"-"str(c)+"-"+str(d)+"=7")
  break
elif a-b+c+d==7:
  print(str(a)+"-"str(b)+"+"str(c)+"+"+str(d)+"=7")
  break
elif a-b+c-d==7:
  print(str(a)+"-"str(b)+"+"str(c)+"-"+str(d)+"=7")
  break
elif a-b-c+d==7:
  print(str(a)+"-"str(b)+"-"str(c)+"+"+str(d)+"=7")
  break
elif a-b-c-d==7:
  print(str(a)+"-"str(b)+"-"str(c)+"-"+str(d)+"=7")
  break

Submission status: Runtime Error

Solution code:
A, B, C, D = [int(i) for i in list(input())]

ans = 0
ans = f"{A}+{B}+{C}+{D}=7" if A+B+C+D==7 else ans
ans = f"{A}+{B}+{C}-{D}=7" if A+B+C-D==7 else ans
ans = f"{A}+{B}-{C}+{D}=7" if A+B-C+D==7 else ans
ans = f"{A}+{B}-{C}-{D}=7" if A+B-C-D==7 else ans
ans = f"{A}-{B}+{C}+{D}=7" if A-B+C+D==7 else ans
ans = f"{A}-{B}+{C}-{D}=7" if A-B+C-D==7 else ans
ans = f"{A}-{B}-{C}+{D}=7" if A-B-C+D==7 else ans
ans = f"{A}-{B}-{C}-{D}=7" if A-B-C-D==7 else ans

print(ans)

Submission status: Runtime Error

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

op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      if eval("A {} B {} C {} D".format(i, j, k)) == 7:
        print("{}{}{}{}{}{}{}{}{}".format(A, i, B, j, C, k, D))
        exit()

Submission status: Runtime Error

Solution code:
import numpy as np

N = np.array([int(el) for el in list(input())])

A = np.array([[1,1,1,1],
             [1,-1,1,1],[1,1,-1,1],[1,1,1,-1],
             [1,-1,-1,1],[1,-1,1,-1],[1,1,-1,-1],
             [1,-1,-1,-1]])

B = np.matmul(A, N)

def result(B):
    if B[0] == 7:
        print("{}+{}+{}+{}=7".format(N[0],N[1],N[2],N[3]))
        return
    if B[1] == 7:
        print("{}-{}+{}+{}=7".format(N[0],N[1],N[2],N[3]))
        return
    if B[2] == 7:
        print("{}+{}-{}+{}=7".format(N[0],N[1],N[2],N[3])) 
        return
    if B[3] == 7:
        print("{}+{}-{}+{}=7".format(N[0],N[1],N[2],N[3]))
        return
    if B[4] == 7:
        print("{}+{}+{}-{}=7".format(N[0],N[1],N[2],N[3]))
        return
    if B[5] == 7:
        print("{}-{}-{}+{}=7".format(N[0],N[1],N[2],N[3]))
        return
    if B[6] == 7:
        print("{}-{}+{}-{}=7".format(N[0],N[1],N[2],N[3]))
        return
    if B[7] == 7:
        print("{}+{}-{}-{}=7".format(N[0],N[1],N[2],N[3]))
        return

result(B)

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input())
sign = "+-"
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+"=7")

Submission status: Runtime Error

Solution code:
A, B, C, D = input()
for p in itertools.product(['+', '-'], repeat = 3):
    equ = A + p[0] + B + p[1] + C + p[2] + D
    
    if(eval(equ) == 7):
        print(equ + '=7')
        break

Submission status: Runtime Error

Solution code:
n = 3
t=[]
for i in range(1<<n):
    ans = int(s[0])
    k=1
    for j in range(n):
        if 1&(i>>j):
            ans += int(s[k:(j+2)])
            t.append("+")
        else: 
            ans -= int(s[k:(j+2)]) 
            t.append("-")
        k=j+2
    if ans==7:
        print(s[0]+t[0]+s[1]+t[1]+s[2]+t[2]+s[3]+"=7")
        break;
    ans = int(s[0])
    t=[]
print(ans)

Submission status: Runtime Error

Solution code:
a, b, c, d = input()
o = "+-"
for i in range(2 ** 3):
    s = a + o[i & 1] + b + o[i & 2] + c + o[i & 4] + d
    if eval(s) == 7:
        print(s + "=7")
        break

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import operator
import itertools

def op(op_str):
    funcs = {
            "+":operator.add,
            "-":operator.sub
            }
    return funcs[op_str]

def solve(A,B,C,D):
    for o in itertools.product(["+","-"], repeat = 3):
        ret = op(o[0])(A,B)
        ret = op(o[1])(C,ret)
        ret = op(o[2])(D,ret)
        if ret == 7:
            print(f"{A}{o[0]}{B}{o[1]}{C}{o[2]}{D}=7")
            return


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    L = [int(c) for c in S]
    
    solve(*L)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import operator
import itertools

def op(op_str):
    funcs = {
            "+":operator.add,
            "-":operator.sub
            }
    return funcs[op_str]

def solve(A,B,C,D):
    for o in itertools.product(["+","-"], repeat = 3):
        ret = op(o[0])(A,B)
        ret = op(o[1])(C,ret)
        ret = op(o[2])(D,ret)
        if ret == 7:
            print(f"{A}{o[0]}{B}{o[1]}{C}{o[2]}{D}=7")


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    L = [int(c) for c in S]
    
    solve(*L)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
abcd = int(input())
A,B,C,D = abcd[0],abcd[1],abcd[2]abcd[3]
if A + B + C + D == 7:
  print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif A + B + C - D == 7:
  print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif A + B - C + D == 7:
  print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif A + B - C - D == 7:
  print('{}+{}-{}-{}=7'.format(A, B, C, D))
elif A - B + C + D == 7:
  print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif A - B + C - D == 7:
  print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif A - B - C + D == 7:
  print('{}-{}-{}+{}=7'.format(A, B, C, D))
else:
  print('{}-{}-{}-{}=7'.format(A, B, C, D))

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input().split())
if A + B + C + D == 7:
  print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif A + B + C - D == 7:
  print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif A + B - C + D == 7:
  print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif A + B - C - D == 7:
  print('{}+{}-{}-{}=7'.format(A, B, C, D))
elif A - B + C + D == 7:
  print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif A - B + C - D == 7:
  print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif A - B - C + D == 7:
  print('{}-{}-{}+{}=7'.format(A, B, C, D))
else:
  print('{}-{}-{}-{}=7'.format(A, B, C, D))

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, raw_input().split())
if A + B + C + D == 7:
  print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif A + B + C - D == 7:
  print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif A + B - C + D == 7:
  print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif A + B - C - D == 7:
  print('{}+{}-{}-{}=7'.format(A, B, C, D))
elif A - B + C + D == 7:
  print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif A - B + C - D == 7:
  print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif A - B - C + D == 7:
  print('{}-{}-{}+{}=7'.format(A, B, C, D))
elif A - B - C - D == 7:
  print('{}-{}-{}-{}=7'.format(A, B, C, D))

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input().split())
if A + B + C + D == 7:
  print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif A + B + C - D == 7:
  print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif A + B - C + D == 7:
  print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif A + B - C - D == 7:
  print('{}+{}-{}-{}=7'.format(A, B, C, D))
elif A - B + C + D == 7:
  print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif A - B + C - D == 7:
  print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif A - B - C + D == 7:
  print('{}-{}-{}+{}=7'.format(A, B, C, D))
elif A - B - C - D == 7:
  print('{}-{}-{}-{}=7'.format(A, B, C, D))

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int,input().split())
if A + B + C + D == 7;
  print('{}+{}+{}+{}=7'.format(A, B, C, D))
elif A + B + C - D == 7;
  print('{}+{}+{}-{}=7'.format(A, B, C, D))
elif A + B - C + D == 7;
  print('{}+{}-{}+{}=7'.format(A, B, C, D))
elif A + B - C - D == 7;
  print('{}+{}-{}-{}=7'.format(A, B, C, D))
elif A - B + C + D == 7;
  print('{}-{}+{}+{}=7'.format(A, B, C, D))
elif A - B + C - D == 7;
  print('{}-{}+{}-{}=7'.format(A, B, C, D))
elif A - B - C + D == 7;
  print('{}-{}-{}+{}=7'.format(A, B, C, D))
elif A - B - C - D == 7;
  print('{}-{}-{}-{}=7'.format(A, B, C, D))

Submission status: Runtime Error

Solution code:
def main():
    A, B, C, D = list(map(int, list(input().strip())))

    for op1 in [-1, 1]:
        for op2 in [-1, 1]:
            for op3 in [-1, 1]:
                if A + (op1 * B) + (op2 * C) + (op3 * D) == 7:
                    print(f'{A}{"+" if op1 == 1 else "-"}{B}{"+" if op2 == 1 else "-"}{C}{"+" if op3 == 1 else "-"}{D}=7')
                    return 0

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

for op1 in [-1, 1]:
    for op2 in [-1, 1]:
        for op3 in [-1, 1]:
            if A + (op1 * B) + (op2 * C) + (op3 * D) == 7:
                print(f'{A}{"+" if op1 == 1 else "-"}{B}{"+" if op2 == 1 else "-"}{C}{"+" if op3 == 1 else "-"}{D}=7')
                exit()

Submission status: Runtime Error

Solution code:
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[-2])
d = int(abcd[-1])
if (a-b-c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a-b+c+d) == 7:
    print(f'{a}-{b}+{c}+{d}=7')
    exit()
if (a+b+c+d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a+b-c+d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a+b+c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a+b-c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a-b+c-d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()
if (a-b-c+d) == 7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()

Submission status: Runtime Error

Solution code:
lst = list(map(int, input()))
n = len(lst) - 1
op_lst = ["+", "-"]
for i in range(2**n):
    op = ["-"] * 3
    for j in range(n):
        if ((i >> j) & 1):
            op[n-j-1] = op_lst[0]
    formula = ""
    for num,opp in zip(lst, op + [""]):
        formula += (num + opp)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Runtime Error

Solution code:
lst = list(map(int, input()))
n = len(lst) - 1
op_lst = ["+", "-"]
for i in range(2**n):
    op = ["-"] * 3
    for j in range(n):
        if ((i >> j) & 1):
            op[n-j-1] = op_lst[0]
    formula = ""
    for num,opp in zip(lst, op + [""]):
        formula += [num + opp]
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Runtime Error

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

op = ["+", "-"]
for op1 in op:
    for op2 in op:
        for op3 in op:
            val = a
            if op1 == "+":
                val += b
            else:
                val -= b

            if op2 == "+":
                val += c
            else:
                val -= c

            if op3 == "+":
                val += d
            else:
                val -= d

            if val==7:
                print("{}{}{}{}{}{}{}=7".format(a,op1,b,op2,c,op3,d))
                return

Submission status: Runtime Error

Solution code:
import sys

S = input()
c = 0


op = len(S) - 1  # すき間の個数

for i in range(2 ** op):
  T = ""
  for j in range(op_cnt):
    T += S[j]
    if ((i >> j) & 1):
      T += "+"
    else:
      T += "-"
  T += S[op_cnt]
  if eval(T) == 7:
    print(T+"=7")
    sys.exit()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

abcd = int(input())
a, b, c, d = str(abcd)
a = int(a);b = int(b);c = int(c);d = int(d)
if a+b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'+'+d+'=7'
elif a+b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'-'+d+'=7'
elif a+b-c-d == 7:
     a = str(a);b = str(b);c = str(c);d = str(d)
     ans = a+'+'+b+'-'+c+'-'+d+'=7'
elif a+b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'-'+c+'+'+d+'=7'
elif a-b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'+'+d+'=7'
elif a-b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'-'+d+'=7'
elif a-b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'+'+d+'=7'
else:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'-'+d+'=7'
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

a, b, c, d = input()
ans = 0
a = int(a);b = int(b);c = int(c);d = int(d)
if a+b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'+'+d+'=7'
elif a+b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'-'+d+'=7'
elif a+b-c-d == 7:
     a = str(a);b = str(b);c = str(c);d = str(d)
     ans = a+'+'+b+'-'+c+'-'+d+'=7'
elif a+b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'-'+c+'+'+d+'=7'
elif a-b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'+'+d+'=7'
elif a-b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'-'+d+'=7'
elif a-b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'+'+d+'=7'
else:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'-'+d+'=7'
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

a, b, c, d = input()
a = int(a);b = int(b);c = int(c);d = int(d)
if a+b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'+'+d+'=7'
elif a+b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'+'+c+'-'+d+'=7'
elif a+b-c-d == 7:
     a = str(a);b = str(b);c = str(c);d = str(d)
     ans = a+'+'+b+'-'+c+'-'+d+'=7'
elif a+b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'+'+b+'-'+c+'+'+d+'=7'
elif a-b+c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'+'+d+'=7'
elif a-b+c-d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'+'+c+'-'+d+'=7'
elif a-b-c+d == 7:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'+'+d+'=7'
else:
    a = str(a);b = str(b);c = str(c);d = str(d)
    ans = a+'-'+b+'-'+c+'-'+d+'=7'
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product as p
A,B,C,D=input();o="+-"
for x in map("".join,p(A,o,B,o,C,o,D)):if eval(x) == 7:print(x+"=7");break

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
ans = ''
if a + b + c + d == 7:
    ans = '{}+{}+{}+{}=7'
elif a - b + c + d == 7:
    ans = '{}-{}+{}+{}=7'
elif a + b - c + d == 7:
    ans = '{}+{}-{}+{}=7'
elif a + b + c - d == 7:
    ans = '{}+{}+{}-{}=7'
elif a - b - c + d == 7:
    ans = '{}-{}-{}+{}=7'
elif a + b - c - d == 7:
    ans = '{}+{}-{}-{}=7'
elif a - b + c - d == 7:
    ans = '{}-{}+{}-{}=7'
elif a - b - c - d == 7:
    ans = '{}-{}-{}-{}=7'
    
print(ans.format(a, b, c, d))