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


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

f = abcd[0]
dfs(0, f, int(f))

Fixed code:
abcd = input()

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

    else:
        dfs(i+1, s + "+" + abcd[i+1], sum + int(abcd[i+1]))
        dfs(i+1, s + "-" + abcd[i+1], sum - int(abcd[i+1]))

dfs(0, abcd[0], int(abcd[0]))
Buggy code:
a,b,c,d = map(int, input().split())

if a + b + c + d == 7:
    print('{a}+{b}+{c}+{d}=7'.format(a,b,c,d))
elif a + b + c - d == 7:
    print('{a}+{b}+{c}-{d}=7'.format(a,b,c,d))
elif a + b - c + d == 7:
    print('{a}+{b}-{c}+{d}=7'.format(a,b,c,d))
elif a + b - c - d == 7:
    print('{a}+{b}-{c}-{d}=7'.format(a,b,c,d))
elif a - b + c + d == 7:    
    print('{a}-{b}+{c}+{d}=7'.format(a,b,c,d))
elif a - b + c - d == 7:       
    print('{a}-{b}+{c}-{d}=7'.format(a,b,c,d))
elif a - b - c + d == 7:     
    print('{a}-{b}-{c}+{d}=7'.format(a,b,c,d))
elif a - b - c - d == 7:    
    print('{a}-{b}-{c}-{d}=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:
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

if __name__=='__main__':
    str = input()
    signs_comb = list(itertools.combinations_with_replacement([1, -1], 3))
    for signs in signs_comb:
        sum = int(str[0])
	for i in range(3):
            sum += signs[i] * int(str[i + 1])
        if sum == 7:
	    sign_char = ['+' if i==1 else '-' for i in signs]
            break
    exp = str[0] + sign_char[0] + str[1] + sign_char[1] + str[2] + sign_char[2] + str[3] + '=7'
    print(exp)



Fixed code:
#!/usr/bin/python3                                                                                                                                                                                          

import itertools

if __name__=='__main__':
    str = input()
    signs_comb = list(itertools.product([1, -1], repeat=3))
    for signs in signs_comb:
        sum = int(str[0])
        for i in range(3):
            sum += signs[i] * int(str[i + 1])
        if sum == 7:
            sign_char = ['+' if i==1 else '-' for i in signs]
            break
    exp = str[0] + sign_char[0] + str[1] + sign_char[1] + str[2] + sign_char[2] + str[3] + '=7'
    print(exp)
Buggy 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(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))

Fixed 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))
Buggy code:
from itertools import product

n = input()
ops = product('+-', repeat=3)

for op in ops:
    fm = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
    if eval(fm) == 7:
        print(fm + '=7')

Fixed code:
from itertools import product

n = input()
ops = product('+-', repeat=3)

for op in ops:
    fm = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
    if eval(fm) == 7:
        print(fm + '=7')
        break
Buggy code:
import itertools
x=list(input())

for lst in itertools.product(['+','-'],repeat=3)
  sum=int(x[0])
  for i in range(3):
    if lst[i]=='+':
      sum+=int(x[i+1])
    else:
      sum-=int(x[i+1])
  if sum==7:
    print(x[0]+lst[0]+x[1]+lst[1]+x[2]+lst[2]+x[3]+'=7')
    break

Fixed code:
import itertools
x=list(input())

for lst in itertools.product(['+','-'],repeat=3):
  sum=int(x[0])
  for i in range(3):
    if lst[i]=='+':
      sum+=int(x[i+1])
    else:
      sum-=int(x[i+1])
  if sum==7:
    print(x[0]+lst[0]+x[1]+lst[1]+x[2]+lst[2]+x[3]+'=7')
    break
Buggy code:
a=list(input())
for i in range(4):
  a[i]=int(a[i])
x=sum(a)-7
dict={0:'+',1:'-'}
for i in range(2):
  for j in range(2):
    for k in range(2):
        if x==(i*a[1]+j*a[2]+k*a[3])*2:
          print(a[0],dict[i],a[1],dict[j],a[2],dict[k],a[3],'=7',sep='')
          break

Fixed code:
a=list(input())
for i in range(4):
  a[i]=int(a[i])
x=sum(a)-7
dict={0:'+',1:'-'}
ans=0
for i in range(2):
  for j in range(2):
    for k in range(2):
        if x==(i*a[1]+j*a[2]+k*a[3])*2:
          print(a[0],dict[i],a[1],dict[j],a[2],dict[k],a[3],'=7',sep='')
          ans=1
        if ans==1:
          break
    if ans==1:
      break
  if ans==1:
    break
Buggy code:
s=input()
op=["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            formula=s[0]+op[i]+s[1]+op[j]+s[2]+op[k]+s[3]
            if eval(formula)==7:
                print(formula+"==7")
                exit(0)

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

plusminus = ['+', '-']

ans = []

def calc(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    else:
        ValueError

def cnt_calc(a, op1, op2, op3):
    return calc(
                int(a[3]),
                calc(
                    int(a[2]),
                    calc(
                        int(a[0]), int(a[1]), op1
                    ),
                    op2
                ),
                op3
            )


for i in plusminus:
    for j in plusminus:
        for k in plusminus:
            if cnt_calc(a, i, j, k) == 7:
                print(a[0] + i + a[1] + j + a[2] + k + a[3] + '=7')
                exit(0)




Fixed code:
a = input()

plusminus = ['+', '-']

def calc(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    else:
        ValueError

def cnt_calc(a, op1, op2, op3):
    return calc(
                int(a[3]),
                calc(
                    int(a[2]),
                    calc(
                        int(a[0]), int(a[1]), op1
                    ),
                    op2
                ),
                op3
            )


for i in plusminus:
    for j in plusminus:
        for k in plusminus:
            if eval(a[0] + i + a[1] + j + a[2] + k + a[3]) == 7:
            # if cnt_calc(a, i, j, k) == 7:
                print(a[0] + i + a[1] + j + a[2] + k + a[3] + '=7')
                exit(0)
Buggy code:
import itertools
status = [(0, 1) for _ in range(3)]
state = list(itertools.product(*status))
num = [int(i) for i in input()]
for ptn in state:
  ans = num[0]
  ans_str = str(num[0])
  for i,ope in enumerate(ptn):
    if ope == 0:
      ans += num[i+1]
      ans_str += ("+" + str(num[i+1]))
    else:
      ans -= num[i+1]
      ans_str += ("-" + str(num[i+1]))
  if ans == 7:
    break
print(ans_str)


Fixed code:
import itertools
status = [(0, 1) for _ in range(3)]
state = list(itertools.product(*status))
num = [int(i) for i in input()]
for ptn in state:
  ans = num[0]
  ans_str = str(num[0])
  for i,ope in enumerate(ptn):
    if ope == 0:
      ans += num[i+1]
      ans_str += ("+" + str(num[i+1]))
    else:
      ans -= num[i+1]
      ans_str += ("-" + str(num[i+1]))
  if ans == 7:
    break
print(ans_str+"=7")
Buggy code:
s = input()

def func(ac,s,op):
  next = s[0]
  if len(s) ==1:
    if ac + next == 7:
      print(str+'+'+s[0]+'=7')
      exit(0)
    if ac - next == 7:
      print(str+'-'+s[0]+'=7')
      exit(0)
  else:
    func(ac+next,s[1:],op+'+'+str(next))
    func(ac-next,s[1:],op+'-'+str(next))
  

Fixed code:
s = input()

def func(ac,s,op):
  next = int(s[0])
  if len(s) ==1:
    if ac + next == 7:
      print(op+'+'+s[0]+'=7')
      exit(0)
    if ac - next == 7:
      print(op+'-'+s[0]+'=7')
      exit(0)
  else:
    func(ac+next,s[1:],op+'+'+str(next))
    func(ac-next,s[1:],op+'-'+str(next))
  
func(int(s[0]),s[1:],s[0])
Buggy code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,d=map(int,list(input()))
    for i in range(2):
        ans=str(a)
        if i: ans+='-'
        else: ans+='+'
        ans+=str(b)
        for j in range(2):
            if j: ans+='-'
            else: ans+='+'
            ans+=str(c)
            for k in range(2):
                if k: ans+='-'
                else: ans+='+'
                ans+=str(d)
                if eval(ans)==7:
                    print(ans+'=7')
                    exit()


if __name__ == "__main__":
    main()

Fixed code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,d=map(int,list(input()))
    for i in range(2):
        ans=str(a)
        if i: ans+='-'
        else: ans+='+'
        ans+=str(b)
        for j in range(2):
            if j: 
                ans=ans[:-2]
                ans+='-'
            else: ans+='+'
            ans+=str(c)
            for k in range(2):
                if k: ans+='-'
                else: ans+='+'
                ans+=str(d)
                if eval(ans)==7:
                    print(ans+'=7')
                    exit()
                else: ans=ans[:-2]


if __name__ == "__main__":
    main()
Buggy code:
a=input()
A=int(a[0])
B=int(a[1])
C=int(a[2])
D=int(a[3])
f=False

if A+B+C+D==7:
  print("{}+{}+{}+{}".format(A,B,C,D))
elif A+B+C-D==7:
  print("{}+{}+{}-{}".format(A,B,C,D))
elif A+B-C+D==7:
  print("{}+{}-{}+{}".format(A,B,C,D))
elif A+B-C-D==7:
  print("{}+{}-{}-{}".format(A,B,C,D))
elif A-B+C+D==7:
  print("{}-{}+{}+{}".format(A,B,C,D))
elif A-B+C-D==7:
  print("{}-{}+{}-{}".format(A,B,C,D))
elif A-B-C+D==7:
  print("{}-{}-{}+{}".format(A,B,C,D))
elif A-B-C-D==7:
  print("{}-{}-{}-{}".format(A,B,C,D))

  


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

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:
def resolve():
    S = list(map(int, input()))
    a, b, c, d = S[0], S[1], S[2], S[3]
    op = ['+', '-']
    for i in op:
        moji = str(a)
        sum = a
        sum += b if i == '+' else -b
        moji += i + str(b)
        for j in op:
            sum += c if j == '+' else -c
            moji += j + str(c)
            for k in op:
                sum += d if k == '+' else -d
                moji += k + str(d)
                if sum == 7:
                    moji += '=7'
                    return print(moji)
                moji = str(a)
                sum = a

if __name__ == '__main__':
    resolve()

Fixed code:
def resolve():
    S = list(map(int, input()))
    a, b, c, d = S[0], S[1], S[2], S[3]
    op = ['+', '-']
    for i in op:
        moji_i = str(a)
        sum_i = a
        sum_i += b if i == '+' else -b
        moji_i += i + str(b)
        for j in op:
            sum_j = sum_i + c if j == '+' else sum_i-c
            moji_j = moji_i + j + str(c)
            for k in op:
                sum = sum_j + d if k == '+' else sum_j-d
                moji = moji_j + k + str(d)
                if sum == 7:
                    moji += '=7'
                    return print(moji)

if __name__ == '__main__':
    resolve()
Buggy code:
s=input()
l=["+","-"]
for i in range(1):
  for j in range(i):
    for p in range(1):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        break
print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")

Fixed code:
s=input()
c=0
l=["+","-"]
for i in range(2):
  if c!=0:
  	break
  for j in range(2):
    if c!=0:
      	break
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")
        c=1
        break
Buggy code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
op1 = '+'
op2 = '+'
op3 = '+'
for B in [b, -b]:
    for C in [c, -c]:
        for D in [d, -d]:
            if a + B + C + D == 7:
                if B < 0:
                    op1 = '-'
                if C < 0:
                    op2 = '-'
                if D < 0:
                    op3 = '-'
                print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
    break

Fixed code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
op1 = '+'
op2 = '+'
op3 = '+'
for B in [b, -b]:
    for C in [c, -c]:
        for D in [d, -d]:
            if a + B + C + D == 7:
                if B < 0:
                    op1 = '-'
                if C < 0:
                    op2 = '-'
                if D < 0:
                    op3 = '-'
                print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                exit()
Buggy code:
from itertools import product

A, B, C, D = [x for x in input().strip()]

for x in ["".join(x) for x in product(A, '+-', B, '+-', C, '+-', D)]:
    if eval(x) == 7:
        print(x+"=7")







Fixed code:
from itertools import product

A, B, C, D = [x for x in input().strip()]

for x in ["".join(x) for x in product(A, '+-', B, '+-', C, '+-', D)]:
    if eval(x) == 7:
        print(x+"=7")
        break
Buggy code:
import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("")

Fixed code:
import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("=7")
    exit(0)
Buggy code:
O = ["+","-"]
I = list(input())
for o1 in O :
    for o2 in O :
        for o3 in O :
            f = I[0]+o1+I[1]+o2+I[2]+o3+I[3]
            if eval(f) == 7 :
                print(f+"=7")
                

Fixed code:
O = ["+","-"]
I = list(input())
for o1 in O :
    for o2 in O :
        for o3 in O :
            f = I[0]+o1+I[1]+o2+I[2]+o3+I[3]
            if eval(f) == 7 :
                print(f+"=7")
                exit()
Buggy code:
S = input()
l = ['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      exp = S[0] + l[i] + S[1] + l[j] + S[2] + l[k] + S[3]
      if eval(exp) == 7:
        print(exp + '=7')
        break

Fixed code:
S = input()
l = ['+', '-']
flg = False
for i in range(2):
  if flg:
    break
  for j in range(2):
    if flg:
      break
    for k in range(2):
      exp = S[0] + l[i] + S[1] + l[j] + S[2] + l[k] + S[3]
      if eval(exp) == 7:
        print(exp + '=7')
        flg = True
        break
Buggy code:
s = input()


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


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

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


s = input()
dfs(0, s[0], int(s[0]))
Buggy code:
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
  c=''
  c+=A[0]
  bns=int(A[0])
  for j in range(3):
    if i[j]==0:
      bns+=int(A[j+1])
      c+='+'+A[j+1]
    else:
      bns-=int(A[j+1])
      c+='-'+A[j+1]
  if bns==7:
    print(c)
    exit()

Fixed code:
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
  c=''
  c+=A[0]
  bns=int(A[0])
  for j in range(3):
    if i[j]==0:
      bns+=int(A[j+1])
      c+='+'+A[j+1]
    else:
      bns-=int(A[j+1])
      c+='-'+A[j+1]
  if bns==7:
    print(c+'=7')
    exit()
Buggy code:
s = input()
a = []

for i in range(len(s)):
    num = int(s[i])
    a.append(num)

print(a)
op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            temp = 0
            if op[i] == '+':
                temp = a[0] + a[1]
            else:
                temp = a[0] - a[1]
            if op[j] == '+':
                temp += a[2]
            else:
                temp -= a[2]
            if op[k] == '+':
                temp += a[3]
            else:
                temp -= a[3]

            if temp == 7:
                n1, n2, n3, n4 = map(str, [a[0], a[1], a[2], a[3]])
                #n1, n2, n3, n4 = a[0], a[1], a[2], a[3]
                print(n1 + op[i] + n2 + op[j] + n3 + op[k] + n4 + '=7')
                break

Fixed code:

import sys
s = input()
a = []

for i in range(len(s)):
    num = int(s[i])
    a.append(num)


op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            temp = 0
            if op[i] == '+':
                temp = a[0] + a[1]
            else:
                temp = a[0] - a[1]
            if op[j] == '+':
                temp += a[2]
            else:
                temp -= a[2]
            if op[k] == '+':
                temp += a[3]
            else:
                temp -= a[3]

            if temp == 7:
                n1, n2, n3, n4 = map(str, [a[0], a[1], a[2], a[3]])
                #n1, n2, n3, n4 = a[0], a[1], a[2], a[3]
                print(n1 + op[i] + n2 + op[j] + n3 + op[k] + n4 + '=7')
                sys.exit()
Buggy code:
S = input().strip()
op = ["+","-"]
for op1 in op:
    for op2 in op:
        for op3 in op:
            if eval(S[0]+op1+S[1]+op2+S[2]+op3+S[3])==7:
                print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+"=7")
                break

Fixed code:
S = input().strip()
op = ["+","-"]
ind = 0
for op1 in op:
    for op2 in op:
        for op3 in op:
            if eval(S[0]+op1+S[1]+op2+S[2]+op3+S[3])==7:
                print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+"=7")
                ind = 1
                break
        if ind==1:break
    if ind==1:break
Buggy code:
def resolve():
    s = input()

    def dfs(i, f):
        if i == 3:
            return f.split(",")
        return dfs(i+1, f + "+" + s[i+1]) + dfs(i+1, f + "-" + s[i-1])
    for i in dfs(0, s[0]):
        if eval(i) == 7:
            print(i + "=7")
            exit()
resolve()

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

    def dfs(i, f):
        if i == 3:
            return f.split(",")
        return dfs(i+1, f + "+" + s[i+1]) + dfs(i+1, f + "-" + s[i+1])
    for i in dfs(0, s[0]):
        if eval(i) == 7:
            print(i + "=7")
            exit()
resolve()
Buggy code:
numbers=list(map(int,list(input())))
ansLst=[]
def count(i,opes,sum):
    if i == 4:
        if sum == 7:
            ansLst.append(str(numbers[0])+opes[0]+str(numbers[1])+opes[1]+str(numbers[2])+opes[3]+str(numbers[3])+"=7")
    else:
        count(i+1,opes+["+"],numbers[i]+sum)
        count(i+1,opes+["-"],sum-numbers[i])
count(0,[],0)
print(ansLst[0])

Fixed code:
numbers=list(map(int,list(input())))
ansLst=[]
def count(i,opes,sum):
    if i == 4:
        if sum == 7:
            ansLst.append(str(numbers[0])+opes[0]+str(numbers[1])+opes[1]+str(numbers[2])+opes[2]+str(numbers[3])+"=7")
    else:
        count(i+1,opes+["+"],sum+numbers[i])
        count(i+1,opes+["-"],sum-numbers[i])
count(1,[],numbers[0])
print(ansLst[0])
Buggy code:
t=list(map(int,list(input())))
t.append(-1)
op=[]
def dfs(x,i):
  if i==4 or len(op)==3:
    if x==7:
      ans=''
      for j in range(4):
        if j==3:
          ans+=str(t[j])
        else:
          ans+=str(t[j])+op[j]
      print(ans)
    return
  i+=1
  op.append('+')
  dfs(x+t[i],i)
  op.pop()
  
  op.append('-')
  dfs(x-t[i],i)
  op.pop()
  i-=1
  
  return
dfs(t[0],0)

Fixed code:
import sys
t = list(map(int, list(input())))
t.append(7)
op = []

def dfs(x, i):
    if i == 4 or len(op) == 3:
        if x == 7:
            op.append('=')
            ans = ''
            for j in range(5):
                if j == 4:
                    ans += str(t[j])
                else:
                    ans += str(t[j]) + op[j]
            print(ans)
            sys.exit(0)
        return

    i += 1
    op.append('+')
    dfs(x + t[i], i)
    op.pop()

    op.append('-')
    dfs(x - t[i], i)
    op.pop()
    i -= 1

    return

dfs(t[0], 0)
Buggy code:
s = list(input())
s = list(map(int, s))

ss = []

def numToString(s):
    if s >= 0:
        s = '+' + str(s)
    else:
        s = str(s)
    return s

for i in range(3):
    if s[0] + s[1] + s[2] + s[3] == 7:
        ss += str(s[0])
        ss += list(map(numToString, s[1:4]))
        ss = ''.join(ss)
        print(ss + '=7')
        exit()

    for j in range(2):
        if s[0] + s[1] + s[2] + s[3] == 7:
            ss += str(s[0])
            ss += list(map(numToString, s[1:4]))
            ss = ''.join(ss)
            print(ss + '=7')
            exit()

        for k in range(1):
            if s[0] + s[1] + s[2] + s[3] == 7:
                ss += str(s[0])
                ss += list(map(numToString, s[1:4]))
                ss = ''.join(ss)
                print(ss + '=7')
                exit()
            s[3] *= -1
        s[2] *= -1
    s[1] *= -1



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

ss = []

def numToString(s):
    if s >= 0:
        s = '+' + str(s)
    else:
        s = str(s)
    return s

for i in range(2):
    if sum(s) == 7:
        ss += str(s[0])
        ss += list(map(numToString, s[1:4]))
        ss = ''.join(ss)
        print(ss + '=7')
        exit()

    for j in range(2):
        if sum(s) == 7:
            ss += str(s[0])
            ss += list(map(numToString, s[1:4]))
            ss = ''.join(ss)
            print(ss + '=7')
            exit()

        for k in range(2):
            if sum(s) == 7:
                ss += str(s[0])
                ss += list(map(numToString, s[1:4]))
                ss = ''.join(ss)
                print(ss + '=7')
                exit()

            s[3] *= -1
        s[2] *= -1
    s[1] *= -1