qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = input()
#A, B, C, D = list(map(int, input().strip().split()))
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
ans1 = A+B+C+D
ans2 = A+B+C-D
ans3 = A+B-C+D
ans4 = A+B-C-D
ans5 = A-B+C+D
ans6 = A-B+C-D
ans7 = A-B-C+D
ans8 = A-B-C-D

if ans1 == 7:
	print('%d+%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d+%d-%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d-%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d-%d-%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d-%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d-%d+%d-%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d-%d-%d+%d=7' % (A, B, C, D))
else:
	print('%d-%d-%d-%d=7' % (A, B, C, D))


Fixed code:
N = input()
#A, B, C, D = list(map(int, input().strip().split()))
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
ans1 = A+B+C+D
ans2 = A+B+C-D
ans3 = A+B-C+D
ans4 = A+B-C-D
ans5 = A-B+C+D
ans6 = A-B+C-D
ans7 = A-B-C+D
ans8 = A-B-C-D

if ans1 == 7:
	print('%d+%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d+%d-%d=7' % (A, B, C, D))
elif ans3 == 7:
	print('%d+%d-%d+%d=7' % (A, B, C, D))
elif ans4 == 7:
	print('%d+%d-%d-%d=7' % (A, B, C, D))
elif ans5 == 7:
	print('%d-%d+%d+%d=7' % (A, B, C, D))
elif ans6 == 7:
	print('%d-%d+%d-%d=7' % (A, B, C, D))
elif ans7 == 7:
	print('%d-%d-%d+%d=7' % (A, B, C, D))
else:
	print('%d-%d-%d-%d=7' % (A, B, C, D))
Buggy code:
abcd = list(input())
a,b,c,d = map(int, abcd)

res = ""

if a + b + c + d == 7:
    res = "a+b+c+d=7"
elif a + b + c - d == 7:
    res = "a+b+c-d=7"
elif a + b - c + d == 7:
    res = "a+b-c+d=7"
elif a + b - c - d == 7:
    res = "a+b-c-d=7"
elif a +- b + c + d == 7:
    res = "a-b+c+d=7"
elif a - b + c - d == 7:
    res = "a-b+c-d=7"
elif a - b - c + d == 7:
    res = "a-b-c+d=7"
elif a - b - c - d == 7:
    res = "a-b-c-d=7"

print(res)




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

res = ""

if a + b + c + d == 7:
    res = str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7"
elif a + b + c - d == 7:
    res = str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7"
elif a + b - c + d == 7:
    res = str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7"
elif a + b - c - d == 7:
    res = str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7"
elif a +- b + c + d == 7:
    res = str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7"
elif a - b + c - d == 7:
    res = str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7"
elif a - b - c + d == 7:
    res = str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7"
elif a - b - c - d == 7:
    res = str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7"

print(res)
Buggy code:
s = input()
n = len(s)

def dfs(i, f):

    if i == n-1:
        if eval(f)==7: 
            print(f+"=7")
            return True
        else: 
            return False
    else:
        dfs(i+1,f + "+" + s[i+1])
        dfs(i+1,f + "-" + s[i+1])
    
def main():
    if dfs(0,s[0]):
        pass

if __name__ == '__main__':
    main()

Fixed code:
s = input()
n = len(s)

def dfs(i, f):

    if i == n-1:
        if eval(f)==7: 
            print(f+"=7")
            exit()
        else: 
            return False
    else:
        dfs(i+1,f + "+" + s[i+1])
        dfs(i+1,f + "-" + s[i+1])
    
def main():
    if dfs(0,s[0]):
        exit()

if __name__ == '__main__':
    main()
Buggy code:
e = input()
a = int(e[0:1])
b = int(e[1:2])
c = int(e[2:3])
d = int(e[3:4])

f, g = a+b, a-b
h, i, j, k = f+c, f-c, g+c, g-c
l, m, n, o, p, q, r, s = h + d, h - d, i + d, i - d, j + d, j - d, k + d, k - d
if(l == 7):
  print(str(a) + " + " + str(b) + " + " + str(c) + " + " + str(d))
elif(m == 7):
  print(str(a) + " + " + str(b) + " + " + str(c) + " - " + str(d))
elif(n == 7):
  print(str(a) + " + " + str(b) + " - " + str(c) + " + " + str(d))
elif(o == 7):
  print(str(a) + " + " + str(b) + " - " + str(c) + " - " + str(d))
elif(p == 7):
  print(str(a) + " - " + str(b) + " + " + str(c) + " + " + str(d))
elif(q == 7):
  print(str(a) + " - " + str(b) + " + " + str(c) + " - " + str(d))
elif(r == 7):
  print(str(a) + " - " + str(b) + " - " + str(c) + " + " + str(d))
elif(s == 7):
  print(str(a) + " - " + str(b) + " - " + str(c) + " - " + str(d))

Fixed code:
e = input()
a = int(e[0:1])
b = int(e[1:2])
c = int(e[2:3])
d = int(e[3:4])

f, g = a+b, a-b
h, i, j, k = f+c, f-c, g+c, g-c
l, m, n, o, p, q, r, s = h + d, h - d, i + d, i - d, j + d, j - d, k + d, k - d
if(l == 7):
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif(m == 7):
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif(n == 7):
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif(o == 7):
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif(p == 7):
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif(q == 7):
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif(r == 7):
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif(s == 7):
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
Buggy code:
#79-C:DFS

def dfs(i,f,f_sum):
    if i==3:
        if f_sum==7:
            print(f+'=7')
    else:
        dfs(i+1,f+'+'+s[i+1],f_sum+int(s[i+1]))
        dfs(i+1,f+'-'+s[i+1],f_sum-int(s[i+1]))

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

Fixed code:
#79-C:DFS

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

s=input()
dfs(0,s[0],int(s[0]))
Buggy code:
a,b,c,d = list(map(int,input()))
op = ['plus','minus']
dic = {'plus':'+','minus':'-'}

for op1 in op:
    ans = a
    if op1 == 'plus':
        ans += b
    else:
        ans -= b
    for op2 in op:
        if op2 == 'plus':
            ans += c
        else:
            ans -= c
        for op3 in op:
            if op3 == 'plus':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(f'{a}{dic[op1]}{b}{dic[op2]}{c}{dic[op3]}{d}=7')
                exit()



Fixed code:
a,b,c,d = list(map(int,input()))
op = ['plus','minus']
dic = {'plus':'+','minus':'-'}

for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a
            if op1 == 'plus':
                ans += b
            else:
                ans -= b
            if op2 == 'plus':
                ans += c
            else:
                ans -= c
            if op3 == 'plus':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(f'{a}{dic[op1]}{b}{dic[op2]}{c}{dic[op3]}{d}=7')
                exit()
Buggy 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()

Fixed 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 e(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]+e(v[0])+L[1]+e(v[1])+L[2]+e(v[2])+L[3]+'=7')
		exit()
Buggy code:
a, b, c, d = map(int, input().split())

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, sep='')


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

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='')
Buggy code:
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


S = input()
A, B, C, D = map(int, [S[0], S[1], S[2], S[3]])
dump(A, B, C, D)
for x in it.product(['+', '-'], repeat=3):
    op1, op2, op3 = x[0], x[1], x[2]
    dump(op1, op2, op3)

    def f(op, a): return a * (1 if op == '+' else -1)
    ans = A + f(op1, B) + f(op2, C)+f(op2, D)
    if(ans == 7):
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7")
        break


Fixed code:
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


S = input()
A, B, C, D = map(int, [S[0], S[1], S[2], S[3]])
dump(A, B, C, D)
for op1, op2, op3 in it.product(['+', '-'], repeat=3):
    dump(op1, op2, op3)

    def f(op, a): return a * (1 if op == '+' else -1)
    ans = A + f(op1, B) + f(op2, C) + f(op3, D)
    dump(A, f(op1, B), f(op2, C), f(op3, D))
    if(ans == 7):
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7")
        exit(0)
print("")
Buggy code:
from itertools import product
li = list(map(int, input()))

for ops in product('+-', repeat=3):
    tmp = li[0]
    for o, n in zip(ops, li[1:]):
        if o == '+':
            tmp += n
        else:
            tmp -= n
    if tmp == 7:
        ans = str(li[0])
        for o, n in zip(ops, li[1:]):
            ans += o + str(n)

print(ans)


Fixed code:
from itertools import product
li = list(map(int, input()))

for ops in product('+-', repeat=3):
    tmp = li[0]
    for o, n in zip(ops, li[1:]):
        if o == '+':
            tmp += n
        else:
            tmp -= n
    if tmp == 7:
        ans = str(li[0])
        for o, n in zip(ops, li[1:]):
            ans += o + str(n)
        ans += '=7'
        break

print(ans)
Buggy code:
S=input()
a=int(S[0])
b=int(S[1])
c=int(S[2])
d=int(S[3])
def operation(a,b,t):    
    if t==0:return a+b
    else:return a-b
def converter(t):
    if t==0:return "+"
    else:return "-"
e=0
f=0
g=0
for x in range(2):
    for y in range(2):
        for z in range(2):
            e=operation(a,b,x)
            f=operation(e,c,y)
            g=operation(f,d,z)
            if g==7:
                print(str(a)+converter(x)+str(b)+converter(y)+str(c)+converter(z)+str(d)+"=7")
                break

Fixed code:
S=input()
a=int(S[0])
b=int(S[1])
c=int(S[2])
d=int(S[3])
def operation(a,b,t):    
    if t==0:return a+b
    else:return a-b
def converter(t):
    if t==0:return "+"
    else:return "-"
e=0
f=0
g=0
for x in range(2):
    for y in range(2):
        for z in range(2):
            e=operation(a,b,x)
            f=operation(e,c,y)
            g=operation(f,d,z)
            if g==7:
                print(str(a)+converter(x)+str(b)+converter(y)+str(c)+converter(z)+str(d)+"=7")
                exit()
Buggy code:
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
s=input()
dfs(0,s[0],int(s[0]))

Fixed code:
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
    exit()
s=input()
dfs(0,s[0],int(s[0]))
Buggy code:
num = input()

#print(num)
flag = "loop"
op_list = ["+","-"]
for i in op_list:
  if flag == "break":
    break
  for j in op_list:
    if flag == "break":
      break
    for k in op_list:
      if i == "+":
        ans = int(num[0]) + int(num[1])
      else:
        ans = int(num[0]) - int(num[1])
      if i == "+":
        ans += int(num[2])
      else:
        ans -= int(num[2])
      if i == "+":
        ans += int(num[3])
      else:
        ans -= int(num[3])
      if ans == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        flag = "break"
        break

Fixed code:
num = input()

#print(num)
flag = "loop"
op_list = ["+","-"]
for i in op_list:
  if flag == "break":
    break
  for j in op_list:
    if flag == "break":
      break
    for k in op_list:
      if i == "+":
        ans = int(num[0]) + int(num[1])
      else:
        ans = int(num[0]) - int(num[1])
        
      if j == "+":
        ans += int(num[2])
      else:
        ans -= int(num[2])
        
      if k == "+":
        ans += int(num[3])
      else:
        ans -= int(num[3])
      #print(ans)
      if ans == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        flag = "break"
        break
      ans = 0
Buggy code:
a=input()
op=list("+-")
flag = False
for i in range(op):
    for j in range(op):
        for k in range(op):
            s = a[0]+i+a[1]+j+a[2]+k+a[3]
            flag = True
            if eval(s) == 7:
                break
        if flag:
            break
    if flag:
        break
print(s+"=7")

Fixed code:
a=input()
op=list("+-")
flag = False
for i in op:
    for j in op:
        for k in op:
            s = a[0]+i+a[1]+j+a[2]+k+a[3]
            if eval(s) == 7:
                flag = True
                break
        if flag:
            break
    if flag:
        break
print(s+"=7")
Buggy code:
a,b,c,d=input()
lst_1=[]
lst_2= ["+","-"]
for i in lst_2:
  for j in lst_2:
    for k in lst_2:
      lst_1.append(a+i+b+j+c+k+d)
for l in lst_1:
  if eval(l)==7:
    print(l)

Fixed code:
a,b,c,d=input()
lst_1=[]
lst_2= ["+","-"]
for i in lst_2:
  for j in lst_2:
    for k in lst_2:
      lst_1.append(a+i+b+j+c+k+d)
for l in lst_1:
  if eval(l)==7:
    print(l+"=7")
    break
Buggy code:
N=int(input())

a=N//1000
b=(N%1000)//100
c=(N%100)//10
d=N%10

ope=[-1,1]

for i in ope:
    for j in ope:
        for k in ope:
            if a+i*b+j*c+k*d==7:
                ans=[i,j,k]

l=[0]*3

for i in range(3):
    if ans[i]>0:
        l[i]="+"
    else:
        l[i]="-"

   

#all_ans=[str(a),l[0],str(b),l[1],str(c),l[2],str(d)]
all_ans=str(a)+l[0]+str(b)+l[1]+str(c)+l[2]+str(d)
print(all_ans)


Fixed code:
N=int(input())

a=N//1000
b=(N%1000)//100
c=(N%100)//10
d=N%10

ope=[-1,1]

for i in ope:
    for j in ope:
        for k in ope:
            if a+i*b+j*c+k*d==7:
                ans=[i,j,k]

l=[0]*3

for i in range(3):
    if ans[i]>0:
        l[i]="+"
    else:
        l[i]="-"

   

#all_ans=[str(a),l[0],str(b),l[1],str(c),l[2],str(d)]
all_ans=str(a)+l[0]+str(b)+l[1]+str(c)+l[2]+str(d)+"=7"
print(all_ans)
Buggy code:
import sys
A, B, C, D = map(int, input())
ops = ['+', '-']
for op1 in ops:
    tmp = A
    for op2 in ops:
        for op3 in ops:
            if op1 == '+':
                tmp += B
            else:
                tmp -= B
            if op2 == '+':
                tmp += C
            else:
                tmp -= C
            if op3 == '+':
                tmp += D
            else:
                tmp -= D
            if tmp == 7:
                print("{}{}{}{}{}{}{}=7".format(A,op1,B,op2,C,op3,D))
                sys.exit()
                  

Fixed code:
import sys
A, B, C, D = map(int, input())
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            tmp = A
            if op1 == '+':
                tmp += B
            else:
                tmp -= B
            if op2 == '+':
                tmp += C
            else:
                tmp -= C
            if op3 == '+':
                tmp += D
            else:
                tmp -= D
            if tmp == 7:
                print("{}{}{}{}{}{}{}=7".format(A,op1,B,op2,C,op3,D))
                sys.exit()
Buggy code:
s = input()
n = len(s)

def helper(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ""
    
    op_p = helper(i+1, x+int(s[i]), op + "+" + s[i])
    if op_p != "":
        return op_p
    
    op_m = helper(i+1, x-int(s[i]), op + "-" + s[i])
    if op_m != "":
        return op_m
    
    return ""

print(helper(1, int(s[0]), s[0]))

Fixed code:
s = input()
n = len(s)

def helper(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ""
    
    op_p = helper(i+1, x+int(s[i]), op + "+" + s[i])
    if op_p != "":
        return op_p
    
    op_m = helper(i+1, x-int(s[i]), op + "-" + s[i])
    if op_m != "":
        return op_m
    
    return ""


result = helper(1, int(s[0]), s[0])
if result == "":
    print(result)
else:
    print(result + "=7")
Buggy code:
import itertools
S=input()
TT=itertools.product(["+","-"],repeat=3)
for T in TT:
    A=S[0]+T[0]+S[1]+T[1]+S[2]+T[2]+S[3]
    if eval(A)==7:
        print(A)
        exit()


Fixed code:
import itertools
S=input()
TT=itertools.product(["+","-"],repeat=3)
for T in TT:
    A=S[0]+T[0]+S[1]+T[1]+S[2]+T[2]+S[3]
    if eval(A)==7:
        print(A+"=7")
        exit()
Buggy code:
S = input()

def func(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ''
    opP = func(i + 1, x + int(S[i]), op+'+'+str(S[i]))
    if opP != '':
        return opP
    opM = func(i + 1, x - int(S[i]), op+'-'+str(S[i]))
    if opM != '':
        return opM
    return ''

print(func(1, int(S[0]), str(S[0])))


Fixed code:
S = input()

def func(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ''
    opP = func(i + 1, x + int(S[i]), op+'+'+str(S[i]))
    if opP != '':
        return opP
    opM = func(i + 1, x - int(S[i]), op+'-'+str(S[i]))
    if opM != '':
        return opM
    return ''

print(func(1, int(S[0]), str(S[0])) + '=7')
Buggy code:
# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


S = sr()
ans = 0


def dfs(depth, p_list):
    global ans

    if depth == 4:
        sum_list = []
        T = S
        text = ''
        for j, p in enumerate(p_list):
            if p == 1:
                sum_list.append(int(T[:1]))
                text += T[:1] + '+'
            elif p == -1:
                sum_list.append(int(T[:1]) * -1)
                text += T[:1] + '-'
            T = T[1:]
        # print(p_list, sum_list, T)
        ans = sum(sum_list)
        if ans == 7:
            text = text[:-1]
            text += '=7'
            print(text)
            exit()

        return

    for i in range(2):
        p_list[depth] = i
        dfs(depth + 1, p_list)


def main():

    p_list = [0] * (4)
    dfs(0, p_list)

    print(ans)


main()


Fixed code:
# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


S = sr()
ans = 0


def dfs(depth, p_list):
    global ans

    if depth == 4:
        sum_list = []
        T = S
        text = ''
        for j, p in enumerate(p_list):
            if p == 1:
                sum_list.append(int(T[:1]))
            elif p == -1:
                sum_list.append(int(T[:1]) * -1)

            if len(text) == 0:
                text += T[:1]
            else:
                if p == 1:
                    text += '+' + T[:1]
                elif p == -1:
                    text += '-' + T[:1]
            T = T[1:]
        # print(p_list, sum_list)
        ans = sum(sum_list)
        if ans == 7:
            text += '=7'
            print(text)
            exit()

        return

    for i in [1, -1]:
        p_list[depth] = i
        dfs(depth + 1, p_list)


def main():

    p_list = [0] * (4)
    dfs(0, p_list)


main()
Buggy code:
a, b, c, d = input()

op_choice = ["+", "-"]

for op1 in op_choice:
    for op2 in op_choice:
        for op3 in op_choice:
            check = a + op1 + b + op2 + c + op3 + d
            if eval(check) == 7:
                print(check + "=7")


Fixed code:
a, b, c, d = input()

op_choice = ["+", "-"]

for op1 in op_choice:
    for op2 in op_choice:
        for op3 in op_choice:
            check = a + op1 + b + op2 + c + op3 + d
            if eval(check) == 7:
                print(check + "=7")
                exit()
Buggy code:
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      ops = [op[i], op[j], op[k]]
      tmp = a[0]
      for l in range(3):
        if ops[l]=='+':
          tmp = tmp + a[l+1]
        else:
          tmp = tmp - a[l+1]
      print(ops, tmp)
      if tmp==7:
        break
    if tmp==7:
      break
  if tmp==7:
    break

print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')


Fixed code:
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      ops = [op[i], op[j], op[k]]
      tmp = a[0]
      for l in range(3):
        if ops[l]=='+':
          tmp = tmp + a[l+1]
        else:
          tmp = tmp - a[l+1]
      if tmp==7:
        break
    if tmp==7:
      break
  if tmp==7:
    break

print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')
Buggy code:
S = list(input())
ops = []
lst = []

for i in range(8):
    ops.append(bin(i))
    ops[i] = ops[i][2:].zfill(3)
    print(ops[i])

for i in range(8):
    res = S[0]
    for j in range(3):
        if ops[i][j] == "0":
            res = res + "+" + S[j+1]
        else:
            res = res + "-" + S[j+1]
    if eval(res) == 7:
        res = res + "=7"
        lst.append(res)
        break

print(lst[0])

Fixed code:
S = list(input())
ops = []
lst = []

for i in range(8):
    ops.append(bin(i))
    ops[i] = ops[i][2:].zfill(3)

for i in range(8):
    res = S[0]
    for j in range(3):
        if ops[i][j] == "0":
            res = res + "+" + S[j+1]
        else:
            res = res + "-" + S[j+1]
    if eval(res) == 7:
        res = res + "=7"
        lst.append(res)
        break

print(lst[0])
Buggy code:
A,B,C,D = list(map(int,list(input())))
def plus(x):
    if x == 0:
        return '+'
    else:
        return '-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+(1-2*i)*B+(1-2*j)*C+(1-2*k)*D
            if ans == 7:
                print(str(A)+plus(i)+str(B)+plus(j)+str(C)+plus(k)+str(D)+'=7')
                break
        else:
            continue
        break

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

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

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A + (1-2*i)*B + (1-2*j)*C + (1-2*k)*D
            if ans == 7:
                print(str(A) + int_to_pm(i) + str(B) + int_to_pm(j) + str(C) + int_to_pm(k) + str(D) + '=7')
                break
        else:
            continue
        break
    else:
        continue
    break