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:
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")
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")
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")
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:
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")
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:
A,B,C,D = map(int,input().split())
op =['+','-']
ops = []
for a in op:
  for b in op:
    for c in op:
        ops.append(a + b + c)
        
for op in ops:
  S = "{1}{2}{3}{4}{5}{6}{7}".format(A,op[0],B,op[1],C,op[2],D)
  if eval(S) == 7:
    print("{}=7".format(S))
    break

Submission status: Runtime Error

Solution code:
s=input()
x1=""
s1=0
s1=int(s[0]) +int(s[1])+int(s[2])+int(s[3]+"="+"7")
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
if s1==7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"="+"7")
elif a+b+c-d==7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]+"="+"7")
elif a+b-c+d==7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]+"="+"7")
elif a-b+c+d==7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]+"="+"7")
elif a+b-c-d==7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"="+"7")
elif a-b+c-d==7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"="+"7")
elif a-b-c+d==7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]+"="+"7")
elif a-b-c-d==7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"="+"7")

Submission status: Runtime Error

Solution code:
import sys
a,b,c,d= input()
for i in range(2**(len(op)-1)):
    op = ["+"]*3
    for j in range(len(op)-1):
        if (i >> j) & 1 == 1:
            op[j] = "-"
    if eval(a+op[0]+b+op[1]+c+op[2]+d) == 7:
        print(a+op[0]+b+op[1]+c+op[2]+d+'=7')
        sys.exit()

Submission status: Runtime Error

Solution code:
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+S[i+1])
        make7(i+1, f+"-"+S[i+1], sum-S[i+1])


S = input()
n = len(S)

make7(0, S[0], S[0])

Submission status: Runtime Error

Solution code:
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+S[i+1])
        make7(i+1, f+"-"+S[i+1], sum+S[i+1])


S = input()
n = len(S)

make7(0, S[0], 0)

Submission status: Runtime Error

Solution code:
def make7(i, f):
    if i == 3:
        if sum(map(int, f.split("+"))) == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1])
        make7(i+1, f+"-"+S[i+1])


S = input()
n = len(S)

make7(0, S[0])

Submission status: Runtime Error

Solution code:
n = 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[-1-j] = '+'
      formula = ''
  for p_n, p_o in zip(n, op + ['']):#(1,+),(2,+),(3,+),(4,'')
    formula += (p_n + p_o)
  if eval(formula) == 7:#'1+2+3+4'
    print(formula + '=7')
    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[-1-j] = '+'
    formula = ''
    for p_n, p_o in zip(n, op + ['']):#(1,+),(2,+),(3,+),(4,'')
      formula += (p_n + p_o)
    if eval(formula) == 7:#'1+2+3+4'
      print(formula + '=7')
      break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
x=list(input())

for lst in itertools.product(['+','-'],repeat=3)
  sum=int(x[0])
  for i in range(3):
    if lst[i]=='+':
      sum+=int(x[i+1])
    else:
      sum-=int(x[i+1])
  if sum==7:
    print(x[0]+lst[0]+x[1]+lst[1]+x[2]+lst[2]+x[3]+'=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])
for i in 1:
    
    if A + B + C + D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        exit()
    if A - B + C + D == 7:
        print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        exit()
    if A + B - C + D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        exit()
    if A + B + C - D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        exit()
    if A - B - C + D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        exit()
    if A - B + C - D == 7:
        print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        exit()
    if A + B - C - D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        exit()
    if A - B - C - D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(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[3])
if A + B + C + D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
    break
if A - B + C + D == 7:
    print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
    break
if A + B - C + D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
    break
if A + B + C - D == 7:
    print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
    break
if A - B - C + D == 7:
    print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
    break
if A - B + C - D == 7:
    print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
    break
if A + B - C - D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
    break
if A - B - C - D == 7:
    print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
    break

Submission status: Runtime Error

Solution code:
if A + B - C - D == 7:
    print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
    exit()

Submission status: Runtime Error

Solution code:

ABCD = str(input())
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]

if int(A) + int(B) + int(C) + int(D) == 7:
    print(A + "+" + B + "+" + C + "+" + D +"=7")
    break
if int(A) - int(B) + int(C) + int(D) == 7:
    print(A + "-" + B + "+" + C + "+" + D +"=7")
    break
if int(A) + int(B) - int(C) + int(D) == 7:
    print(A + "+" + B + "-" + C + "+" + D +"=7")
    break
if int(A) - int(B) - int(C) + int(D) == 7:
    print(A + "-" + B + "-" + C + "+" + D +"=7")
    break
if int(A) + int(B) + int(C) - int(D) == 7:
    print(A + "+" + B + "+" + C + "-" + D +"=7")
    break
if int(A) - int(B) + int(C) - int(D) == 7:
    print(A + "-" + B + "+" + C + "-" + D +"=7")
    break
if int(A) + int(B) - int(C) - int(D) == 7:
    print(A + "+" + B + "-" + C + "-" + D +"=7")
    break
if int(A) - int(B) - int(C) - int(D) == 7:
    print(A + "-" + B + "-" + C + "-" + D +"=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])

flag = [0]*3
tmp = 0
for i in range(8):
  flag[0]=(i>>2)&1
  flag[1]=(i>>1)&1
  flag[2]=(i)&1
  
  tmp = A +(-1)**flag[0]*B +(-1)**flag[0]*C +(-1)**flag[0]*D
  if tmp==7:
    ans=s[0]
    for j in range(3):
      if flag[i]:
        ans+="-"+s[i+1]
      else:
        ans+="+"+s[i+1]
    ans+="=7"
    print(ans)
    break

Submission status: Runtime Error

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

import itertools

A=(1,-1)

def c(x):
	if x==1:
		return '+'
	else:
		return '-'

for v in itertools.product(A,repeat=3):
	s=a+b*v[0]+c*v[1]+d*v[2]
	if s==7:
		print(L[0]+c(v[0])+L[1]+c(v[1])+L[2]+c(v[2])+L[3]+'=7')
		exit()

Submission status: Runtime Error

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

import itertools

A=(1,-1)

def c(x):
	if x==1:
		return '+'
	else:
		return '-'

for v in itertools.product(A,repeat=3):
	s=a+b*v[0]+c*v[1]+d*v[2]
	if s==7:
		print(L[0]+c(v[0])+L[1]+c(v[1])+L[2]+c(v[2])+L[3]+'=7')
		exit()

Submission status: Runtime Error

Solution code:
L=input()
a=int(L[0])
b=int(L[1])
c=int(L[2])
d=int(L[3])
def s(i,x):
	if i==0:
		return x
	else:
		return -x

def c(x):
	if x==0:
		return '+'
	else:
		return '-'

for i in range(2):
	for j in range(2):
		for k in range(2):
			p=a+s(i,b)+s(j,c)+s(k,d)
			if p==7:
				ans=L[0]+c(i)+L[1]+c(j)+L[2]+c(k)+L[3]
				print(ans)
				exit()

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = ""
    nums = list(map(int, list(input())))
    for i in range(8):
        ts = sum(nums)
        ops = ['+']*3
        for j in range(3):
            if i>>j&1:
                ts -= nums[j+1]*2
                ops[j]='-'
        if ts == 7:
            for i in range(3):
                ans += str(nums[i])+ops[i]
            ans += str(nums[3])+"=7"
            break
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from itertools import product
s = list(input())
n = len(s)

pattern = list(product(['+', ''], repeat=n-1))

for i in range(2 ** (n-1)):
    formula = s[0]
    for j, k in zip(pattern[i], s[1:]):
        formula += (j + k)
    if eval(formula) == 7:
        print("{}=7".format(formula))
        break

Submission status: Runtime Error

Solution code:
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  string s;
  cin >> s;
  vector<int> a;
  forn(i, len(s)) a.pb(s[i]-'0');
  for (auto i: {0, 1}){
    for (auto j: {0, 1}) {
      for (auto k: {0, 1}){
        int x = a[0];
        string ans = "";
        ans += s[0];
        if (i%2) {
          x -= a[1];
          ans += '-';
        } else {
          x += a[1];
          ans += '+';
        }
        ans += s[1];

        if (j%2) {
          x -= a[2];
          ans += '-';
        } else {
          x += a[2];
          ans += '+';
        }
        ans += s[2];

        if (k%2) {
          x -= a[3];
          ans += '-';
        } else {
          x += a[3];
          ans += '+';
        }
        ans += s[3];
        
        if (x == 7){
          cout << ans << "=7";
          return;
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

k (k-1) (k-1)

2 6 3
4 6 5
6 6 7
7 7 7

*/

Submission status: Runtime Error

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

for i in range(2**3):
    op = ['-']*3
    for j in range(3):
        if (i >> j) &1:
            op[3 - 1 - j] ='+'
    if eval(A +op[0] +B+ op[1]+C +op[2] +D) ==7:
        print(A +op[0] +B+ op[1]+C +op[2] +D+'=7')
        break

Submission status: Runtime Error

Solution code:
def a(t,i):
    if i==l:
        if eval(t)==7:
            print(t+'=7')
            exit()
    a(t+'+'+s[i+1],i+1)
    a(t+'-'+s[i+1],i+1)

s = input()
l = len(s)-1
a(s[0],0)

Submission status: Runtime Error

Solution code:
def a(t,i):
    if i==l and eval(t)==7:
        print(t+'=7')
        exit()
    a(t+'+'+s[i+1],i+1)
    a(t+'-'+s[i+1],i+1)

s = input()
l = len(s)-1
a(s[0],0)

Submission status: Runtime Error

Solution code:
def a(t,i):
    if i==l and eval(t)==7:
        print(t+'=7')
        exit()
    a(t+'+'+s[i+1],i+1)
    a(t+'-'+s[i+1],i+1)

s = int(input())
l = len(s)-1
a(s[0],0)

Submission status: Runtime Error

Solution code:
n = 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:
import sys
from io import StringIO
import unittest


n = 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 = map(lambda x: int(x), list(input()))

cnt = 0
def get_str(a):
    if a >= 0:
        s = "+{}".format(a)
    else:
        s = "{}".format(a)
    return s

for i in range(1 << 4 - 1):
    if (i >> 3) % 2 == 0:
        a = -a
    if (i >> 2) % 2 == 0:
        b = -b
    if (i >> 1) % 2 == 0:
        c = -c
    if (i >> 0) % 2 == 0:
        d = -d

    if a + b + c + d  == 7:
        s = ""
        s += get_str(a)
        s += get_str(b)
        s += get_str(c)
        s += get_str(d)
        s += "=7"
        if a >= 0:
            print(s[1::])
        else:

Submission status: Runtime Error

Solution code:
#変数: S, num, formula
    
S = input()
num = len(S) - 1

for i in range(2**num):
    op=["-"]*num
    for j in range(num):
        if (i>>j)&1:
            op[num-j-1]="+"
            
    formula=""
    for op_S,op_num in zip(S,num+[""]):
        formula += op_S + op_num

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

Submission status: Runtime Error

Solution code:
S = input()
num = len(S) - 1

for i in range(2**num):
    op=["-"]
    for j in range(num):
        if (i>>j)&1:
            op[num-j-1]="+"
            
    formula=""
    for op_S,op_num in zip(S,num+[""]):
        formula += op_S + op_num

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

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
def a(t,i):
    if i = l - 1:
        if eval(t)==7:
            print(t+"=7")
            exit()
        return
    a(t+"+"+N[i+1],i+1)
    a(t+"-"+N[i+1],i+1)

N = input()
l = len(N)
a(N[0],0)

Submission status: Runtime Error

Solution code:
N = input()
op_cnt = len(N) - 1 #隙間の個数
for i in range(2 ** op_cnt):
     op = ['-'] * op_cnt #とりあえず演算子は-を3つとしておく
     for j in range(op_cnt):
          if((i >> j) | 1):

Submission status: Runtime Error

Solution code:
def a(t,i):
    if i = l - 1:
        if eval(t==7):
            print(t+"=7")
            exit()
        return
    a(t+"+"+N[i+1],i+1)
    a(t+"-"+N[i+1],i+1)

N = input()
l = len(N)
a(N[0],0)

Submission status: Runtime Error

Solution code:
nums = list(map(int, list(input())))

flag = 7
while flag >= 0:
    S = []
    total = nums[0]
    for i, bit in enumerate(bin(flag)[2:], 1):
        if int(bit):
            total += nums[i]
            S.append("+")
        else:
            total -= nums[i]
            S.append("-")
    if total == 7:
        break
    
    flag -= 1

print(f"{nums[0]}{S[0]}{nums[1]}{S[1]}{nums[2]}{S[2]}{nums[3]}=7")

Submission status: Runtime Error

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


def check():
    for i in [1, 0]:
        total = A
        if i:
            total += B
        else:
            total -= B
        for j in [1, 0]:
            if j:
                total += C
            else:
                total -= C
            for k in [1, 0]:
                if k:
                    total += D
                else:
                    total -= D
    
                if total == 7:
                    return [i, j, k]

S = []
for s in check():
    if s:
        S.append("+")
    else:
        S.append("-")

print(f"{A}{S[0]}{B}{S[1]}{C}{S[2]}{D}=7")

Submission status: Runtime Error

Solution code:
a = int(input())
a = list(str(a))

sign = "+-"

for i in range(2):  #1つめの正負
 for j in range(2):  #2つ目の正負
  for k in range(2):  #3つ目の正負
    if eval(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3] ) == 7:
     print(str(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3])+'=7')

Submission status: Runtime Error

Solution code:
nums = input() 
N = 3
for i in range(2**N):
    equation = ''
    for j in range(N+1):
        equation += nums[j]
        if ((i >> j) & 1):
            equation += '+'
        else:
            equation += '-'
    if eval(equation) == 7:
        print(equation + '=7')
        exit()

Submission status: Runtime Error

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

for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if (i>>j)&1:
            op[l - j - 1] = "+" #なぜ i - j - 1 ではなく、l - j - 1なのか、決まっている数から引いたものが知りたい
    formula = ""
    for op1,op2 in zip(n,op+[""]): #式の文字列を作るループ
        formula += op1 + op2
    if eval(formula)==7:
        print(formula + "=7")
        break

Submission status: Runtime Error

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

for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if (i>>j)&1:
            op[l - j - 1] = "+" #なぜ i - j - 1 ではなく、l - j - 1なのか、決まっている数から引いたものが知りたい
    formula = ""
    for op1,op2 in zip(n,op): #式の文字列を作るループ
        formula += op1 + op2
    if eval(formula)==7:
        print(formula + "=7")
        break

Submission status: Runtime Error

Solution code:
n = input()
l = len(n)-1

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

    formula = ""
    for op_num,op_l in zip(n,op+[""]):
        formula += op_num + op_l
    if eval(formula)==7:
        print(formula+"=7")
        break

Submission status: Runtime Error

Solution code:

n = input()
l = len(n)-1

for i in range(2**l):
    op = ["-"]*l
    for j in range(l):
        if (i>>j) &1:
            op[i-j-1]="+"
    formula = ""
    for op_num,op_l in zip(n,op+[""]):
        formula += op_num+op_l
    if eval(formula)==7:
       print(formula+"=7")
       break

Submission status: Runtime Error

Solution code:

n = input()
l = len(n)-1

for i in range(2**l):
    op = ["-"]*l
    for j in range(l):
        if (i>>j) &1:
            op[i-j-1]="+"
    formula = ""
    for op_num,op_l in zip(n,op+[""]):
        formula += op_num+op_l
        if eval(formula)==7:
            print(formula+"=7")
            break

Submission status: Runtime Error

Solution code:

n = input()
l = len(n)-1

for i in range(2**l):
    op = ["-"]*l
    for j in range(l):
        if (i>>j) &1:
            op[i-j-1]="+"
    formula = ""
    for op_num,op_l in zip(n,op+""):
        formula += op_num + op_l
        if eval(formula)==7:
            print(formula+"=7")
            break

Submission status: Runtime Error

Solution code:

n = input()
l = len(n)-1

for i in range(2**l):
    op = ["-"]*l
    for j in range(l):
        if (i>>j) &1:
            op[i-j-1]="+"
    formula = ""
    for op_num,op_l in zip(n,op):
        formula += op_num+op_l
        if eval(formula)==7:
            print(formula+"=7")
            break

Submission status: Runtime Error

Solution code:

n = input()
l = len(n)-1

for i in range(2**l):
    op = ["-"]*l
    for j in range(l):
        if (i>>j) &1:
            op[i-j-1]="+"
    formula = ""
    for op_num,op_l in zip(n,op):
        formula = op_num+op_l
        if eval(formula)==7:
            print(formula+"=7")
            break

Submission status: Runtime Error

Solution code:

def a(s,i):
    if i = l-1:
        if eval(s)==7:
            print(s+"=7")
            exit()
        return
    a(s+"+"+N[i+1],i+1)
    a(s+"-"+N[i+1],i+1)

N = input()
l = len(N)

a(N[0],0)

Submission status: Runtime Error

Solution code:
def a(s,i):
    if i = l-1:
        if eval(s)==7:
            return s+"=7"
        return
    a(s+"+"+N[i+1],i+1)
    a(s+"-"+N[i+1],i+1)

N = input()
l = len(N)

print(a(N[0],0))

Submission status: Runtime Error

Solution code:

def a(s,i):
    if i = l-1:
        if eval(s)==7:
            print(s+"=7")
            exit()
        return
    a(s+"+"+N[i],i+1)
    a(s+"-"+N[i],i+1)

N = input()
l = len(N)

a(N[0],0)

Submission status: Runtime Error

Solution code:

def a(s,i):
    if i = l-1:
        if eval(s)==7:
            return s+"=7"
        return
    a(s+"+"+N[i],i+1)
    a(s+"-"+N[i],i+1)

N = input()
l = len(N)


print(a(N[0],0)

Submission status: Runtime Error

Solution code:

def a(s,i):
    if i = l-1:
        if eval(s)==7:
            return s
    return a(s+"+"+N[i],i+1) + a(s+"-"+N[i],i+1)

N = input()
l = len(N)

print(a(N[0],0) + "=7")

Submission status: Runtime Error

Solution code:
def dump(a,b,c):
    if a == operator.add:
        a = '+'
    else:
        a = '-'
    if b == operator.add:
        b = '+'
    else:
        b = '-'
    if c == operator.add:
        c = '+'
    else:
        c = '-'
    print(vals[0] + a + vals[1] + b + vals[2] + c + vals[3] + '=7')

for a in (operator.add, operator.sub):
    for b in (operator.add, operator.sub):
        for c in (operator.add, operator.sub):
            if c(b(a(nums[0], nums[1]), nums[2]), nums[3]) == 7:
                dump(a, b, c)
                exit(0)

Submission status: Runtime Error

Solution code:
A=list(input())

for i in range(4):
  A[i]=int(A[i])


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

elif A[0]+A[1]-A[2]+A[3]==7:
  print(A[0]+A[1]-[2]+A[3]=7)

elif A[0]+A[1]+A[2]-A[3]==7:
  print(A[0]+A[1]+[2]-A[3]=7)
  
elif A[0]-A[1]+A[2]-A[3]==7:
  print(A[0]-A[1]+[2]-A[3]=7)
    
elif A[0]-A[1]-A[2]+A[3]==7:
  print(A[0]-A[1]+[2]-A[3]=7)
  
elif A[0]+A[1]-A[2]-A[3]==7:
  print(A[0]-A[1]+[2]-A[3]=7)
  
elif A[0]-A[1]-A[2]-A[3]==7:
  print(A[0]-A[1]-[2]-A[3]=7)

Submission status: Runtime Error

Solution code:
N = int(input())
L0=2
L1=0
if N == 1
　　return L0
elif N == 2:
    return L1
else:
    for i in range(N-2):
            L0, L1 = L1, L0+L1
        return L1
        print()

Submission status: Runtime Error

Solution code:
A,B,C,D=input()
for i in range(2**3):
	op = ["+","+","+"]
    for j in range(len(op)):
      if (i>>j) & 1:
        op[j]="-"
        




def main():
    A, B, C, D = input()
    for i in range(2**3):
        op = ['+', '+', '+']
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break

    main()

Submission status: Runtime Error

Solution code:
    lst = [int(a) for a in input()]
    for bit in range(1 << len(lst)):
        sum = 0
        op_lst = []
        for i in range(len(lst)):
            if bit & (1 << i):
                sum += lst[i]
                op_lst.append('+')
            else:
                sum -= lst[i]
                op_lst.append('-')
        if sum == 7:
            print(lst[0], op_lst[1], lst[1], op_lst[2], lst[2], op_lst[3], lst[3], '=7', sep='')
            break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, c, d = list(input())
for q in range(1, 3):
    ao = ("+" if q % 2 else "-")
    for w in range(1, 3):
        bo = ("+" if w % 2 else "-")
        for e in range(1, 3):
            if eval(a + ao + b + bo + c + ("+" if e % 2 else "-") + d) == 7:
                print(f'{a}{ao}{b}{bo}{c}{("+" if e%2else"-")}{d}=7')
                exit(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools import product
a=list(map(str,input().split()))

for b in product(["+","-"],repeat=3):
  if(eval(a[0]+b[0]+a[1]+b[1]+a[2]+b[2]+a[3])==7):
    print(str(a[0]+b[0]+a[1]+b[1]+a[2]+b[2]+a[3]=7))
    break:

Submission status: Runtime Error

Solution code:
n = [int(c) for c in input()]
for i in range(2 ** 3):
    os = format(i, "03b").replace("1", "+").replace("0", "-")
    temp = n[0]
    for i, c in enumerate(os):
        num = n[i + 1]
        temp += num if c == "+" else -num
    if temp == 7:
        ans = "{0}{4}{1}{5}{2}{6}{3}=7".format(*n, *os)
        break
print(ans)

Submission status: Runtime Error

Solution code:
A, *BCD = map(int, input())
st_a = str(A)
for bit in range(1 << 3):
    formula = st_a
    tmp = A
    for i in range(3):
        n = BCD[i]
        if bit >> i & 1:
            tmp += n
            formula += '+'
        else:
            tmp -= n
            formula += '-'
        formula += str(n)
    if tmp == 7:
        print(f'{formula}=7')
        break

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int, iput().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))