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:
ABCD = list(map(int, input()))
op ="+-"
for i in range(pow(2, 3)):
  v = i
  f = str(ABCD[j])
  for j in range(3):
    f += op[v%2] + ABCD[j]
    v //= 2
  if eval(f) == 7:
    print("{}=7", f)
    break

Submission status: Runtime Error

Solution code:
array = [int(i) for i in list(input())]
flag = False
fugou = ['+', '-']

for i in fugou:
	if i == '+':
		tmp = array[0] + array[1]
	else:
		tmp = array[0] - array[1]
	for j in fugou:
		if j == '+':
			tmp2 = tmp + array[2]
		else:
			tmp2 = tmp - array[2]
		for k in fugou:
			if k == '+':
				if tmp2 + array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3]))
							+ '=7')
					flag = True
					break
			else:
				if tmp2 - array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3])
							+ '=7')
					flag = True
					break
		if flag: break
	if flag: break

Submission status: Runtime Error

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 += (p_n + p_o)
    if eval(formula) == 7:
      print(formula + "=7")
      break

Submission status: Runtime Error

Solution code:
a, b, c, d = list(input())
a, b, c, d = int(a), int(b), int(c), int(d)
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'-str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'-str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'-str(d)+'=7')

Submission status: Runtime Error

Solution code:
a, b, c, d = list(input())
a, b, c, d = int(a), int(b), int(c), int(d)
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'-str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'-str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'-str(d)+'=7')

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

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int, '1222'.split())

if a + b + c + d == 7:
    print('{a}+{b}+{c}+{d}=7'.format(a,b,c,d))
elif a + b + c - d == 7:
    print('{a}+{b}+{c}-{d}=7'.format(a,b,c,d))
elif a + b - c + d == 7:
    print('{a}+{b}-{c}+{d}=7'.format(a,b,c,d))
elif a + b - c - d == 7:
    print('{a}+{b}-{c}-{d}=7'.format(a,b,c,d))
elif a - b + c + d == 7:    
    print('{a}-{b}+{c}+{d}=7'.format(a,b,c,d))
elif a - b + c - d == 7:       
    print('{a}-{b}+{c}-{d}=7'.format(a,b,c,d))
elif a - b - c + d == 7:     
    print('{a}-{b}-{c}+{d}=7'.format(a,b,c,d))
elif a - b - c - d == 7:    
    print('{a}-{b}-{c}-{d}=7'.format(a,b,c,d))

Submission status: Runtime Error

Solution code:
n = list(input().split())


for i in range(2 ** 3):
    i2 = bin(i)[2:].zfill(3)
    i3 = n[0]
    total = int(n[0])
    for j in range(3):
        if i2[j] == '1':
            # plus
            total += int(n[j+1])
            i3 += '+'
        else:
            # minus
            total -= int(n[j+1])
            i3 += '-'
        i3 += n[j+1]

    if total == 7:
        break

print(i3 + '=7')

Submission status: Runtime Error

Solution code:
arr = []
text = input()
for ch in text:
    arr.append(int(ch))


arr2 = sorted(arr)
arr2.reverse()

ope = []

def n2opeindex(n):
    for i, _n in enumerate(arr):
        if n == _n:
            return i
    return -1

        
count = 0
for i in arr2:
    if count == 0:
        count = i
        ope.append([i, "+"])
        continue
    if count >= 7:
        count = count - i
        ope.append([i, "-"])
    else:
        count = count + i
        ope.append([i, "+"])
result = str(arr[0])
for i in arr[1:]:
    opeindex = n2opeindex(i)
    result = result + ope[opeindex][1]
    del ope[opeindex]
    result = result + str(i)
result = result + "=7"
print(result)

Submission status: Runtime Error

Solution code:
arr = []
text = input()
for ch in text:
    arr.append(int(ch))


arr2 = sorted(arr)
arr2.reverse()

ope = []

def n2opeindex(n):
    for i, _n in enumerate(arr):
        if n == _n:
            return i
    return -1

        
count = 0
for i in arr2:
    if count == 0:
        count = i
        ope.append([i, "+"])
        continue
    if count >= 7:
        count = count - i
        ope.append([i, "-"])
    else:
        count = count + i
        ope.append([i, "+"])
result = str(arr[0])
for i in arr[1:]:
    opeindex = n2opeindex(i)
    result = result + ope[opeindex][1]
    del ope[opeindex]
    result = result + str(i)
print(result)

Submission status: Runtime Error

Solution code:
import sys, ast

def dfs(str_input,count = 1):
    if count == 7:
        if ast.literal_eval(str_input) == 7:
            sys.exit(str_input + "=7")
        else:
            return 0
    for i in ["+","-"]:
        dfs(str_input[:count] + i + str_input[count:], count = count + 2)

x = input()

dfs(x)

Submission status: Runtime Error

Solution code:
import sys, ast

def dfs(str_input,count = 1):
    if count == 7:                                                      #演算子を挿入完了
        if ast.literal_eval(str_input) == 7:
            sys.exit(str_input + "=7")
        else:       　　　　　　　　　　　　　　　　　　　　#和が7にならなかった場合は何もしない
            return 0
    for i in ["+","-"]:
        dfs(str_input[:count] + i + str_input[count:], count = count + 2)　　#演算子の挿入

x = input()

dfs(x)

Submission status: Runtime Error

Solution code:
OP = ['+','-']
ans = 0
for op1 in OP:
    for op2 in OP:
        for op3 in OP:
            if eval(abc[0]+op1+abc[1]+op2+abc[2]+op3+abc[3]) == 7:
                ans = abc[0]+op1+abc[1]+op2+abc[2]+op3+abc[3]
print(ans+'=7')

Submission status: Runtime Error

Solution code:
s=str(input())
n1=s[0]
n2=s[1]
n3=s[2]
n4=s[3]
sum1=0
sum2=0
sum3=0
ans=''
op=['+','-']
for i in range(2):
  if i == 0:
    sum1 = n1+n2
  else:
    sum1 = n1-n2
  for j in range(2):
    if j == 0:
      sum2 = sum1+n3
    else:
      sum2 = sum1-n3
    for k in range(2):
      if k == 0:
        sum3=sum2+n4
      else:
        sum3=sum2-n4
      if sum3==7:
        ans=str(n1)+op[i]+str(n2)+op[j]+str(n3)+op[k]+str(n4)+'=7'
print(ans)

Submission status: Runtime Error

Solution code:
N = input()
A, B, C, D = int(N[0]), int(N[1]), int(N[2]), int(N[3])
OP = ["+", "-"]

ANS = A
for op1 in OP:
    if ANS == 7:
        break
    ANS = A
    if op1 == "+":
        ANS = ANS + B
    else:
        ANS = ANS - B
    for op2 in OP:
        if ANS == 7:
            Break
        if op2 == "+":
            ANS = ANS + C
        else:
            ANS = ANS - C
        for op3 in OP:
            if op3 == "+":
                ANS = ANS + D
            else:
                ANS = ANS - D
            if ANS == 7:
                print("%d%s%d%s%d%s%d=7" % (A, op1, B, op2, C, op3, D))
                break

Submission status: Runtime Error

Solution code:
A,B,C,D = map(int,list(input()))
s = (sum([A,B,C,D])-7)//2
c = [1,1,1]
for a,n in enumerate([A,B,C,D]):
  if s == n:
    c[i] = -1
    s = 0
  else:
    for i in [1,-1]:
      for j in [1,-1]:
        for k in [1,-1]:
          if A+B*i+C*j+D*k == 7:
            c[0] = i
            c[1] = j
            c[2] = k
            s = 0
            break
print(str(A)+'{:+}{:+}{:+}'.format(B*c[0],C*c[1],D*c[2])+"=7")

Submission status: Runtime Error

Solution code:
import sys
a,b,c,d = input()
pm = ['+','-']
for pm1 in PM:
    for pm2 in PM:
        for pm3 in PM:
            ans = a+pm1+b+pm2+c+pm3+d
            if eval(ans) == 7:
                print(ans+'=7')
                sys.exit()

Submission status: Runtime Error

Solution code:
import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("=7")
	exit(0)

Submission status: Runtime Error

Solution code:
s = [int(i) for i in input()]
op = {'+':1, '-':-1}
for a in op:
  for b in op:
    for c in op:
      if s[0] + op['a'] * s[1] + op['b'] * s[2] + op['c'] * s[3] == 7:
        print(str(s[0]) + op['a'] + str(s[1]) + op['b'] + str(s[2]) + op['c'] + str(s[3]) + '=7')

Submission status: Runtime Error

Solution code:
N = [int(i) for i in input().split()] 

flag = ["","",""]

for i in range(1 << len(N)-1):
	print("i:", i)
	result = N[0]
	for j in range(len(N)-1):
		print("j:", j)
		if ((i >> j) & 1) == 1:
			result += N[j+1]
			flag[j] = "+"
		else:
			result -= N[j+1]
			flag[j] = "-"

	print("result:", result)

	if result == 7:
		break

print("%d%s%d%s%d%s%d=7" %(N[0],flag[0],N[1],flag[1],N[2],flag[2],N[3]))

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

nums = list(input())
nums = [int(i) for i in nums]

def make2digits(n):
    digits = []
    for i in range(3):
        if n % 2 == 1:
            digits.append(1)
        else:
            digits.append(0)
        n = n//2
    return digits

for i in range(8):
    count = nums[0]
    choices = make2digits(i)
    for j in range(len(choices)):
        if choices[j]==0:
            count = nums[j+1]
        else:
            count += nums[j+1]
    if count == 7:
        ans_choice = choices


plusminus = ["-","+"]
ans = ""
nums = [str(i) for i in nums]
for i in range(3):
    ans = ans + nums[i] + plusminus[ans_choice[i]]

ans = ans+nums[-1]+"=7"
print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,d = list(input())
a,b,c,d = int(a), int(b), int(c), int(d)
mark = {"+":1,"-":-1}
e = 0
for i, i_ in mark.items():
    for j, j_ in mark.items():
        for k, k_ in mark.items():
            if (e==0)&(a + i_ * b + c * j_ + d * k_ == 7):
                print(f"{a}{i}{b}{j}{c}{k}{d}=7")
                e = 1
                break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
A,B,C,D = map(int, input().split())
if A+B+C+D==7:
    print("A+B+C+D=7")
    sys.exit()
if A-B+C+D==7:
    print("A-B+C+D=7")
    sys.exit()
if A+B-C+D==7:
    print("A+B-C+D=7")
    sys.exit()
if A+B+C-D==7:
    print("A+B+C-D=7")
    sys.exit()
if A-B-C+D==7:
    print("A-B-C+D=7")
    sys.exit()
if A-B+C-D==7:
    print("A-B+C-D=7")
    sys.exit()
if A-B-C+D==7:
    print("A-B-C+D=7")
    sys.exit()
if A-B-C-D==7:
    print("A-B-C-D=7")
    sys.exit()

Submission status: Runtime Error

Solution code:
import sys
A,B,C,D = map(int, input().split())
if A+B+C+D==7:
    print("A+B+C+D==7")
    sys.exit()
if A-B+C+D==7:
    print("A-B+C+D==7")
    sys.exit()
if A+B-C+D==7:
    print("A+B-C+D==7")
    sys.exit()
if A+B+C-D==7:
    print("A+B+C-D==7")
    sys.exit()

if A-B-C+D==7:
    print("A-B-C+D==7")
    sys.exit()
if A-B+C-D==7:
    print("A-B+C-D==7")
    sys.exit()
if A-B-C+D==7:
    print("A-B-C+D==7")
    sys.exit()
if A-B-C-D==7:
    print("A-B-C-D==7")
    sys.exit()

Submission status: Runtime Error

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[j] = '+'
            
    formula = ''
    for a, b in zip(n, op + ['']):
        formula += (a + b)
    if eval(formula) == 7:
        print(formula + '=7')
        break

Submission status: Runtime Error

Solution code:
S=input()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def n_ary1(l,d): # リストl中の文字でd桁を全列挙(sorted)
    if d == 1:
        return(l)
    ll = n_ary1(l,d-1)
    lll = []
    for i in l:
        for j in ll:
            lll.append(i+j)
            #lll.append(int(i+j)) ## n進数の場合
    return(lll)
In = list(map(int,input().split()))
op = n_ary1([[0],[1]],3)

for i in op:
    s = In[0]
    for j in range(3):
        if i[j]:
            s += In[j+1]
        else:
            s -= In[j+1]
    if s == 7:
        ansl = i
        break


ans = str(In[0])
for i in range(3):
    if ansl[i] :
        ans = ans + '+' + str(In[i+1])
    else:
        ans = ans + '-' + str(In[i+1])
ans = ans + '=7'
print(ans)

Submission status: Runtime Error

Solution code:
A = input()
op = ["+", "-"]
for bit in range(1 << 3):
    ans = A[0]
    for i in range(3):
        ans += op[bit & (1 << i)]+A[i+1]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Submission status: Runtime Error

Solution code:
A = input()
op = ["+", "-"]
for bit in range(1 << 4):
    ans = A[0]
    for i in range(3):
        ans += op[bit & (1 << i)]+A[i+1]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Submission status: Runtime Error

Solution code:
n = int(input())
a = n // 1000
b = n // 100 - a * 10
c = n // 10 - a * 100 - b * 10
d = n - a * 1000 - b * 100 - c * 10
yet = True
if a+b+c+d==7 and yet:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    yet = False
if a+b+c-d==7 and yet:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    yet = False
if a+b-c+d==7 and yet:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    yet = False
if a+b-c-d==7 and yet:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    yet = False
if a-b+c+d==7 and yet:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    yet = False
if a-b+c-d==7 and yet:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    yet = False
if a-b-c+d==7 and yet:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    yet = False
if a-b-c-d==7 and yet:
    print(str(a)+'

Submission status: Runtime Error

Solution code:
line=str(input())
line=list(line)
a=line[0]
b=line[1]
c=line[2]
d=line[3]
o1='+'
o2='+'
o3='+'
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
print("{}{}{}{}{}{}{}=7".format(a,o1,b,o2,c,o3,d))

Submission status: Runtime Error

Solution code:
line=str(input())
line=list(line)
a,b,c,d=line
o1='+'
o2='+'
o3='+'
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
print("{}{}{}{}{}{}{}=7".format(a,o1,b,o2,c,o3,d))

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())
o1='+'
o2='+'
o3='+'
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
print("{}{}{}{}{}{}{}=7".format(a,o1,b,o2,c,o3,d))

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())
o1='+'
o2='+'
o3='+'
for x in (a+b,a-b):
  for y in (c,-c):
    for z in (d,-d):
      if x+y+z==7:
        if x==a-b:
          o1='-'
        if y==-c:
          o2='-'
        if z==-d:
          o3='-'
print("{}{}{}{}{}{}{}".format(a,o1,b,o2,c,o3,d))

Submission status: Runtime Error

Solution code:
abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans -= '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7', ans)
    break

Submission status: Runtime Error

Solution code:
 N = input()

 answer = ""

 for i in range(1 << 3):
     exp = N[0]
     for j in range(3):
         if i >> j & 1:
             exp += "+"
         else:
             exp += "-"
         exp += N[j + 1]
     if eval(exp) == 7:
         answer = exp
         break

 print(answer + "=7")

Submission status: Runtime Error

Solution code:
 N = input()

 for i in range(1 << 3):
     exp = N[0]
     for j in range(3):
         if i >> j & 1:
             exp += "+"
         else:
             exp += "-"
         exp += N[j + 1]
     if eval(exp) == 7:
         print(exp + "=7")
         break

Submission status: Runtime Error

Solution code:
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0
  	break
  for j in range(2):
    	if c!=0
      		break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

from itertools import product

def main():
    a, b, c, d = map(int, input())
    for x, y, z in product(("+", "-"), repeat=3):
        eq = f"a{x}b{y}c{z}d"
        val = eval(eq)
        if val == 7:
            print(f"{a}{x}{b}{y}{c}{z}{d}=7")
            return

main()

Submission status: Runtime Error

Solution code:
s=input()
l=["+","-"]
for i in range(1):
  for j in range(i):
    for p in range(1):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        break
print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")

Submission status: Runtime Error

Solution code:
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var inputLine string
	fmt.Scan(&inputLine)
	runeS := []rune(inputLine)
	var nums []int
	for _, c := range runeS {
		n, _ := strconv.Atoi(string(c))
		nums = append(nums, n)
	}

	var temp int
	var s string
	for i := 0; i < (1 << uint(len(nums)-1)); i++ {
		temp = nums[0]
		s = strconv.Itoa(nums[0])
		for j := 0; j < (len(nums) - 1); j++ {
			if (i>>uint(j))&1 == 1 {
				temp += nums[j+1]
				s += "+" + strconv.Itoa(nums[j+1])
			} else {
				temp -= nums[j+1]
				s += "-" + strconv.Itoa(nums[j+1])
			}
		}
		if temp == 7 {
			s += "=7"
			fmt.Println(s)
			break
		}
	}
}

Submission status: Runtime Error

Solution code:
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.sppend('-')
        flag = 1
        break
        
if flag == 1:
    print('{}{}{}{}{}{}{}{}'.format(A[0], B[0], A[1], B[1], A[2], B[2], A[3], '=7'))

Submission status: Runtime Error

Solution code:
a  = input()
x = int(a[0])
y = int(a[1])
z = int(a[2])
w = int(a[3])
o = ["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0 and j == 0 and k == 0:
                if x + y + z + w == 7: p = [i,j,k]
            elif i == 0 and j == 0 and k == 1:
                if x + y + z - w == 7: p = [i,j,k]
            elif i == 0 and j == 1 and k == 0:
                if x + y - z - w == 7: p = [i,j,k]
            elif i == 1 and j == 0 and k == 0:
                if x - y + z - w == 7: p = [i,j,k]
            elif i == 1 and j == 1 and k == 0:
                if x - y - z + w == 7: p = [i,j,k]
            elif i == 0 and j == 1 and k == 1:
                if x + y - z - w == 7: p = [i,j,k]
            elif i == 1 and j == 0 and k == 1:
                if x - y + z - w == 7: p = [i,j,k]
            elif i == 1 and j == 1 and k == 1:
                if x - y - z - w == 7: p = [i,j,k]
print(str(x)+o[p[0]]+str(y)+o[p[1]]+str(z)+str(o[p[2]])+str(w)+"=7")

Submission status: Runtime Error

Solution code:
A = input()
a,b,c,d = A[0],A[1],A[2],A[3]
e1 = a+b+c+d
e2 = a+b+c-d
e3 = a+b-c+d
e4 = a+b-c-d
e5 = a-b+c+d
e6 = a-b+c-d
e7 = a-b-c+d
e8 = a-b+c-d
if eval(e1) == 7:
    print(e1)
elif eval(e2) == 7:
    print(e2)
elif eval(e3) == 7:
    print(e3)
elif eval(e4) == 7:
    print(e4)
elif eval(e5) == 7:
    print(e5)
elif eval(e6) == 7:
    print(e6)
elif eval(e7) == 7:
    print(e7)
elif eval(e8) == 7:
    print(e8)

Submission status: Runtime Error

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

op = ['+','-']

for a,b,c in itertools.product(op,op,op):
  x = A + op1 + B + op2 + C + op3 + D
  if(eval(x) == 7):
    print(x + "=7")
    break

Submission status: Runtime Error

Solution code:
abcd = str(input())
n = 3
x1 = '+'
x2 = '+'
x3 = '+'
for bits in range(1 << n):
    for i in range(n):
        if (bits >> i & 1) == 1:
            if i == 0:
                x1 = '-'
            if i == 1:
                x2 = '-'
            if i == 2:
                x3 = '-'
    check1 = abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3]
    check2 = eval(abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3])
    if check2 == 7:
        ans = check1
print(ans+'=7')

Submission status: Runtime Error

Solution code:
import sys
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print(f'{A}{sgn[0]}{B}{sgn[1]}{C}{sgn[2]}{D}=7')
        sys.exit()

Submission status: Runtime Error

Solution code:
def cal(sgn, n1, n2):
    return n1 + n2 if sgn == '+' else n1 - n2


A, B, C, D = map(int, list(input()))
sgns = []
for bit in range(1<<3):
    tmp = ['+'] * 3
    for i in range(3):
        if ((bit>>i) & 1) == 1:
            tmp[i] = '-'
    sgns.append(tmp)

for sgn in sgns:
    if cal(sgn[2], cal(sgn[1], cal(sgn[0], A, B), C), D) == 7:
        print(f'{A}{sgn[0]}{B}{sgn[1]}{C}{sgn[2]}{D}=7')
        exit()

Submission status: Runtime Error

Solution code:
import sys

def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        # it is beautiful!
        string += op
        string =+ num
    string += "=7"
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0):
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) # careful code
            stack.append(l + ["-"])

    print(result)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        # it is beautiful!
        string += op
        string =+ num
    string += "="
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0){
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) # careful code
            stack.append(l + ["-"])
    }
    print(result)

Submission status: Runtime Error

Solution code:
def check(in_list,stack):
    i = 0
    suma = int(in_list[0])
    result = in_list[0]
    while i < len(stack):
        if stack[i] == "-":
            suma =suma - int(in_list[i+1])
            result = result + "-" + in_list[i+1]
        else:
            suma += int(in_list[i+1])
            result = result + "+" + in_list[i+1]
    return suma,result

in_list = input().split()
l = len(in_list)
a = in_list[0]
suma = 0

stack = [a]
i = 0
visited = []
while stack:
    l2 = len(stack)
    if l2 == l:
        suma,result = check(in_list,stack)
        if suma == 7:
            print (result)
        else:
            stack.pop()
    a = stack[l-1]
    i = stack.index(a)
    s1 = "+"+in_list[i+1]
    s2 = "-"+in_list[i+1]
    if s1 in visited and s2 in visited:
        stack.pop()
    elif s1 in visited :
        stack.append()
        visited.append(s2)
    else:
        visited.append(s1)

Submission status: Runtime Error

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

a,b,c,d=map(int,input())
s=[1,-1]
f=['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+b*s[i]+c*s[j]+d*s[k]==7:
                    print(str(a)+f[i]+str(b)+f[j]+str(c)+f[k]+str(d)+'=7')
                    exit()

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

if __name__=='__main__':
    str = input()
    signs_comb = list(itertools.combinations_with_replacement([1, -1], 3))
    for signs in signs_comb:
        sum = int(str[0])
        for i in range(3):
            sum += signs[i] * int(str[i + 1])
        if sum == 7:
            sign_char = ['+' if i==1 else '-' for i in signs]
            break
    exp = str[0] + sign_char[0] + str[1] + sign_char[1] + str[2] + sign_char[2] + str[3] + '=7'
    print(exp)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

if __name__=='__main__':
    str = input()
    signs_comb = list(itertools.combinations_with_replacement([1, -1], 3))
    for signs in signs_comb:
        sum = int(str[0])
	for i in range(3):
            sum += signs[i] * int(str[i + 1])
        if sum == 7:
            sign_char = ['+' if i==1 else '-' for i in signs]
            break
    exp = str[0] + sign_char[0] + str[1] + sign_char[1] + str[2] + sign_char[2] + str[3] + '=7'
    print(exp)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

if __name__=='__main__':
    str = input()
    signs_comb = list(itertools.combinations_with_replacement([1, -1], 3))
    for signs in signs_comb:
        sum = int(str[0])
	for i in range(3):
            sum += signs[i] * int(str[i + 1])
        if sum == 7:
	    sign_char = ['+' if i==1 else '-' for i in signs]
            break
    exp = str[0] + sign_char[0] + str[1] + sign_char[1] + str[2] + sign_char[2] + str[3] + '=7'
    print(exp)

Submission status: Runtime Error

Solution code:
a, b, c, d = list(map(int, input().split()))
ops = ['+', '-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      s = str(a)+op1+str(b)+op2+str(c)+op3+str(d)
      res = eval(s)
      if res == 7:
        print(s+'=7')
        break

Submission status: Runtime Error

Solution code:
i=input()

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])

if a+b+c+d==7:
    x="+"
    y="+"
    z="+"
elif a+b+c-d==7:
    x="+"
    y="+"
    z="-"
elif a+b-c+d==7:
    x="+"
    y="-"
    z="+"    
elif a-b+c+d==7:
    x="-"
    y="+"
    z="+"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b+c-d==7:
    x="-"
    y="+"
    z="-"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b-c-d==7:
    x="-"
    y="-"
    z="-"
    
    
print(a,end="")
print(x,end="")
print(b,end="")
print(y,end="")
print(c,end="")
print(z,end="")
print(d,end="")
print("=7")