qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = input()

s = []
for c in S:
    s.append(c)

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

    operator.append(op)

F = []
for op in operator:
    f = "".join(a+b for a, b in zip(s,op))
    F.append(f)


for fm in F:
    if eval(fm):
        print(fm + '=7')
        break


Fixed code:
S = input()

s = []
for c in S:
    s.append(c)

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

    operator.append(op)

F = []
for op in operator:
    f = "".join(a+b for a, b in zip(s,op))
    F.append(f)


for fm in F:
    if eval(fm)==7:
        print(fm + '=7')
        break
Buggy code:
a , b, c, d=list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            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')

Fixed code:
a , b, c, d=list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            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')
                exit()
Buggy code:

n = list(map(int,list(input())))
limit = 7
d = [ [] for i in range(len(n))]
op = [ [] for i in range(len(n))]

for i,val in enumerate(n):
	if i == 0:
		d[0].append(n[0])
		op[0].append("")
	else:
		for j in d[i-1]:
			d[i].append(j+val)
			d[i].append(j-val)
		for j in op[i-1]:
			op[i].append(j + "+")
			op[i].append(j + "-")


_op = op[len(n)-1][d[len(n)-1].index(limit)]

s = ""
for i,val in enumerate(n):
	s += str(val)
	if i == len(n)-1:
		break
	else:
		s += _op[i]

print(s)

Fixed code:
n = list(map(int,list(input())))
limit = 7
d = [ [] for i in range(len(n))]
op = [ [] for i in range(len(n))]

for i,val in enumerate(n):
	if i == 0:
		d[0].append(n[0])
		op[0].append("")
	else:
		for j in d[i-1]:
			d[i].append(j+val)
			d[i].append(j-val)
		for j in op[i-1]:
			op[i].append(j + "+")
			op[i].append(j + "-")


_op = op[len(n)-1][d[len(n)-1].index(limit)]

s = ""
for i,val in enumerate(n):
	s += str(val)
	if i == len(n)-1:
		break
	else:
		s += _op[i]
s += "="+str(limit)
print(s)
Buggy code:
a, b, c, d = input()
op = ["+", "-"]

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

Fixed code:
a, b, c, d = input()
op = ["+", "-"]

for op1 in op:
    for op2 in op:
        for op3 in op:
            check = a + op1 + b + op2 + c + op3 + d
            if eval(check) == 7:
                print(check + "=7")
                exit()
Buggy code:
x=int(input())
dig=[]
for i in range(1,4):
  dig.append(x%(10))
  x=x//10
dig.append(x)

d,c,b,a=dig

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

Fixed code:
x=int(input())
dig=[]
for i in range(1,4):
  dig.append(x%(10))
  x=x//10
dig.append(x)

d,c,b,a=dig

if (a+b+c+d)==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a+b+c-d)==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a+b-c+d)==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a+b-c-d)==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif (a-b+c+d)==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a-b-c+d)==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a-b+c-d)==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a-b-c-d)==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
Buggy code:
#ABC 079 C
a,b,c,d=list(input())
s="+-"

for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+s[i]+b+s[j]+c+s[k]+d==7:
                print(eval(a+s[i]+b+s[j]+c+s[k]+d))

Fixed code:
#ABC 079 C
a,b,c,d=list(input())
s="+-"

for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+s[i]+b+s[j]+c+s[k]+d)==7:
                print(str(a+s[i]+b+s[j]+c+s[k]+d)+"=7")
                exit()
Buggy code:
A, B, C, D = input()
for p in itertools.product(['+', '-'], repeat = 3):
    equ = A + p[0] + B + p[1] + C + p[2] + D
    
    if(eval(equ) == 7):
        print(equ + '=7')
        break

Fixed code:
import itertools

A, B, C, D = input()
for p in itertools.product(['+', '-'], repeat = 3):
    equ = A + p[0] + B + p[1] + C + p[2] + D
    
    if(eval(equ) == 7):
        print(equ + '=7')
        break
Buggy code:
In = list(map(int, list(input())))

import itertools
Bit = list(itertools.combinations_with_replacement(['-', '+'], 3))

for l in Bit:
    seven = In[0]
    for i, bit in enumerate(l):
        if bit == '+':
            seven += In[i+1]
        else:
            seven -= In[i+1]
    if seven == 7:
        print("{}{}{}{}{}{}{}=7".format(In[0],l[0],In[1],l[1],In[2],l[2],In[3]))

Fixed code:
In = list(map(int, list(input())))

import itertools
Bit = list(itertools.product(['+', '-'], repeat=3))

for l in Bit:
    seven = In[0]
    for i, bit in enumerate(l):
        if bit == '+':
            seven += In[i+1]
        else:
            seven -= In[i+1]
    if seven == 7:
        print("{}{}{}{}{}{}{}=7".format(In[0],l[0],In[1],l[1],In[2],l[2],In[3]))
        break
Buggy code:
from sys import exit
def dfs(i,f,sum):
  if i == n-1:
    if sum ==7:
      return 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()
n=len(s)
dfs(0, s[0],int(s[0]))

Fixed code:
from sys import exit
def dfs(i,f,sum):
  if i == n-1:
    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()
n=len(s)
dfs(0, s[0],int(s[0]))
Buggy code:
import itertools

def solve(S):
    bit_list = list(itertools.product([0, 1], repeat=3))
    
    for pattern in bit_list:
        count = int(S[0])
        ans = S[0]
        for i in range(3):
            if pattern[i] == 0:
                count += int(S[i+1])
                ans += "+" + S[i+1]
            else:
                count -= int(S[i+1])
                ans += "-" + S[i+1]
        
        if count == 7:
            print(ans)
            break
    

if __name__ == '__main__':
    S = input()
    solve(S)

Fixed code:
import itertools

def solve(S):
    bit_list = list(itertools.product([0, 1], repeat=3))
    
    for pattern in bit_list:
        count = int(S[0])
        ans = S[0]
        for i in range(3):
            if pattern[i] == 0:
                count += int(S[i+1])
                ans += "+" + S[i+1]
            else:
                count -= int(S[i+1])
                ans += "-" + S[i+1]
        
        if count == 7:
            print(ans + "=7")
            break
    

if __name__ == '__main__':
    S = input()
    solve(S)
Buggy 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()

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

ans=int(s[0])
for i in range(2):
    if i==0:
        ans+=int(s[1])
        i='+'
    else:
        ans-=int(s[1])
        i='-'
    for j in range(2):
        if j==0:
            ans+=int(s[2])
            j='+'
        else:
            ans-=int(s[2])
            j='-'
        for k in range(2):
            if k==0:
                ans+=int(s[3])
                k='+'
            else:
                ans-=int(s[3])
                k='-'
            if ans==int(7):
                print(s[0]+str(i)+s[1]+str(j)+s[2]+str(k)+s[3]+'=7')
                break
            else:
                ans=int(s[0])
        else:
            continue
        break
    else:
        continue
    break



Fixed code:
s=str(input())

ans=int(s[0])
a=ans
for i in range(2):
    ans=a
    if i==0:
        ans+=int(s[1])
        i='+'
    else:
        ans-=int(s[1])
        i='-'
    b=ans
    for j in range(2):
        ans=b
        if j==0:
            ans+=int(s[2])
            j='+'
        else:
            ans-=int(s[2])
            j='-'
        c=ans
        for k in range(2):
            ans=c
            if k==0:
                ans+=int(s[3])
                k='+'
            else:
                ans-=int(s[3])
                k='-'
            if ans==int(7):
                print(s[0]+str(i)+s[1]+str(j)+s[2]+str(k)+s[3]+'=7')
                break
        else:
            continue
        break
    else:
        continue
    break
Buggy 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")

Fixed 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")
elif a - b - c - d == 7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
Buggy code:
s=input()
listA=[0,0,0,0]
i=0
for x in s:
    listA[i]=int(x)
    i+=1
a=listA[0]
b=listA[1]
c=listA[2]
d=listA[3]
if(a+b+c+d==7):
    print("%d+%d+%d+%d==7"% (a,b,c,d))
elif(a+b+c-d==7):
    print("%d+%d+%d-%d==7"% (a,b,c,d))
elif(a+b-c+d==7):
    print("%d+%d-%d+%d==7" % (a, b, c, d))
elif(a+b-c-d==7):
    print("%d+%d-%d-%d==7" % (a, b, c, d))
elif(a-b+c+d==7):
    print("%d-%d+%d+%d==7" % (a, b, c, d))
elif(a-b-c+d==7):
    print("%d-%d-%d+%d==7" % (a, b, c, d))
elif(a-b-c-d==7):
    print("%d-%d-%d-%d==7" % (a, b, c, d))
elif(a-b+c-d==7):
    print("%d-%d+%d-%d==7" % (a, b, c, d))

Fixed code:
s=input()
listA=[0,0,0,0]
i=0
for x in s:
    listA[i]=int(x)
    i+=1
a=listA[0]
b=listA[1]
c=listA[2]
d=listA[3]
if(a+b+c+d==7):
    print("%d+%d+%d+%d=7"% (a,b,c,d))
elif(a+b+c-d==7):
    print("%d+%d+%d-%d=7"% (a,b,c,d))
elif(a+b-c+d==7):
    print("%d+%d-%d+%d=7" % (a, b, c, d))
elif(a+b-c-d==7):
    print("%d+%d-%d-%d=7" % (a, b, c, d))
elif(a-b+c+d==7):
    print("%d-%d+%d+%d=7" % (a, b, c, d))
elif(a-b-c+d==7):
    print("%d-%d-%d+%d=7" % (a, b, c, d))
elif(a-b-c-d==7):
    print("%d-%d-%d-%d=7" % (a, b, c, d))
elif(a-b+c-d==7):
    print("%d-%d+%d-%d=7" % (a, b, c, d))
Buggy code:
import itertools
num = str(input())
sign = ("+", "-")
for s1, s2, s3 in itertools.product(sign, repeat=3):
    result = num[0] + s1 + num[1] + s2 + num[2] + s3 + num[3]
    if eval(result) == 7:
        print(result)
        break

Fixed code:
import itertools
num = str(input())
sign = ("+", "-")
for s1, s2, s3 in itertools.product(sign, repeat=3):
    result = num[0] + s1 + num[1] + s2 + num[2] + s3 + num[3]
    if eval(result) == 7:
        print(result+"=7")
        break
Buggy code:
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = [0]*3

for i in range(2):
    for j in range(2):
        for k in range(2):
            if(A+B*op**(i+1)+C*op**(j+1)+D*op**(k+1) == 7):
                sign[0] = i
                sign[1] = j
                sign[2] = k
                quit()

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "-"
    else:
        sign[n] = "+"

print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")

Fixed code:
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = []

for i in range(2):
    for j in range(2):
        for k in range(2):
            if(A+B*op**i+C*op**j+D*op**k == 7):
                sign.append(i)
                sign.append(j)
                sign.append(k)

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "+"
    else:
        sign[n] = "-"

print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")
Buggy code:
from itertools import combinations_with_replacement
x=[a for a in input()]
a=('+','-')
s=list(combinations_with_replacement(a,3))
for op in s:
     ops=x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]
     if eval(ops)==7:
          print(ops+'=7')
          break

Fixed code:
from itertools import product
x=[a for a in input()]
a=('+','-')
s=list(product(a,repeat=3))
for op in s:
     ops=x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]
     if eval(ops)==7:
          print(ops+'=7')
          break
Buggy 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])


Fixed 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+int(S[i+1]))
        make7(i+1, f+"-"+S[i+1], sum-int(S[i+1]))


S = input()
n = len(S)

make7(0, S[0], int(S[0]))
Buggy code:
from itertools import product
A,B,C,D = list(input())
for k in list(product(['+','-'],repeat=3)):
    k = A + k[0] + B + k[1] + C + k[2] + D
    if eval(k) == 7:
        print('{}=7'.format(k))

Fixed code:
from itertools import product
A,B,C,D = list(input())
for k in list(product(['+','-'],repeat=3)):
    k = A + k[0] + B + k[1] + C + k[2] + D
    if eval(k) == 7:
        print('{}=7'.format(k))
        break
Buggy code:
a, b, c, d = map(int, input())
l = [a+b+c+d, a+b+c-d, a+b-c+d, a+b-c-d, a-b+c+d, a-b+c-d, a-b-c+d, a-b-c-d]

if l.index(7) == 0:
    print(a, '+', b, '+', c, '+', d, '= 7')
elif l.index(7) == 1:
    print(a, '+', b, '+', c, '-', d, '= 7')
elif l.index(7) == 2:
    print(a, '+', b, '-', c, '+', d, '= 7')
elif l.index(7) == 3:
    print(a, '+', b, '-', c, '-', d, '= 7')
elif l.index(7) == 4:
    print(a, '-', b, '+', c, '+', d, '= 7')
elif l.index(7) == 5:
    print(a, '-', b, '+', c, '-', d, '= 7')
elif l.index(7) == 6:
    print(a, '-', b, '-', c, '+', d, '= 7')
elif l.index(7) == 7:
    print(a, '-', b, '-', c, '-', d, '= 7')

Fixed code:
a, b, c, d = map(int, input())
l = [a+b+c+d, a+b+c-d, a+b-c+d, a+b-c-d, a-b+c+d, a-b+c-d, a-b-c+d, a-b-c-d]

if l.index(7) == 0:
    print(a, '+', b, '+', c, '+', d, '=7', sep='')
elif l.index(7) == 1:
    print(a, '+', b, '+', c, '-', d, '=7', sep='')
elif l.index(7) == 2:
    print(a, '+', b, '-', c, '+', d, '=7', sep='')
elif l.index(7) == 3:
    print(a, '+', b, '-', c, '-', d, '=7', sep='')
elif l.index(7) == 4:
    print(a, '-', b, '+', c, '+', d, '=7', sep='')
elif l.index(7) == 5:
    print(a, '-', b, '+', c, '-', d, '=7', sep='')
elif l.index(7) == 6:
    print(a, '-', b, '-', c, '+', d, '=7', sep='')
elif l.index(7) == 7:
    print(a, '-', b, '-', c, '-', d, '=7', sep='')
Buggy code:
import sys
a,b,c,d = map(int, list(input()))
x = [1,-1]
for i in x:
  for j in x:
    for k in x:
      if a+i*b+j*c+k*d==7:
        ans = str(a)
        ans += "+" if i==1 else"-"
        ans += str(b)
        ans += "+" if j==1 else"-"
        ans += str(c)
        ans += "+" if k==1 else"-"
        ans += str(d)
        print(ans)
        sys.exit()

Fixed code:
import sys
a,b,c,d = map(int, list(input()))
x = [1,-1]
for i in x:
  for j in x:
    for k in x:
      if a+i*b+j*c+k*d==7:
        ans = str(a)
        ans += "+" if i==1 else "-"
        ans += str(b)
        ans += "+" if j==1 else "-"
        ans += str(c)
        ans += "+" if k==1 else "-"
        ans += str(d)
        ans += "=7"
        print(ans)
        sys.exit()
Buggy code:
import itertools
N=[int(x) for x in input()]
op=['+','-']
for op1 in op:
  if op1=='+': ans=N[0]+N[1]
  else: ans=N[0]-N[1]
  for op2 in op:
    if op2=='+': ans+=N[2]
    else: ans-=N[2]
    for op3 in op:
      if op3=='+': ans+=N[3]
      else: ans-=N[3]
      if ans==7:
        print(N[0],end="")
        print(op1,end="")
        print(N[1],end="")
        print(op2,end="")
        print(N[2],end="")
        print(op3,end="")
        print(N[3],end="")
        print("=7")
        exit()

Fixed code:
import itertools
N=[int(x) for x in input()]
op=['+','-']
for op1 in op:
  for op2 in op:
    for op3 in op:
      if op1=='+': ans=N[0]+N[1]
      else: ans=N[0]-N[1]
      if op2=='+': ans+=N[2]
      else: ans-=N[2]
      if op3=='+': ans+=N[3]
      else: ans-=N[3]
      if ans==7:
        print(N[0],end="")
        print(op1,end="")
        print(N[1],end="")
        print(op2,end="")
        print(N[2],end="")
        print(op3,end="")
        print(N[3],end="")
        print("=7")
        exit()
Buggy 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))
if a + b - c + d == 7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
if a - b + c + d == 7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
if a + b - c - d == 7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
if a - b - c + d == 7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
if a - b + c - d == 7:
    print("{}-{}+{}-{}=7".format(a, b, c, d))
if a - b - c - d == 7:
    print("{}-{}-{}-{}=7".format(a, b, c, d))


Fixed 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))
Buggy code:
from itertools import product
abcd = list(map(int, list(input())))


for ops in product(['+', '-'], repeat=3):
    temp = abcd[0]
    ans = str(abcd[0])
    for i, op in enumerate(ops):
        if op=='+':
            temp+=abcd[i+1]
            ans+='+'+str(abcd[i+1])
        else:
            temp-=abcd[i+1]
            ans+='+'+str(abcd[i+1])
    if temp==7:
        ans+='=7'
        break
print(ans)

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


for ops in product(['+', '-'], repeat=3):
    temp = abcd[0]
    ans = str(abcd[0])
    for i, op in enumerate(ops):
        if op=='+':
            temp+=abcd[i+1]
            ans+='+'+str(abcd[i+1])
        else:
            temp-=abcd[i+1]
            ans+='-'+str(abcd[i+1])
    if temp==7:
        ans+='=7'
        break
print(ans)
Buggy code:
import sys
df = list(map(int, list(str(input()))))
print(df)
counter = 0
for i in range(2**3):
    bin_i = format(i, '03b')
    counter += df[0]
    for j in range(3):
        print(j, counter)
        if bin_i[j] == '1':
            counter -= df[j+1]
        else:
            counter += df[j+1]
    if counter == 7:
        result = str(df[0])
        for j in range(3):
            if bin_i[j] =='0':
                result += '+' + str(df[j+1])
            else:
                result += '-' + str(df[j+1])
        result += '=7'
        print(result)
        sys.exit()
    else:
        print(counter)
        counter = 0

Fixed code:
import sys
df = list(map(int, list(str(input()))))
counter = 0
for i in range(2**3):
    bin_i = format(i, '03b')
    counter += df[0]
    for j in range(3):
        if bin_i[j] == '1':
            counter -= df[j+1]
        else:
            counter += df[j+1]
    if counter == 7:
        result = str(df[0])
        for j in range(3):
            if bin_i[j] =='0':
                result += '+' + str(df[j+1])
            else:
                result += '-' + str(df[j+1])
        result += '=7'
        print(result)
        sys.exit()
    else:
        counter = 0
Buggy code:
#!/usr/bin/env python3
import sys
import operator
import itertools

def op(op_str):
    funcs = {
            "+":operator.add,
            "-":operator.sub
            }
    return funcs[op_str]

def solve(A,B,C,D):
    for o in itertools.product(["+","-"], repeat = 3):
        ret = op(o[0])(A,B)
        ret = op(o[1])(C,ret)
        ret = op(o[2])(D,ret)
        if ret == 7:
            print(f"{A}{o[0]}{B}{o[1]}{C}{o[2]}{D}=7")


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    L = [int(c) for c in S]
    
    solve(*L)

if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python3
import sys
import operator
import itertools

def op(op_str):
    funcs = {
            "+":operator.add,
            "-":operator.sub
            }
    return funcs[op_str]

def solve(A,B,C,D):
    for o in itertools.product(["+","-"], repeat = 3):
        ret = op(o[0])(A,B)
        ret = op(o[1])(ret,C)
        ret = op(o[2])(ret,D)
        if ret == 7:
            print("{0}{1}{2}{3}{4}{5}{6}=7".format(A,o[0],B,o[1],C,o[2],D))
            return


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    L = [int(c) for c in S]
    
    solve(*L)

if __name__ == '__main__':
    main()