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:
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="+"

if a+b+c-d==7:
    x="+"
    y="+"
    z="-"
    
    
if a+b-c+d==7:
    x="+"
    y="-"
    z="+"    

if a-b+c+d==7:
    x="-"
    y="+"
    z="+"
    
if a-b-c+d==7:
    x="-"
    y="-"
    z="+"

if a-b+c-d==7:
    x="-"
    y="+"
    z="-"

if a-b-c+d==7:
    x="-"
    y="-"
    z="+"
    
if 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")

Submission status: Runtime Error

Solution code:
 S = input()
 n = len(S)
 
 for i in range(1 << (n - 1)):
     eq = ''
     for j in range(n - 1):
         eq += S[j]
         if (i >> j) & 1 :
             eq += '+'
         else:
             eq += '-'
     eq += S[n-1]
     ans = eval(eq)
     if(ans == 7):
         print(eq + '=' + str(ans))
         break

Submission status: Runtime Error

Solution code:
 S = input()
 n = len(S)
 
 for i in range(1 << (n - 1)):
     eq = ''
     for j in range(n - 1):
         eq += S[j]
         if (i >> j) & 1 :
             eq += '+'
         else:
             eq += '-'
     eq += S[n-1]
     ans = eval(eq)
     if(ans == 7):
         print(eq + '=' + str(ans))

Submission status: Runtime Error

Solution code:
[n, Y] = list(map(int, input().split()))
x, y, z = -1, -1, -1
for xx in range(n+1):
    for yy in range(n+1-xx):
        zz = n - xx - yy
        if Y == 10000 * xx + 5000 * yy + 1000 * zz:
            x, y, z = xx, yy, zz
            break
print(x, y, z)

Submission status: Runtime Error

Solution code:
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let mut ans = 0;
    for i in 1..n+1 {
        let s = i/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+(i%10);
        if s >= a && s <= b {
            ans += i
        }
    }
    println!("{}", ans);
}

Submission status: Runtime Error

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

ops = {'+', '-'}

for op1 in ops:
    if op1 == '+': ab = a+b
    else: ab = a-b
    
    for op2 in ops:
        if op2 == '+': abc = ab+c
        else: abc = ab-c
        
        for op3 in ops:
            if op3 == '+': abcd = abc+d
            else: abcd = abc-d

            if abcd == 7:
                print(f'{a}{op1}{b}{op2}{c}{op3}{d}=7')
                exit()

Submission status: Runtime Error

Solution code:
ABCD=list(map(int, list(input())))
for i in range(1<<3):
    tmp=list(map(int, list(str(bin(i))[2:].zfill(3))))
    a=ABCD[0]
    for j in range(3):
        if tmp[j]:
            a+=ABCD[j+1]
        else:
            a-=ABCD[j+1]
    if a==7:
        print(ABCD[0], end="")
        for j in range(3):
            print("+" if tmp[j] else "-", end="")
            print(ABCD[j+1], end="")
        print("=7")
        exit(1)

Submission status: Runtime Error

Solution code:
ABCD=list(map(int, list(input())))
for i in range(1<<3):
    tmp=list(map(int, list(str(bin(i))[2:].zfill(3))))
    print(tmp)
    a=ABCD[0]
    for j in range(3):
        if tmp[j]:
            a+=ABCD[j+1]
        else:
            a-=ABCD[j+1]
    if a==7:
        print(ABCD[0], end="")
        for j in range(3):
            print("+" if tmp[j] else "-", end="")
            print(ABCD[j+1], end="")
        print("=7")
        exit(1)

Submission status: Runtime Error

Solution code:
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8 5\n"
     ]
    }
   ],
   "source": [
    "n,k = map(int,input().split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-9 -7 -4 -3 1 2 3 4\n"
     ]
    }
   ],
   "source": [
    "x = list(map(int,input().split()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "ans = []\n",
    "for i in range(n):\n",
    "    if (i + k -1) >= n:\n",
    "        break\n",
    "    x1 = x[i]\n",
    "    x2 = x[i+k-1]\n",
    "    ans1 = abs(x2) + abs(x2-x1)\n",
    "    ans2 = abs(x1) + abs(x1-x2)\n",
    "    ans.append(ans1)\n",
    "    ans.append(ans2)\n",
    "print(min(ans))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

Submission status: Runtime Error

Solution code:
from itertools import product

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

for pattern in product('+-', repeat=3):
    f = '{}{}{}{}{}{}{}'.format(A, pattern[0], B, pattern[1], C, pattern[2], D)    if eval(f) == 7:
        print(f+'=7') 
        break

Submission status: Runtime Error

Solution code:
n = input()

a = ['+','-']

b = ''
ans = ''
for i in a:
    b += n[0]+i
    for j in a:
        b += n[1]+j
        for k in a:
            b += n[2]+k+n[3]
            if eval(b) == 7:
                ans = b+'=7'
            else:
                b = ''
print(ans)

Submission status: Runtime Error

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

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d+%d+%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)

Submission status: Runtime Error

Solution code:
# input
N = int(input())
L = [int(x) for x in list(str(N))]
ans = 0

if L[0] + L[1] + L[2] + L[3] == 7:
    print("%d+%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
else:
    if L[0] - L[1] + L[2] + L[3] == 7:
        print("%d-%d+%d+%d=7" % (L[0], L[1], L[2], L[3]))
    else:
        if L[0] + L[1] - L[2] + L[3] == 7:
            print("%d+%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
        else:
            if L[0] + L[1] + L[2] - L[3] == 7:
                print("%d+%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
            else:
                if L[0] - L[1] - L[2] + L[3] == 7:
                    print("%d-%d-%d+%d=7" % (L[0], L[1], L[2], L[3]))
                else:
                    if L[0] - L[1] + L[2] - L[3] == 7:
                        print("%d-%d+%d-%d=7" % (L[0], L[1], L[2], L[3]))
                    else:
                        if L[0] + L[1] - L[2] - L[3] == 7:
                            print("%d+%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))
                        else:
                            if L[0] - L[1] - L[2] - L[3] == 7:
                                print("%d-%d-%d-%d=7" % (L[0], L[1], L[2], L[3]))

Submission status: Runtime Error

Solution code:
ABCD = list(map(int, input().split()))

for i in range(1 << 3):
    total = ABCD[0]
    equation = str(ABCD[0])
    for j in range(3):
        if i & (1 << j):
            total += ABCD[j+1]
            equation += "+"
        else:
            total -= ABCD[j+1]
            equation += "-"    
        equation += str(ABCD[j+1])
    if total == 7:
        equation += "=7"
        print(equation)
        break

Submission status: Runtime Error

Solution code:
ABCD = list(map(int, input().split()))

for i in range(1 << 3):
    total = ABCD[0]
    equation = str(ABCD[0])
    for j in range(3):
        if i & (1 << j):
            total += ABCD[j+1]
            equation.append("+")
        else:
            total -= ABCD[j+1]
            equation.append("-")    
        equation.append(ABCD[j+1])
    if total == 7:
        equation.append("=7")
        print(equation)
        break

Submission status: Runtime Error

Solution code:
l=[int(x) for x in list(input())]
if l[0]+l[1]+l[2]+l[3]==7: print('{}+{}+{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]+l[1]+l[2]-l[3]==7: print('{}+{}+{}-{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]+l[1]-l[2]+l[3]==7: print('{}+{}-{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]+l[1]-l[2]-l[3]==7: print('{}+{}-{}-{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]+l[2]+l[3]==7: print('{}-{}+{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]+l[2]-l[3]==7: print('{}-{}+{}-{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]-l[2]+l[3]==7: print('{}-{}-{}+{}=7'.format(l[0],l[1],l[2],l[3])
elif l[0]-l[1]-l[2]-l[3]==7: print('{}-{}-{}-{}=7'.format(l[0],l[1],l[2],l[3])

Submission status: Runtime Error

Solution code:
p = int(input())

q =list(str(p))
r = []
for i in range(len(q)):
    r.append(int(q[i]))
    
a = r[0]
b = [-r[1],r[1]]
c = [-r[2],r[2]]
d = [-r[3],r[3]]

e = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a + b[i] + c[j] + d[k] == 7:
                e.append(a)
                e.append(b[i])
                e.append(c[j])
                e.append(d[k])
                
for i in range(len(e)):
    if e[i] < 0 or i == 0:
        e[i] = str(e[i])
    else:
        e[i] = '+' + str(e[i])
        
print(e[0] + e[1] + e[2] + e[3])

Submission status: Runtime Error

Solution code:
import itertools
n = input()
x, pm, a = [], [1,-1], 7-int(n[0])
for i in range(1,4):
	x.append(int(n[i]))
for j in itertools.product(pm,repeat=3):
	if x[0]*j[0]+x[1]*j[1]+x[2]*j[2]==a:
		y = j
		break
for k in range(3):
	if y[k]==1: y[k] = "+"
	else: y[k] = "-"
print(n[0]+y[0]+n[1]+y[1]+n[2]+y[2]+n[3]+"=7")

Submission status: Runtime Error

Solution code:
nums = [int(num) for num in input()]

target = 7

if sum(nums) == target:
    symbols = '+++'
elif nums[0] + nums[1] + nums[2] - nums[3] == target:
    symbols = '++-'
elif nums[0] + nums[1] - nums[2] + nums[3] == target:
    symbols = '+-+'
elif nums[0] + nums[1] - nums[2] - nums[3] == target:
    symbols = '+--'
elif nums[0] - nums[1] + nums[2] + nums[3] == target:
    symbols = '-++'
elif nums[0] - nums[1] + nums[2] - nums[3] == target:
    symbols = '-+-'
elif nums[0] - nums[1] - nums[2] + nums[3] == target:
    symbols = '--+'
elif nums[0] - nums[1] - nums[2] - nums[3] == target:
    symbols = '---'

print(f'{nums[0]}{symbols[0]}{nums[1]}{symbols[1]}{nums[2]}{symbols[2]}{nums[3]}=7')

Submission status: Runtime Error

Solution code:
ans=list(input())
a=int(ans[0])
b=int(ans[1])
c=int(ans[2])
d=int(ans[3])
    pass=int(ans[3])
if b+c+d+e==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:
# -*- coding: utf-8 -*-
A,B,C,D = list(map(int, list(input())))

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')
elif A-B-C-D == 7:
    print(A+'-'+B+'-'+C+'-'+D+'=7')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
A,B,C,D = list(map(int, input().split()))

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')
elif A-B-C-D == 7:
    print('A-B-C-D=7')

Submission status: Runtime Error

Solution code:
H, W=map(int,input().split(' '))
c=[list(map(int,input().split(' '))) for i in range(10)]
a=[list(map(int,input().split(' '))) for i in range(H)]
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])

for i in range(H):
    for j in range(W):
        if a[i][j]>=0:
            ans += c[a[i][j]][1]

print(ans)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//変数
vector<int> num;
string ans = "";

//サブ関数
//入力
void input() {
	string s;
	cin >> s;
	for (auto c : s) {
		num.push_back(c - '0');
	}
}


void rec(int id, int sum, string s) {
	if (id == 4) {
		if(sum==7)ans = s + "=7";
		return;
	}
	rec(id + 1, sum + num[id], s + "+" + to_string(num[id]));
	rec(id + 1, sum - num[id], s + "-" + to_string(num[id]));
}


//計算
void calc() {
	rec(1, num[0], to_string(num[0]));
}


//出力
void output() {
	cout << ans << endl;
}

//デバッグ
void debug() {
	int N;
	cin >> N;
}


//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}

Submission status: Runtime Error

Solution code:
a, b, c, d = map(str,input().split())
sign = "+-"
for i in range(2):  # 1つ目の記号
    for j in range(2):  # 2つ目の記号
        for k in range(2):  # 3つ目の記号
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+"=7")

Submission status: Runtime Error

Solution code:
a, b, c, d = map(str,input().split())
sign = "+-"
for i in range(3):  # 1つ目の記号
    for j in range(3):  # 2つ目の記号
        for k in range(3):  # 3つ目の記号
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+"=7")

Submission status: Runtime Error

Solution code:
a, b, c, d = map(str,input().split())
sign = "+-*"
for i in range(3):  # 1つ目の記号
    for j in range(3):  # 2つ目の記号
        for k in range(3):  # 3つ目の記号
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+"=7")

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, raw_input().split())

if A+B+C+D == 7:
    print '%s+%s+%s+%s' % (A, B, C, D)
elif A+B+C-D == 7:
    print '%s+%s+%s-%s' % (A, B, C, D)
elif A+B-C+D == 7:
    print '%s+%s-%s+%s' % (A, B, C, D)
elif A-B+C+D == 7:
    print '%s-%s+%s+%s' % (A, B, C, D)
elif A+B-C-D == 7:
    print '%s+%s-%s-%s' % (A, B, C, D)
elif A-B+C-D == 7:
    print '%s-%s+%s-%s' % (A, B, C, D)
elif A-B-C+D == 7:
    print '%s-%s-%s+%s' % (A, B, C, D)
elif A-B-C-D == 7:
    print '%s-%s-%s-%s' % (A, B, C, D)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
ns = [int(n) for n in input()]

for i in range(0b000, 0b111 + 1):
    s = ns[0]
    if (i & 0b100) != 0:
        s += ns[1]
    else:
        s -= ns[1]

    if (i & 0b010) != 0:
        s += ns[2]
    else:
        s -= ns[2]

    if (i & 0b001) != 0:
        s += ns[3]
    else:
        s -= ns[3]

    if s == 7:
        ops = bin(i)
        ops = ops[2:]
        if len(ops) == 2:
            ops = '0' + ops

        ops = ['+' if a == '1' else '-' for a in ops]
        sns = [str(n) for n in ns]
        ans = sns[0] + ops[0] + sns[1] + ops[1] + sns[2] + ops[2] + sns[3] + '=7'
        break

print(ans)

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('{}+{}+{}+{}=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:
n=input()
pm=[+,-]
for op1 in pm:
  for op2 in pm:
    for op3 in pm:
      if (n[0] op1 n[1] op2 n[2] op3 n[3])==7:
        print("n[0] op1 n[1] op2 n[2] op3 n[3]=7")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = [int(i) for i in list(input())]
enzan = ['+', '+', '+']
res = 0
for i in range(2):
	if i == 0:
		enzan[0] = '+'
		b = a[0] + a[1]
	else:
		enzan[0] = '-'
		b = a[0] - a[1]
	for j in range(2):
		if j == 0:
			enzan[1] = '+'
			c = b + a[2]
		else:
			enzan[1] = '-'
			c = b - a[2]
		for k in range(2):
			if k == 0:
				enzan[2] = '+'
				d = c + a[3]
			else:
				enzan[2] = '-'
				d = b - a[3]
			if d1 == 7:
				print(str(a[0])+enzan[0]+str(a[1])+enzan[1]+str(a[2])+enzan[2]+str(a[3])+'=7')

Submission status: Runtime Error

Solution code:
def main():
    a, b, c, d = map(int, input().split())
    num_list = [a, b, c, d]
    if (a-b-c-d == 7): print('{}-{}-{}-{}=7'.format(*num_list))
    elif (a-b-c+d == 7): print('{}-{}-{}+{}=7'.format(*num_list))
    elif (a-b+c-d == 7): print('{}-{}+{}-{}=7'.format(*num_list))
    elif (a+b-c-d == 7): print('{}+{}-{}-{}=7'.format(*num_list))
    elif (a-b+c+d == 7): print('{}-{}+{}+{}=7'.format(*num_list))
    elif (a+b-c+d == 7): print('{}+{}-{}+{}=7'.format(*num_list))
    elif (a+b+c+d == 7): print('{}+{}+{}+{}=7'.format(*num_list))
                    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    a, b, c, d = map(int, input().split())
    num_list = [a, b, c, d]
    if (a-b-c-d == 7): print('{}-{}-{}-{}=7'.format(*num_list))
    elif (a-b-c+d == 7): print('{}-{}-{}+{}=7'.format(*num_list))
    elif (a-b+c-d == 7): print('{}-{}+{}-{}=7'.format(*num_list))
    elif (a+b-c-d == 7): print('{}+{}{}-{}=7'.format(*num_list))
    elif (a-b+c+d == 7): print('{}-{}+{}+{}=7'.format(*num_list))
    elif (a+b-c+d == 7): print('{}+{}-{}+{}=7'.format(*num_list))
    elif (a+b+c+d == 7): print('{}+{}+{}+{}=7'.format(*num_list))
                    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def solve(a, b, c, d):
    op_list = ['+', '-']
    sumv = a
    for op1 in op_list:
        if op1 == '+':
            sumv += b
        else:
            sumv -= b
        for op2 in op_list:
            if op2 == '+':
                sumv += c
            else:
                sumv -= c
            for op3 in op_list:
                if op3 == '+':
                    sumv += d
                else:
                    sumv -= d
                if sumv == 7:
                    return op1, op2, op3
        sumv = a



def main():
    tmp = input()
    a, b, c, d = int(tmp[0]), int(tmp[1]), int(tmp[2]), int(tmp[3])
    op_list = ['+', '-']

    op1, op2, op3 = solve(a, b, c, d)
    print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + '=7')
                    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def solve(a, b, c, d):
    op_list = ['+', '-']
    sumv = a
    for op1 in op_list:
        if op1 == '+':
            sumv += b
        else:
            sumv -= b
        for op2 in op_list:
            if op2 == '+':
                sumv += c
            else:
                sumv -= c
            for op3 in op_list:
                if op3 == '+':
                    sumv += d
                else:
                    sumv -= d
                if sumv == 7:
                    return op1, op2, op3
                sumv = a


def main():
    tmp = input()
    a, b, c, d = int(tmp[0]), int(tmp[1]), int(tmp[2]), int(tmp[3])
    op_list = ['+', '-']

    op1, op2, op3 = solve(a, b, c, d)
    print(str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d) + '=7')
                    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D = map(int, input().split())

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")
elif A-B-C-D == 7:
    print("A-B-C-D =7")

Submission status: Runtime Error

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

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

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

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

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

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

Submission status: 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('{0}+{1}+{2}+{3}=7' .format(a,b,c,d))
	
if a-b+c+d == 7:
	print('{0}-{1}+{2}+{3}=7' .format(a,b,c,d))

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

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

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

Submission status: Runtime Error

Solution code:
N = raw_input()
keys = ['+','-']
x = 0
check = True

for key1 in keys:
    if key1 == '+' and check:
        x = int(N[0]) + int(N[1])
    elif(key1 == '-' and check):
        x = int(N[0]) - int(N[1])
    for key2 in keys:
        if key2 == '+' and check:
            x = x  + int(N[2])
        elif(key2 == '-' and check):
            x = x  - int(N[2])
            
        for key3 in keys:
            if key3 == '+' and check:
                x = x  + int(N[3])
                if (x == 7):
                    ans = N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    #print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    check = False
                else:
                    x = 0
            elif(key3 == '-' and check):
                x = x  - int(N[3])

                if (x == 7):
                    ans =  N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    check = False

                else:
                    x = 0
print ans

Submission status: Runtime Error

Solution code:
num = list(map(int, input().split()))
if sum(num) == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")

Submission status: Runtime Error

Solution code:
r = int(input())
a = r[0]
b = r[1]
c = r[2]
d = r[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:
r = int(input())
a = r[0]
b = r[1]
c = r[2]
d = r[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")
elif a-b-c-d ==7:
  print(a+"-"+b+"-"+c+"-"+d"=7")

Submission status: Runtime Error

Solution code:
sr = input()

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

def calc(one, two, three):
  if a + b*one + c*two + d*three == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  
for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        q, w, e = change(q), change(w), change(e)
        print(str(a)+q+str(b)+w+str(c)+e+str(d)+"=7")
        break

Submission status: Runtime Error

Solution code:
s = str
End = False
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
    for j in [C,-1*C]:
        for k in [D,-1*D]:
            if A + i + j + k == 7:
                print(f"{A:d}{i:+d}{j:+d}{k:+d}=7")
                exit()

Submission status: Runtime Error

Solution code:
n = int(input())
a = n // 1000
b = n % 1000 // 100
c = n % 100 // 10
d = n % 10

def calc(ind, x):
    if ind == 0:
        return x
    else:
        return -x

flag = 0
for j in range(2):
    ans = a
    if flag:
        break
    ans += calc(j, b)
    for k in range(2):
        if flag:
            break
        ans += calc(k, c)
        for l in range(2):
            ans += calc(l, d)
            if ans == 7:
                flag = 1
                result = ['+' if x == 0 else '-' for x in [j, k, l]]
                break
answer = str(a) + result[0] + str(b) + result[1] + str(c) + result[2] + str(d) + '=7'
print (answer)

Submission status: Runtime Error

Solution code:
s = str
End = False
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
    for j in [C,-1*C]:
        for k in [D,-1*D]:
            if A + i + j + k == 7:
                print(f"{A:d}{i:+d}{j:+d}{k:+d}=7")
                End = True
                break
        if End:
            break
    if End:
        break

Submission status: Runtime Error

Solution code:
def check_if_seven(num_list):
    if sum(num_list) == 7:
        return "+,+,+"
    elif num_list[0] - sum(num_list[1:]) == 7:
        return "-,+,+"
    elif num_list[0] + num_list[1] - sum(num_list[2:]) == 7:
        return "+,-,+"
    elif sum(num_list[:-1]) - num_list[-1] == 7:
        return "+,+,-"
    elif num_list[0] - num_list[1] - num_list[2] + num_list[3]== 7:
        return "-,-,+"
    elif num_list[0] + num_list[1] - num_list[2] - num_list[3]== 7:
        return "+,-,-"
    elif num_list[0] - num_list[1] - num_list[2] - num_list[3]== 7:
        return "-,-,-"


a = [x for x in list(str(input()))]
pm_list = check_if_seven([int(x) for x in a])
print("".join([a[0], pm_list[0], a[1], pm_list[1], a[2], pm_list[2], a[3], "=7"]))

Submission status: Runtime Error

Solution code:
s = input()
ops = ['-', '+']
for i in range(2):
    for j in range(2):
        for k in range(2):
            com = s[0] + op[i] + s[1] + op[j] + s[2] + op[k] + s[3]
            if eval(com) == 7:
                print(com + '=7')