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:
a,b,c,d=map(int,input().split())
if a+b+c+d==7:
    print(a,"+",b,"+",c,"+",d,"=",7,sep="")
elif a+b+c-d==7:
    print(a,"+",b,"+",c,"-",d,"=",7,sep="")
elif a+b-c+d==7:
    print(a,"+",b,"-",c,"+",d,"=",7,sep="")
elif a+b-c-d==7:
    print(a,"+",b,"-",c,"-",d,"=",7,sep="")
elif a-b+c+d==7:
    print(a,"-",b,"+",c,"+",d,"=",7,sep="")
elif a-b+c-d==7:
    print(a,"-",b,"+",c,"-",d,"=",7,sep="")
elif a-b-c+d==7:
    print(a,"-",b,"-",c,"+",d,"=",7,sep="")
elif a-b-c-d==7:
    print(a,"-",b,"-",c,"-",d,"=",7,sep="")

Submission status: Runtime Error

Solution code:
a,b,c,d=list(input())
op=lambda i,a:"+" if i&a else "-"
for i in range(8):
  s=a+op(i&1)+e+op(i&2)+c+op(i&4)+d
  if eval(s)==7:print(s+"=7");exit()

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <cstdio>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    if (a - b - c - d == 7)
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
    else if (a - b - c + d == 7)
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    else if (a - b + c - d == 7)
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    else if (a - b + c + d == 7)
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    else if (a + b - c - d == 7)
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    else if (a + b - c + d == 7)
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    else if (a + b + c - d == 7)
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    else if (a + b + c + d == 7)
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
}

Submission status: Runtime Error

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

def judge(i, remaining, kigou):
    if i==4 and remaining==0:
        return True, kigou
    elif i==4 and remaining!=0:
        return False ,kigou
    else:
        temp_plus = remaining - kippu[i]
        temp_minus = remaining + kippu[i]
        kigou_plus = kigou + ['+'+str(kippu[i])]
        kigou_minus = kigou + ['-'+str(kippu[i])]
        
        judge_p_result, kigou_p_result = judge(i+1, temp_plus, kigou_plus)
        if judge_p_result:
            return judge_p_result, kigou_p_result
        
        judge_m_result, kigou_m_result = judge(i+1, temp_minus, kigou_minus)
        if judge_m_result:
            return judge_m_result, kigou_m_result

i=1
remaining=7-kippu[0]
kigou=[str(1)]
result, kigou = judge(i,remaining,kigou)
if result:
    print(''.join(kigou) + '=7')

Submission status: Runtime Error

Solution code:
S = tuple((input()))
S = [int(s) for s in S]

flag=0
for i in [0,1]:
    if flag==1:
        break
    for j in [0,1]:
        if flag==1:
            break
        for k in [0,1]:
            value = S[0]
            if i==0:
                value+=S[1]
            else:
                value-=S[1]
            if j==0:
                value+=S[2]
            else:
                value-=S[2]
            if j==0:
                value+=S[3]
            else:
                value-=S[3]
            if value==7:
                flag=1
                x = i
                y = j
                z = k
            if flag==1:
                break
if x==0:
    a = "+"
else:
    a = "-"
if y==0:
    b = "+"
else:
    b = "-"
if z==0:
    c = "+"
else:
    c = "-"

print("{}{}{}{}{}{}{}=7".format(S[0], a, S[1], b, S[2], c, S[3]))

Submission status: Runtime Error

Solution code:
from itertools import product
s=input()
for b in list(product(["+","-"],repeat=3)):
    ans=s[0]+b[0]+s[1]+b[1]+s[2]+b[2]+s[3]
    if evel(ans)==7:
        print(ans+"7")
        break

Submission status: Runtime Error

Solution code:
from itertools import product
s=input()
for b in list(product["+","-"],repeat=3):
    ans=s[0]+b[0]+s[1]+b[1]+s[2]+b[2]+s[3]
    if evel(ans)==7:
        print(ans+"7")
        break

Submission status: Runtime Error

Solution code:
nums = [n for n in input()]
ope = ["+", "-"]
for b in range(2 ** 3):
    temp = nums[0]
    for i in range(3):
        temp += ope[b & (1 << i)] + nums[i + 1]
    if eval(temp) == 7:
        print(temp+"=7")
        break

Submission status: Runtime Error

Solution code:
nums = [n for n in input()]
ope = ["+", "-"]
for b in range(2 ** 3):
    temp = nums[0]
    for i in range(3):
        temp += f"{ope[b & (1 << i)]}{nums[i + 1]}"
    if eval(temp) == 7:
        print(temp+"=7")
        break

Submission status: Runtime Error

Solution code:
nums = [n for n in input()]
ope = ["+", "-"]
for b in range(2 ** 3):
    temp = nums[0]
    for i in range(3):
        temp += f"{ope[b & (1 << i)]}{nums[i + 1]}"
    if eval(temp) == 7:
        print(temp)
        break

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')
else:
  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(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')
else:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Submission status: Runtime Error

Solution code:
def dfs(i, f, sum, s):
    if i == 3:
        if sum == 7:
            print(f+"=7")
            exit()

    dfs(i+1, f+"-"+s[i+1], sum - int(s[i+1]), s)
    dfs(i+1, f+"+"+s[i+1], sum + int(s[i+1]), s)

def main():
    s = input()

    dfs(0, s[0], int(s[0]), s)
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
Z = []
for s in input():
  Z.append(int(s))

def dfs(index, value, ops):
  if index == 4:
    if value == 7:
      print(f"{Z[0]}{ops[0]}{Z[1]}{ops[1]}{Z[2]}{ops[2]}{Z[3]}=7")
      exit()
    return
  dfs(index + 1, value + Z[index], ops + ["+"])
  dfs(index + 1, value - Z[index], ops + ["-"])

dfs(1, Z[0], [])

Submission status: Runtime Error

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

b_case = [b, -b]
c_case = [c, -c]
d_case = [d, -d]

#print(b_case, c_case, d_case)

for i in b_case:
    for j in c_case:
        for k in d_case:
            #print(a, i, j, k, a+i+j+k)
            if a + i + j + k == 7:
                print('{}{:+}{:+}{:+}{}'.format(a, i, j, k, '=7'))
                flag = 0
                break
                
        if flag == 0:
            break
    if flag == 0:
        break

Submission status: Runtime Error

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

b_case = [b, -b]
c_case = [c, -c]
d_case = [d, -d]

print(b_case, c_case, d_case)

for i in b_case:
    for j in c_case:
        for k in d_case:
            print(a, i, j, k, a+i+j+k)
            if a + i + j + k == 7:
                print('{}{:+}{:+}{:+}{}'.format(a, i, j, k, '=7'))
                flag = 2
                break
                
        if flag == 2:
            break
    if flag == 2:
        break

Submission status: Runtime Error

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

b_case = [b, -b]
c_case = [c, -c]
d_case = [d, -d]

for i in b_case:
    for j in c_case:
        for k in d_case:
            if a + i + j + k == 7:
                print('{}{:+}{:+}{:+}{}'.format(a, i, j, k, '=7'))
                flag = 1
                break
        
        if flag == 1:
            break
    if flag == 1:
        break

Submission status: Runtime Error

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

b_case = [b, -b]
c_case = [c, -c]
d_case = [d, -d]

for i in b_case:
    for j in c_case:
        for k in d_case:
            if a + i + j + k == 7:
                print('{}{:+}{:+}{:+}{}'.format(a, i, j, k, '=7'))
                flag = True
                break
        
        if flag == True:
            break
    if flag == True:
        break

Submission status: Runtime Error

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

b_case = [b, -b]
c_case = [c, -c]
d_case = [d, -d]

ans = ''

for i in b_case:
    for j in c_case:
        for k in d_case:
            if a + i + j + k == 7:
                print('{}{:+}{:+}{:+}{}'.format(a, i, j, k, '=7'))
                flag = True
                break
        
        if flag == True:
            break
    if flag == True:
        break

Submission status: Runtime Error

Solution code:
S = input()
A = [int(S[i]) for i in range(4)]
for i in range(8):
  p = A[0]
  s = []
  for j in range(3):
    if i % 2 == 0:
      p += A[i]
      s.append('+')
    else:
      p -= A[i]
      s.append('-')
    i //= 2
  if p == 7:
    print('A[0]s[0]A[1]s[1]A[2]s[2]A[3]=7')
    break

Submission status: Runtime Error

Solution code:
s=input()
n = 2**(len(s)-1)
ans=""

for i in range(n):
    t = ""
    a = str(bin(i))[2:].zfill(len(s)-1)
    for j in range(len(a)):
        if a[j] == "1":
            t += s[j] + "+"
        else:
            t += s[j]
    t += s[-1]
    if eval(t)==7:
        ans = t + "=7"
        break
print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
def dfs(i,f,sum):#ストップする段階（i）、式（f）、sumカウンタの3つの引数を用意。
    if i == 3:
        if sum==7:
            print(f+"=7")
            exit()
    
    return 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:
def dfs(i, f, sum):
    if i == 3:
        if 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:
s = input()

def dfs(i, f, sum):
    if i == 3:
        if 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])


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

Submission status: Runtime Error

Solution code:
s = input()


def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + s[i + 1], sum + s[i + 1])
        dfs(i + 1, f + "-" + s[i + 1], sum - s[i + 1])


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

Submission status: Runtime Error

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

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:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]


for i in range(2**(len(S)-1)):
    op_list = ['+']*(len(S)-1)
    for j in range(len(S)-1):

        if (i>>j)&1:
            op_list[j]='-'
    s = ""
    for j in range(len(S)-1):
        s = s + S[j] + op_list[j]

    s = s + S[len(S)-1]

    if 7==eval(s):
        print(s,"=7", sep="")
        sys.exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
a,b,c,d = map(int,input())
ans = a+b+c+d
if ans == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a+b+c-d
if ans == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]+"=7")
    sys.exit()
ans = a+b-c+d
if ans == 7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a-b+c+d
if ans == 7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a-b-c+d
if ans == 7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]+"=7")
    sys.exit()
ans = a+b-c-d
if ans == 7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
    sys.exit()
ans = a-b+c-d
if ans == 7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3]+"=7")
    sys.exit()
ans = a-b-c-d
if ans == 7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
    sys.exit()

Submission status: Runtime Error

Solution code:
a = input()
input_list = []
for k in a:
    input_list.append(int(k))
ans = []
fomul_list = []
for i in range(2 ** n):
    sum = input_list[0]
    fomul = str(input_list[0])
    for j in range(3):
        if (i >> j)&1:
            sum += input_list[j+1]
            fomul = fomul + "+" + str(input_list[j+1])
        else:
            sum -= input_list[j+1]
            fomul = fomul + "-" + str(input_list[j+1])
    bag.append(sum)
    fomul_list.append(fomul)
print(fomul_list[bag.index(7)])

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:
import sys
import copy
S = list(map(str, input()))


def main():
    op_cnt = len(S) - 1
    lis=[]
    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] = "+"
            else:
                op[op_cnt -1 -j]='-'

        S_tmp = copy.deepcopy(S)

        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])
            a=S_tmp
            if eval(''.join(a))==7:
                lis.append("".join(a)) 
               
            
    print(lis[0]+'=7')

main()

Submission status: Runtime Error

Solution code:
import sys
import copy
S = list(map(str, input()))


def main():
    op_cnt = len(S) - 1
    lis=[]
    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] = "+"
            else:
                op[op_cnt -1 -j]='-'

        S_tmp = copy.deepcopy(S)

        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])

            if eval(''.join(S_tmp))==7:
                lis.append("".join(S_tmp)) 
               
            
    print(lis[0]+'=7')

main()

Submission status: Runtime Error

Solution code:
import sys
import copy
S = list(map(str, input()))


def main():
    op_cnt = len(S) - 1
    lis=[]
    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] = "+"
            else:
                op[op_cnt -1 -j]='-'
        #print(op)
        S_tmp = copy.deepcopy(S)

        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])
            #print(S_tmp)
            if eval(''.join(S_tmp))==7:
                lis.append("".join(S_tmp)) 
                #print(lis)#eval-式として評価、''.join-リストの要素をくっつける
            
    print(lis[0]+'=7')

main()

Submission status: Runtime Error

Solution code:
S = list(map(str, input()))
op_cnt = len(S) - 1

def main():
    lis=[]
    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] = "+"
            else:
                op[op_cnt -1 -j]='-'
        #print(op)
        S_tmp = copy.deepcopy(S)

        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])
            #print(S_tmp)
            if eval(''.join(S_tmp))==7:
                lis.append("".join(S_tmp)) 
                #print(lis)#eval-式として評価、''.join-リストの要素をくっつける
            
    print(lis[0]+'=7')

main()

Submission status: Runtime Error

Solution code:
S = list(map(str, input()))
op_cnt = len(S) - 1


lis=[]
eva=[]
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] = "+"
        else:
            op[op_cnt -1 -j]='-'
    #print(op)
    S_tmp = copy.deepcopy(S)

    for k in range(len(op)):
        S_tmp.insert(1+k*2,op[k])
        #print(S_tmp)
        if eval(''.join(S_tmp))==7:
                lis.append("".join(S_tmp)) 
                #print(lis)#eval-式として評価、''.join-リストの要素をくっつける
            
print(lis[0]+'=7')

Submission status: Runtime Error

Solution code:
import sys
import copy

def main():
    ABCD = list(map(str, input()))
    b_digit = len(ABCD)-1

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

        ABCD_tmp = copy.deepcopy(ABCD)
        for k in range(len(signs)):
            ABCD_tmp.insert(1+k*2,signs[k])
        if(eval("".join(ABCD_tmp))==7):
            print("{}=7".format("".join(ABCD_tmp)))
            sys.exit()

main()
~

Submission status: Runtime Error

Solution code:
import sys
import copy

def main():
    ABCD = list(map(str, input()))
    b_digit = len(ABCD)-1

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

        ABCD_tmp = copy.deepcopy(ABCD)
        for k in range(len(signs)):
            ABCD_tmp.insert(1+k*2,signs[k])
            if(eval("".join(ABCD_tmp))==7):
                    print("{}=7".format("".join(ABCD_tmp)))
                    sys.exit()

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])

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

Submission status: Runtime Error

Solution code:
A = list(int(input()))

for i in range(2**3):
  tmp=A[:]
  for j in range(3):
    if (i>>j)&1:
      tmp[j]*=-1
  if sum(A) == 7:
    for s in tmp:
      print(s,end="")
    print("=7")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#1+2+2+2=7
K=input()
keta=len(K)
#print(K,keta)

for i in range(1<<(keta-1)):#探索数
  ANS=K[0]
  for j in range(keta-1):#調査桁数
    if (i>>j) &1 == 1:#bitがある、つまりプラスが入る場合
      ANS+="+"
    ANS+=K[j+1]
#  print(ANS)
  if eval(ANS)==7:
    print(ANS+"=7")
    break

Submission status: Runtime Error

Solution code:
J=list(input())
n=len(J)

def dfs_formula(i,f):
    if i==n-1:
        return [f]
    return dfs_formula(i+1,f+"+"+J[i+1])+dfs_formula(i+1,f+"-"+J[i+1])
    
def dfs_sum(i,f):
    if i==n-1:
        return f
    return str(dfs_sum(i+1,f+int(J[i+1])))+" "+str(dfs_sum(i+1,f-int(J[i+1])))

A=dfs_formula(0,J[0])
S=dfs_sum(0,int(J[0]))

for i in range(len(S)):
    if S[i]=='7':
        print(A[i]+"=7")
        break

Submission status: Runtime Error

Solution code:
n = input()

for i in range(n):
  print(bin(n))

Submission status: Runtime Error

Solution code:
from itertools import zip_longest

N = input()
len_N = len(str(N))

hugo = ["-"]*(len_N-1)

for i in range(2**(len_N-1)):
  hugo = ["-"]*(len_N-1)
  for j in range(len_N-1):
    if (i>>j)& 1:
      hugo[len_N-1-1-j]="+"
  formula = ""
  for aaa,bbb in zip_longest(N,hugo+[""]):
    formula +=(aaa+bbb)
  if eval(formula) ==7:
    print(f"{formula}=7")
    break

Submission status: Runtime Error

Solution code:
from itertools import zip_longest

N = input()
len_N = len(str(N))

hugo = ["-"]*(len_N-1)

for i in range(2**(len_N-1)):
  hugo = ["-"]*(len_N-1)
  for j in range(len_N-1):
    if (i>>j)& 1:
      hugo[j]="+"
  formula = ""
  for aaa,bbb in zip_longest(N,hugo+[""]):
    formula +=(aaa+bbb)
  if eval(formula) ==7:
    print(f"{formula}=7")
    break

Submission status: Runtime Error

Solution code:
s=input()

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
s=list(input())
for i in s:
  i=int(i)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
s = input()
a  = 7
n = len(s)
for i in range(2**(n-1)):
    total = int(s[0])
    ans = [s[0]]
    for j in range(n-1):
        if (i >> j) & 1:
            total += int(s[j+1])
            ans.append('+' + s[j+1])
        else:
            total -= int(s[j+1])
            ans.append('-'+s[j+1])
    if total == 7:
        print(''.jon(ans) + '=7')
        sys.exit()

Submission status: Runtime Error

Solution code:
A,B,C,D =input()
E ="+-"

for i in E:
  for j in E:
    for k in E:
      s=A+i+B+j+C+k+D
      if eval(s)==7:
        print(s+"=7")
		exit()

Submission status: Runtime Error

Solution code:
A,B,C,D =input();
E ="+-"

for i in E:
  for j in E:
    for k in E:
      s=A+i+B+j+C+k+D
      if eval(s)==7:
        print(s+"=7")
		exit()

Submission status: Runtime Error

Solution code:
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b, c, d = (int(x) for x in list(sys.stdin.readline().rstrip()))
    s = 7 - a
    if sum([b, c, d]) == s: res = '+++'
    elif sum([-b, c, d]) == s: res = '-++'
    elif sum([b, -c, d]) == s: res = '+-+'
    elif sum([b, c, -d]) == s: res = '++-'
    elif sum([-b, -c, d]) == s: res = '--+'
    elif sum([-b, c, -d]) == s: res = '-+-' 
    if res[0] == '-': b = -b
    if res[1] == '-': c = -c
    if res[2] == '-': d = -d
    ans = [str(a)]
    for x in [b, c, d]:
        if x >= 0 : x = '+' + str(x)
        else: x = str(x)
        ans.append(x)
    print(''.join(ans) + '=7')


if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Runtime Error

Solution code:
abcd = input()
s = 0
i = 0
for i in range(8):
    a = abcd[0]
    for j in range(3):
        if (i >> j) & 1:
            a += '+'
        else:
            a += '-'
    s = eval(a)
    if s == 7:
        ans = a + '=' + '7'
        break
print(ans)

Submission status: Runtime Error

Solution code:
N=str(input())
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
for i in range(2):
  for j in range(2):
    for k in range(2):
      t=a
      if i==0:
        t+=b
      else:
        t-=b
        
      if j==0:
        t+=c
      else:
        t-=c
        
      if k==0:
        t+=d
      else:
        t-=d
        
      if t==7:
        print(f"{a}{"+-"[i]}{b}{"+-"[j]}{c}{"+-"[k]}{d}=7")

Submission status: Runtime Error

Solution code:
def dfs(i, sum):
    # n 個決め終わったら、今までの和 sum が k と等しいかを返す
    if i == n  - 1:
#         print(sum)
        if eval(sum) == k:
            print(sum+"=7")
        return eval(sum) == k
    # + を使う
    if dfs(i + 1, sum + "-" +  s[i+1]):
        return True
    
    # - を使う
    if dfs(i + 1, sum + "+" + s[i+1]):
        return True
#     print(sum)
    return False

def main():
    s = input()
    n = len(s)
    k = 7

    if dfs(0, s[0]):
        pass
    else:
        pass
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

if n[0]+n[1]+n[2]+n[3] == 7:
	print(f'{n[0]}+{n[1]}+{n[2]}+{n[3]}=7')
elif n[0]+n[1]+n[2]-n[3] == 7:
	print(f'{n[0]}+{n[1]}+{n[2]}-{n[3]}=7')
elif n[0]+n[1]-n[2]+n[3] == 7:
	print(f'{n[0]}+{n[1]}-{n[2]}+{n[3]}=7')
elif n[0]+n[1]-n[2]-n[3] == 7:
	print(f'{n[0]}+{n[1]}-{n[2]}-{n[3]}=7')
elif n[0]-n[1]+n[2]+n[3] == 7:
	print(f'{n[0]}-{n[1]}+{n[2]}+{n[3]}=7')
elif n[0]-n[1]+n[2]-n[3] == 7:
	print(f'{n[0]}-{n[1]}+{n[2]}-{n[3]}=7')
elif n[0]-n[1]-n[2]+n[3] == 7:
	print(f'{n[0]}-{n[1]}-{n[2]}+{n[3]}=7')
elif n[0]-n[1]-n[2]-n[3] == 7:
	print(f'{n[0]}-{n[1]}-{n[2]}-{n[3]}=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")
elif a+b+c-d==7:
  print(a+"+"+b+"+"+c+"-"+d+"=7")
elif a+b-c+d==7:
  print(a+"+"+b+"-"+c+"+"+d+"=7")
elif a+b-c-d==7:
  print(a+"+"+b+"-"+c+"-"+d+"=7")
elif a-b+c+d==7:
  print(a+"-"+b+"+"+c+"+"+d+"=7")
elif a-b+c-d==7:
  print(a+"-"+b+"+"+c+"-"+d+"=7")
elif a-b-c+d==7:
  print(a+"-"+b+"-"+c+"+"+d+"=7")
else:
  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")
elif a+b+c-d==7:
  print(a+"+"b+"+"+c+"-"+d+"=7")
elif a+b-c+d==7:
  print(a+"+"b+"-"+c+"+"+d+"=7")
elif a+b-c-d==7:
  print(a+"+"b+"-"+c+"-"+d+"=7")
elif a-b+c+d==7:
  print(a+"-"b+"+"+c+"+"+d+"=7")
elif a-b+c-d==7:
  print(a+"-"b+"+"+c+"-"+d+"=7")
elif a-b-c+d==7:
  print(a+"-"b+"-"+c+"+"+d+"=7")
else:
  print(a+"-"b+"-"+c+"-"+d+"=7")

Submission status: Runtime Error

Solution code:
s = str(input())
flag = 0

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i+1])
            f += "+"
        else:
            ans -= int(s[i+1])
            f += "-"
        f += s[i+1]
    
        if ans == 7:
            print(f + "=7")
            flag = 1
            break
	if flag:
      break

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
S=input()
sign=[+-]
for i in range(2):
  for j in range(2):
    for n in range(2):
      if eval(S[0]+sign[i]+S[1]+sign[j]+S[2]+sign[n]+S[3])==7:
        print(str(S[0]+sign[i]+S[1]+sign[j]+S[2]+sign[n]+S[3])+'=7')
        exit()

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
X=list(input())
A,B,C,D=map(int,X)
if A+B+C+D==7:
  print(A+'+'+B+'+'+C+'+'+D+'=7')
  exit()
if A+B+C-D==7:
  print(A+'+'+B+'+'+C+'-'+D+'=7')
  exit()
if A+B-C+D==7:
  print(A+'+'+B+'-'+C+'+'+D+'=7')
  exit()
if A-B+C+D==7:
  print(A+'-'+B+'+'+C+'+'+D+'=7')
  exit()
if A-B-C+D==7:
  print(A+'-'+B+'-'+C+'+'+D+'=7')
  exit()
if A+B-C-D==7:
  print(A+'+'+B+'-'+C+'-'+D+'=7')
  exit()
if A-B+C-D==7:
  print(A+'-'+B+'+'+C+'-'+D+'=7')
  exit()
if A-B-C-D==7:
  print(A+'-'+B+'-'+C+'-'+D+'=7')
  exit()

Submission status: Runtime Error

Solution code:
a=input()
def dfs(i,s,l):
    if i==3:
        if s==7:
            print(l+'=7')
    else:
        dfs(i+1,s+int(a[i+1]),l+'+'+a[i+1])
        dfs(i+1,s-int(a[i+1]),l+'-'+a[i+1])

dfs(dfs(0,int(a[0]),a[0]))

Submission status: Runtime Error

Solution code:
s = input()
n = len(s) - 1 #隙間の数

for i in range(2**3):
    tmp = s[0]
    for j in range(n):
        if (i >> j) & 1:
            tmp += "+"

        else:
            tmp += "-"

        tmp += s[j+1]

    list_tmp = [tmp[0], tmp[1:3], tmp[3:5], tmp[5:7]]

    for j in list_tmp:
        res += int(j)

    if res == 7:

        print(tmp + "=7")
        exit()

Submission status: Runtime Error

Solution code:
def f(i,s,t):
    if i==3:
        if s==7:
            print(t + '=7')
            exit()
    
    else:
        f(i+1,t+'-'+a[i+1],s-int(a[i+1]))
        f(i+1,t+'+'+a[i+1],s+int(a[i+1]))

a=input()
f(0,int(a[0]),a[0])

Submission status: Runtime Error

Solution code:
def f(i,s,t):
    if i==3:
        if s==7:
            print(t + '=7')
            exit()
    
    else:
        f(i+1,t+'-'+a[i+1],s-int(a[i+1]))
        f(i+1,t+'+'+a[i+1],s+int(a[i+1]))

a=input()
f(0,a[0],int(a[0]))