qyliang/CodeNanoFix huggingface dataset:
Buggy code:
i=int(input())
d=i%10
c=(i//10)%10
b=(i//100)%10
a=i//1000
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="")
else:
    print(a,"-",b,"-",c,"-",d,"=7",sep="")

Fixed code:
i=int(input())
d=i%10
c=(i//10)%10
b=(i//100)%10
a=i//1000
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="")
else:
    print(a,"-",b,"-",c,"-",d,"=7",sep="")
Buggy code:
a=list(input())
for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            ans=a[0]+i+a[1]+j+a[2]+k+a[3]
            if eval(ans)==7:
                print(ans+"==7")
                exit()

Fixed code:
a=list(input())
for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            ans=a[0]+i+a[1]+j+a[2]+k+a[3]
            if eval(ans)==7:
                print(ans+"=7")
                exit()
Buggy code:
A,B,C,D = list(map(int, input()))

for op1 in ["+", "-"]:
    tmp1 = A+B if op1=="+" else A-B
    for op2 in ["+", "-"]:
        tmp2 = tmp1+C if op2=="+" else tmp1-C
        for op3 in ["+", "-"]:
            tmp3 = tmp2+D if op3=="+" else tmp2-D
            if tmp3==7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7"
                print(ans)
                break
    
            


Fixed code:
A,B,C,D = list(map(int, input()))
flag = 0
for op1 in ["+", "-"]:
    if flag:
        break
    tmp1 = A+B if op1=="+" else A-B
    for op2 in ["+", "-"]:
        if flag:
            break
        tmp2 = tmp1+C if op2=="+" else tmp1-C
        for op3 in ["+", "-"]:
            if flag:
                break
            tmp3 = tmp2+D if op3=="+" else tmp2-D
            if tmp3==7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7"
                print(ans)
                flag = 1
                break
Buggy code:
from itertools import product
s = list(input())
n = len(s)

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

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


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

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

for i in range(2 ** (n-1)):
    formula = s[0]
    for j, k in zip(pattern[i], s[1:]):
        formula += (j + k)
    if eval(formula) == 7:
        print("{}=7".format(formula))
        break
Buggy code:
n = input()
op = [bin(i)[2:].zfill(3) for i in range(8)]
ans = [n[0]]
for i in range(8):
    cnt = int(n[0])
    for j in range(3):
        if op[i][j] == "0":
            cnt += int(n[j+1])
            ans.append("+")
        else:
            cnt -= int(n[j+1])
            ans.append("-")
        ans.append(n[j+1])
    if cnt == 7:
        ans += ["=", "7"]
        print("".join(ans))
        exit()



Fixed code:
n = input()
op = [bin(i)[2:].zfill(3) for i in range(8)]
for i in range(8):
    cnt = int(n[0])
    ans = [n[0]]
    for j in range(3):
        if op[i][j] == "0":
            cnt += int(n[j+1])
            ans.append("+")
        else:
            cnt -= int(n[j+1])
            ans.append("-")
        ans.append(n[j+1])
    if cnt == 7:
        ans += ["=", "7"]
        print("".join(ans))
        exit()
Buggy code:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

mark = ["+", "-"]

for m1 in mark:
  for m2 in mark:
    for m3 in mark:
      if eval("{0} {1} {2} {3} {4} {5} {6}".format(A,m1,B,m2,C,m3,D)) == 7:
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(A,m1,B,m2,C,m3,D))
        break

Fixed code:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

mark = ["+", "-"]

for m1 in mark:
  for m2 in mark:
    for m3 in mark:
      if eval("{0} {1} {2} {3} {4} {5} {6}".format(A,m1,B,m2,C,m3,D)) == 7:
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(A,m1,B,m2,C,m3,D))
        exit()
Buggy code:
S=input()
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])

op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      if eval("A {} B {} C {} D".format(i, j, k)) == 7:
        print("{}{}{}{}{}{}{}{}{}".format(A, i, B, j, C, k, D))
        exit()

Fixed code:
S=input()
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])

op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      if eval("A {} B {} C {} D".format(i, j, k)) == 7:
        print("{}{}{}{}{}{}{}=7".format(A, i, B, j, C, k, D))
        exit()
Buggy 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 + one*b + two*c + three*d == 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):
        r, t, y = change(q), change(w), change(e)
        print(str(a)+r+str(b)+t+str(c)+y+str(d)+"=7")
        break
      else:
        pass  
  break

Fixed 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 + one*b + two*c + three*d == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  
flag = False
for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        r, t, y = change(q), change(w), change(e)
        print(str(a)+r+str(b)+t+str(c)+y+str(d)+"=7")
        flag = True
        break
    if flag:
      break
  if flag:
    break
Buggy code:
import itertools
moji = str(input())
A,B,C,D = int(moji[0]),int(moji[1]),int(moji[2]),int(moji[3])

Bn = [B,B*-1]
Cn = [C,C*-1]
Dn = [D,D*-1]
flg = 0
for i,j,k in itertools.product(Bn, Cn,Dn):
    X = A + i + j + k
    if X == 7:
        break
    
print(str(A) + (str(i),"+"+str(i))[i >= 0]+ (str(j),"+"+str(j))[j >= 0]+ (str(k),"+"+str(k))[k >= 0])    


Fixed code:
import itertools
moji = str(input())
A,B,C,D = int(moji[0]),int(moji[1]),int(moji[2]),int(moji[3])

Bn = [B,B*-1]
Cn = [C,C*-1]
Dn = [D,D*-1]
flg = 0
for i,j,k in itertools.product(Bn, Cn,Dn):
    X = A + i + j + k
    if X == 7:
        break
    
print(str(A) + (str(i),"+"+str(i))[i >= 0]+ (str(j),"+"+str(j))[j >= 0]+ (str(k),"+"+str(k))[k >= 0]+"=7")
Buggy code:
num = input()

x = ["+", "-"]

for i in x:
  for j in x:
    for k in x:
      n = eval(num[0]+i+num[1]+j+num[2]+k+num[3])
      if n == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        break
    break
  break

Fixed code:
num = input()

x = ["+", "-"]

for i in x:
  for j in x:
    for k in x:
      n = eval(num[0]+i+num[1]+j+num[2]+k+num[3])
      if n == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        exit()
Buggy code:
n = input()
a, b, c, d = int(n[0]), int(n[1]), int(n[2]), int(n[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))

Fixed code:
n = input()
a, b, c, d = int(n[0]), int(n[1]), int(n[2]), int(n[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))
else:
    print('%d-%d-%d-%d=7' % (a, b, c, d))
Buggy code:
import sys
input = sys.stdin.readline
ABCD = list(map(int, list(input())[: -1]))
t = [[] for _ in range(4)]
t[0].append((ABCD[0], ""))
for i in range(3):
  for j in range(len(t[i])):
    t[i + 1].append((t[i][j][0] + ABCD[i + 1], t[i][j][1] + "+"))
    t[i + 1].append((t[i][j][0] - ABCD[i - 1], t[i][j][1] + "-"))
#print(t)
for i in range(len(t[-1])):
  if t[-1][i][0] == 7:
    print(str(ABCD[0]) + t[-1][i][1][0] + str(ABCD[1]) + t[-1][i][1][1] + str(ABCD[2]) + t[-1][i][1][2] + str(ABCD[3]) + "=7")
    exit(0)

Fixed code:
import sys
input = sys.stdin.readline
ABCD = list(map(int, list(input())[: -1]))
t = [[] for _ in range(4)]
t[0].append((ABCD[0], ""))
for i in range(3):
  for j in range(len(t[i])):
    t[i + 1].append((t[i][j][0] + ABCD[i + 1], t[i][j][1] + "+"))
    t[i + 1].append((t[i][j][0] - ABCD[i + 1], t[i][j][1] + "-"))
#print(t)
for i in range(len(t[-1])):
  if t[-1][i][0] == 7:
    print(str(ABCD[0]) + t[-1][i][1][0] + str(ABCD[1]) + t[-1][i][1][1] + str(ABCD[2]) + t[-1][i][1][2] + str(ABCD[3]) + "=7")
    exit(0)
Buggy code:
a, b, c, d = input()
op = ["+", "-"]
for i in op:
  for j in op:
    for k in op:
      result = a + i + b + j + c + k + d
      if eval(result) == 7:
        print(result + "=7")

Fixed code:
a, b, c, d = input()
op = ["+", "-"]
for i in op:
  for j in op:
    for k in op:
      result = a + i + b + j + c + k + d
      if eval(result) == 7:
        print(result + "=7")
        exit()
Buggy code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

k = [
[1, 1, 1],
[1, 1, -1],
[1, -1, 1],
[1, -1, -1],
[-1, 1, 1],
[-1, 1, -1],
[-1, -1, 1],
[-1, -1, -1]]

p = ""

for i in k:
  if (a + b * i[0] + c * i[1] + d * i[2]) == 7:
    p += str(a)
    p += "+" if i[0] == 1 else "-"
    p += str(b)
    p += "+" if i[1] == 1 else "-"
    p += str(c)
    p += "+" if i[2] == 1 else "-"
    p += str(d)
    p += "=7"
    print(p)
    p = ""

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

k = [
[1, 1, 1],
[1, 1, -1],
[1, -1, 1],
[1, -1, -1],
[-1, 1, 1],
[-1, 1, -1],
[-1, -1, 1],
[-1, -1, -1]]

p = ""

for i in k:
  if (a + b * i[0] + c * i[1] + d * i[2]) == 7:
    p += str(a)
    p += "+" if i[0] == 1 else "-"
    p += str(b)
    p += "+" if i[1] == 1 else "-"
    p += str(c)
    p += "+" if i[2] == 1 else "-"
    p += str(d)
    p += "=7"
    print(p)
    break
Buggy code:
x = int(input())
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d))
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d))
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d))
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d))
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d))
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d))
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d))
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d))

Fixed code:
x = input()
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[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:
def main():
    s = input()

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

    for i in range(2):
        tmp = 0
        if i % 2 == 0:
            tmp = a + b 
        else:
            tmp = a - b
        for j in range(2):
            if j % 2 == 0:
                tmp += c
            else:
                tmp -= c
            for k in range(2):
                if k % 2 == 0:
                    tmp += d
                else:
                    tmp -= d
                if tmp == 7:
                    op1 = '+' if i % 2 == 0 else '-'
                    op2 = '+' if j % 2 == 0 else '-'
                    op3 = '+' if k % 2 == 0 else '-'
                    print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                    exit()
            

    # print(i,j,k,tmp)

if __name__ == '__main__':
    main()

Fixed code:
def main():
    s = input()

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

    for i in range(2):
        tmp = 0
        if i % 2 == 0:
            tmp = a + b 
        else:
            tmp = a - b
        for j in range(2):
            if j % 2 == 0:
                hoge1 = tmp
                tmp += c
            else:
                tmp = hoge1
                tmp -= c
            for k in range(2):
                if k % 2 == 0:
                    hoge = tmp
                    tmp += d
                else:
                    tmp = hoge
                    tmp -= d
                if tmp == 7:
                    op1 = '+' if i % 2 == 0 else '-'
                    op2 = '+' if j % 2 == 0 else '-'
                    op3 = '+' if k % 2 == 0 else '-'
                    print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                    exit()
            

    # print(i,j,k,tmp)

if __name__ == '__main__':
    main()
Buggy code:
s = input()

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

one = -1
flg = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			if a + b*one**i + c*one**j + d*one**k == 7:
				print(i,j,k)
				flg = True
				break
		if flg:
			break
	if flg:
		break
                
if i == 0 :
	i_flg = "+"
else:
	i_flg = "-"

if j == 0 :
	j_flg = "+"
else:
	j_flg = "-"

if k == 0 :
	k_flg = "+"
else:
	k_flg = "-"

print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')

Fixed code:
s = input()

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

one = -1
flg = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			if a + b*one**i + c*one**j + d*one**k == 7:
				flg = True
				break
		if flg:
			break
	if flg:
		break
                
if i == 0 :
	i_flg = "+"
else:
	i_flg = "-"

if j == 0 :
	j_flg = "+"
else:
	j_flg = "-"

if k == 0 :
	k_flg = "+"
else:
	k_flg = "-"

print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')
Buggy code:
# -*- coding: utf-8 -*-
abcd = [int(_) for _ in list(input())]
op = [0, 1]


def cal(ops, abcd, tsum):
    if ops:
        if ops.pop(0):
            _ = abcd.pop(0)
            return cal(ops, abcd, tsum + _)
        else:
            _ = abcd.pop(0)
            return cal(ops, abcd, tsum - _)
    else:
        return tsum


for op1 in op:
    for op2 in op:
        for op3 in op:
            ops = [op1, op2, op3]
            if cal(ops, abcd[1:], abcd[0]) == 7:
                ops = [op1, op2, op3]
                break

abcd = [str(_) for _ in abcd]
ops = ['+' if op else '-' for op in ops]
tmp = [abcd[i] + _ for i, _ in enumerate(ops)]
tmp.append(abcd[-1])
print(''.join(tmp) + '=7')

Fixed code:
# -*- coding: utf-8 -*-
abcd = [int(_) for _ in list(input())]
op = [0, 1]


def cal(ops, abcd):
    if ops:
        op = ops.pop(0)
        _ = abcd.pop(0)
        if op:
            abcd[0] = _ + abcd[0]
            return cal(ops, abcd)
        else:
            abcd[0] = _ - abcd[0]
            return cal(ops, abcd)
    else:
        return abcd[0]


for op1 in op:
    for op2 in op:
        for op3 in op:
            _ = abcd[:]
            __ = [op1, op2, op3]
            if cal(__, _) == 7:
                ops = [op1, op2, op3]

abcd = [str(_) for _ in abcd]
ops = ['+' if op else '-' for op in ops]
tmp = [abcd[i] + _ for i, _ in enumerate(ops)]
tmp.append(abcd[-1])
print(''.join(tmp) + '=7')
Buggy code:
from itertools import product

s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

ops = product([1,-1],repeat=3)

for op in ops:
  test = a + b * op[0] + c * op[1] + d * op[2]
  if test == 7:
    _op = [""]*3
    for i in range(3):
      _op[i] = "+" if op[i] else "-"
    print("{}{}{}{}{}{}{}=7".format(a,_op[0],b,_op[1],c,_op[2],d))
    exit()
print(-1)

Fixed code:
from itertools import product

s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

ops = product([1,-1],repeat=3)

for op in ops:
  test = a + b * op[0] + c * op[1] + d * op[2]
  if test == 7:
    _op = [""]*3
    for i in range(3):
      _op[i] = "+" if op[i] == 1 else "-"
    print("{}{}{}{}{}{}{}=7".format(a,_op[0],b,_op[1],c,_op[2],d))
    exit()
print(-1)
Buggy code:
import itertools
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

l = [0] * 8
l[0] = a + b + c + d
l[1] = a + b + c - d
l[2] = a + b - c + d
l[3] = a + b - c - d
l[4] = a - b + c + d
l[5] = a - b + c - d
l[6] = a - b - c + d
l[7] = a - b - c - d

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

Fixed code:
import itertools
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

l = [0] * 8
l[0] = a + b + c + d
l[1] = a + b + c - d
l[2] = a + b - c + d
l[3] = a + b - c - d
l[4] = a - b + c + d
l[5] = a - b + c - d
l[6] = a - b - c + d
l[7] = a - b - c - d

if l[0] == 7:
  print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif l[1] == 7:
  print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif l[2] == 7:
  print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif l[3] == 7:
  print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif l[4] == 7:
  print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif l[5] == 7:
  print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif l[6] == 7:
  print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif l[7] == 7:
  print('{}-{}-{}-{}=7'.format(a, b, c, d))
Buggy code:
import sys
from collections import defaultdict
a = input()
alst = [0, 1]
blst = [0, 1]
clst = [0, 1]
ans = ''
for i in alst:
    for j in blst:
        for k in clst:
            tmp = 0
            ans = ''
            if i == 0:
                tmp = int(a[0]) + int(a[1])
                ans = a[0] + '+' + a[1]
            else:
                tmp = int(a[0]) - int(a[1])
                ans = a[0] + '-' + a[1]
            if j == 0:
                tmp = tmp + int(a[2])
                ans = ans + '+' + a[2]
            else:
                tmp = tmp - int(a[2])
                ans = ans + '-' + a[2]
            if k == 0:
                tmp = tmp + int(a[3])
                ans = ans + '+' + a[3]
            else:
                tmp = tmp - int(a[3])
                ans = ans + '-' + a[3]
            if tmp == 7:
                print(ans)
                sys.exit()

Fixed code:
import sys
from collections import defaultdict
a = input()
alst = [0, 1]
blst = [0, 1]
clst = [0, 1]
ans = ''
for i in alst:
    for j in blst:
        for k in clst:
            tmp = 0
            ans = ''
            if i == 0:
                tmp = int(a[0]) + int(a[1])
                ans = a[0] + '+' + a[1]
            else:
                tmp = int(a[0]) - int(a[1])
                ans = a[0] + '-' + a[1]
            if j == 0:
                tmp = tmp + int(a[2])
                ans = ans + '+' + a[2]
            else:
                tmp = tmp - int(a[2])
                ans = ans + '-' + a[2]
            if k == 0:
                tmp = tmp + int(a[3])
                ans = ans + '+' + a[3]
            else:
                tmp = tmp - int(a[3])
                ans = ans + '-' + a[3]
            if tmp == 7:
                print(ans + '=7')
                sys.exit()
Buggy code:
import sys
s=input()
a=[int(s[i]) for i in range(4)]
for b in [a[1],-a[1]]:
    for c in[a[2],-a[2]]:
        for d in [a[3],-a[3]]:
            if a[0]+b+c+d==7:
                s=str(a[0])
                for x in [b,c,d]:
                    s+="+"+str(x) if x>0 else str(x)
                s+="=7"
                print(s)
                sys.exit()

Fixed code:
import sys
s=input()
a=[int(s[i]) for i in range(4)]
for b in [a[1],-a[1]]:
    for c in[a[2],-a[2]]:
        for d in [a[3],-a[3]]:
            if a[0]+b+c+d==7:
                s=str(a[0])
                for x in [b,c,d]:
                    s+="+"+str(x) if x>=0 else str(x)
                s+="=7"
                print(s)
                sys.exit()
Buggy code:
import itertools

A, B, C, D = [int(s) for s in list(input())]
print('A:{}, B:{}, C:{}, D:{}'.format(A, B, C, D))

symbols = ['+', '-']
for s1, s2, s3 in itertools.product(symbols, symbols, symbols):
    N = 0
    N = A + B if s1 == '+' else A - B
    N = N + C if s2 == '+' else N - C
    N = N + D if s3 == '+' else N - D
    if N == 7:
        print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N))
        break


Fixed code:
import itertools

A, B, C, D = [int(s) for s in list(input())]

symbols = ['+', '-']
for s1, s2, s3 in itertools.product(symbols, symbols, symbols):
    N = 0
    N = A + B if s1 == '+' else A - B
    N = N + C if s2 == '+' else N - C
    N = N + D if s3 == '+' else N - D
    if N == 7:
        print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N))
        break
Buggy code:
N = input()
n = [int(N[i]) for i in range(4)]  


def addd(lista,op):
    cnt = lista[0]


    tmp = [lista[0]]
    for i in range(len(op)):
        if op[i]==0:
            cnt+=lista[i+1]
            tmp.append("+")
            tmp.append(lista[i+1])
        else:
            cnt -=lista[i+1]
            tmp.append("-")
            tmp.append(lista[i+1])
    if cnt ==7:
        tmp.append("=7")
        return tmp
    else:
        False

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = addd(n,[i,j,k])
            if ans != False:
                print("".join([str(n) for n in ans]))
                exit()
    




Fixed code:
N = input()
n = [int(N[i]) for i in range(4)]  

def addd(lista,op):
    cnt = lista[0]


    tmp = [lista[0]]
    for i in range(len(op)):
        if op[i]==0:
            cnt+=lista[i+1]
            tmp.append("+")
            tmp.append(lista[i+1])
        else:
            cnt -=lista[i+1]
            tmp.append("-")
            tmp.append(lista[i+1])
    if cnt ==7:
        tmp.append("=7")
        return tmp
    else:
        return False

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = addd(n,[i,j,k])
            if ans != False:
                print("".join([str(n) for n in ans]))
                exit()
Buggy code:
S=input()
size = len(S)
pmlist = [format(i,'010b').replace('0','+').replace('1', '-') for i in range(2**(size-1))]
for pm in pmlist:
    eq = ''.join([S[i]+pm[i] for i in range(size-1)]+[S[size-1]])
    if eval(eq) == 7:
        break
print(eq+'=7')


Fixed code:
S=input()
size = len(S)
pmlist = [format(i,'0'+str(size-1)+'b').replace('0','+').replace('1', '-') for i in range(2**(size-1))]
for pm in pmlist:
    eq = ''.join([S[i]+pm[i] for i in range(size-1)]+[S[size-1]])
    if eval(eq) == 7:
        break
print(eq+'=7')