qyliang/CodeNanoFix huggingface dataset:
Buggy code:

def abc079_c():
    stlist = input()

    stlist = "1222"

    def DFS(i,sum,li):
        if i == len(stlist)-1:
            if sum == 7:
                print(str(stlist[0])+str(li[0])+str(stlist[1])+str(li[1])+str(stlist[2])+str(li[2])+str(stlist[3])+"=7")
            return

        #+
        li[i]="+"
        DFS(i+1,sum+int(stlist[i+1]),li)

        #-
        li[i]="-"
        DFS(i+1,sum-int(stlist[i+1]),li)

    DFS(0,int(stlist[0]),[[] for i in range(3)])










abc079_c()


Fixed code:

def abc079_c():
    stlist = input()

    def DFS(i,sum,li):
        if i == len(stlist)-1:
            if sum == 7:
                print(str(stlist[0])+str(li[0])+str(stlist[1])+str(li[1])+str(stlist[2])+str(li[2])+str(stlist[3])+"=7")
                exit()
            return

        #+
        li[i]="+"
        DFS(i+1,sum+int(stlist[i+1]),li)

        #-
        li[i]="-"
        DFS(i+1,sum-int(stlist[i+1]),li)

    DFS(0,int(stlist[0]),[[] for i in range(3)])










abc079_c()
Buggy code:
l=input()
num=[int(l[i]) for i in range(4)]
pm=['+','-']
for i in pm:
  a,b,c,d=num[0],num[1],num[2],num[3]
  for j in pm:
    for k in pm:
      if i=='-':
        b=b*(-1)
      if j=='-':
        c=c*(-1)
      if k=='-':
        d==d*(-1)
      if a+b+c+d==7:
        print(str(a)+i+str(abs(b))+j+str(abs(c))+k+str(abs(d))+'='+'7')
        exit()

Fixed code:
l=input()
num=[int(l[i]) for i in range(4)]
pm=['+','-']
for i in pm:
  a,b,c,d=num[0],num[1],num[2],num[3]
  for j in pm:
    for k in pm:
      if i=='-':
        b=b*(-1)
      if j=='-':
        c=c*(-1)
      if k=='-':
        d=d*(-1)
      if a+b+c+d==7:
        print(str(a)+i+str(abs(b))+j+str(abs(c))+k+str(abs(d))+'='+'7')
        exit()
      a,b,c,d=num[0],num[1],num[2],num[3]
Buggy code:

abcd = input()
num = [int(i) for i in abcd]
def solve(i,a,seven,ans):
    if i == 3:
        if seven == 7:
            return ans
            
        else:
            return False

    if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
        return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
    
    if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
        return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))

print(solve(0,num,num[0],str(num[0])))


Fixed code:

abcd = input()
num = [int(i) for i in abcd]
anslist = []
def solve(i,a,seven,ans):
    if i == 3:
        if seven == 7:
            return ans+'=7'
            
            
        else:
            return False

    if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
        return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
    
    if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
        return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))

print(solve(0,num,num[0],str(num[0])))
Buggy code:
S = input()

op = [0]*3
for i in range(2):
    tmp = int(S[0])
    if i == 0:
        tmp += int(S[1])
        op[0] = '+'
    else:
        tmp -= int(S[1])
        op[0] = '-'
    for j in range(2):
        if j == 0:
            tmp += int(S[2])
            op[1] = '+'
        else:
            tmp -= int(S[2])
            op[1] = '-'
        for k in range(2):
            if k == 0:
                tmp += int(S[3])
                op[2] = '+'
            else:
                tmp -= int(S[3])
                op[2] = '-'
            if tmp == 7:
                print(S[0] + op[0] + S[1] + op[1] + S[2] + op[2] + S[3] + '=7')
                exit()


Fixed code:
S = input()

op = [0]*3
tmp = [0]*4
for i in range(2):
    tmp[0] = int(S[0])
    if i == 0:
        tmp[1] = int(S[1])
        op[0] = '+'
    else:
        tmp[1] = -int(S[1])
        op[0] = '-'
    for j in range(2):
        if j == 0:
            tmp[2] = int(S[2])
            op[1] = '+'
        else:
            tmp[2] = -int(S[2])
            op[1] = '-'
        for k in range(2):
            if k == 0:
                tmp[3] = int(S[3])
                op[2] = '+'
            else:
                tmp[3] = -int(S[3])
                op[2] = '-'
            if sum(tmp) == 7:
                print(S[0] + op[0] + S[1] + op[1] + S[2] + op[2] + S[3] + '=7')

                exit()
Buggy code:
n=input()
for i in ('+','-'):
  for j in ('+','-'):
    for k in ('+','-'):
      sm=a[0]+i+a[1]+j+a[2]+k+a[3]
      if eval(sm)==7:
        print(sm+'=7')
        exit()

Fixed code:
a=input()
for i in ('+','-'):
  for j in ('+','-'):
    for k in ('+','-'):
      sm=a[0]+i+a[1]+j+a[2]+k+a[3]
      if eval(sm)==7:
        print(sm+'=7')
        exit()
Buggy code:
import sys

a = list(input())
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i % 2 == 0:
                sym1 = '+'
            else:
                sym1 = '-'
            if j % 2 == 0:
                sym2 = '+'
            else:
                sym2 = '-'
            if k % 2 == 0:
                sym3 = '+'
            else:
                sym3 = '-'
            word = a[0] + sym1 + a[1] + sym2 + a[2] + sym3 + a[3]

            ans = eval(word)
            if ans == 7:
                print(word)
                sys.exit()

Fixed code:
import sys

a = list(input())
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i % 2 == 0:
                sym1 = '+'
            else:
                sym1 = '-'
            if j % 2 == 0:
                sym2 = '+'
            else:
                sym2 = '-'
            if k % 2 == 0:
                sym3 = '+'
            else:
                sym3 = '-'
            word = a[0] + sym1 + a[1] + sym2 + a[2] + sym3 + a[3]

            ans = eval(word)
            if ans == 7:
                print(word+'=7')
                sys.exit()
Buggy code:
a=input()
op=['+','-']
 
for i in op:
    for j in op:
        for k in op:
            if a[0]+i+a[1]+j+a[2]+k+a[3]==7:
                print(a[0]+i+a[1]+j+a[2]+k+a[3]+"=7")
                exit()

Fixed code:
a=input()
op=['+','-']
 
for i in op:
    for j in op:
        for k in op:
            if eval(a[0]+i+a[1]+j+a[2]+k+a[3])==7:
                print(a[0]+i+a[1]+j+a[2]+k+a[3]+"=7")
                exit()
Buggy code:
from itertools import product

s=input()

for op in product(["+","-"],repeat=len(s)-1):
  formula =""
  for i in range(len(s-1)):
    formula+=s[i]+op[i]
  formula+=s[1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Fixed code:
from itertools import product

s=input()

for op in product(["+","-"],repeat=3):
  formula =""
  for i in range(3):
    formula+=s[i]+op[i]
  formula+=s[-1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()
Buggy code:
s = input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

flag = [0]*3
tmp = 0
for i in range(8):
  flag[0]=(i>>2)&1
  flag[1]=(i>>1)&1
  flag[2]=(i)&1
  
  tmp = A +(-1)**flag[0]*B +(-1)**flag[0]*C +(-1)**flag[0]*D
  if tmp==7:
    ans=s[0]
    for j in range(3):
      if flag[i]:
        ans+="-"+s[i+1]
      else:
        ans+="+"+s[i+1]
    ans+="=7"
    print(ans)
    break

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

flag = [0]*3
tmp = 0
for i in range(8):
  flag[0]=(i>>2)&1
  flag[1]=(i>>1)&1
  flag[2]=(i)&1
  
  tmp = A +(-1)**flag[0]*B +(-1)**flag[1]*C +(-1)**flag[2]*D
  if tmp==7:
    ans=s[0]
    for j in range(3):
      if flag[j]:
        ans+="-"+s[j+1]
      else:
        ans+="+"+s[j+1]
    ans+="=7"
    print(ans)
    break
Buggy code:
from itertools import product

s=input()

for op in product(["+","-"],repeat=3):
  formula =""
  for i in range(3):
    formula+=s[i]+op[i]
  formula+=s[1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

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

for operators in product(["+","-"],repeat=3):
  formula=""
  for i in range(3):
    formula+=s[i]+operators[i]
  formula+=s[-1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()
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("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()

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("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()
if a+b+c-d==7:
  print("%d+%d+%d-%d=7"%(a,b,c,d))
  exit()
if a+b-c+d==7:
  print("%d+%d-%d+%d=7"%(a,b,c,d))
  exit()
if a+b-c-d==7:
  print("%d+%d-%d-%d=7"%(a,b,c,d))
  exit()  
if a-b+c+d==7:
  print("%d-%d+%d+%d=7"%(a,b,c,d))
  exit()
if a-b+c-d==7:
  print("%d-%d+%d-%d=7"%(a,b,c,d))
  exit()
if a-b-c+d==7:
  print("%d-%d-%d+%d=7"%(a,b,c,d))
  exit()
if a-b-c-d==7:
  print("%d-%d-%d-%d=7"%(a,b,c,d))
  exit()
Buggy code:
import sys
s = input()

for i in range(8):
    bit = bin(i)[2:].zfill(3)
    string = s[0]
    flag = int(s[0])

    for j,k in enumerate(bit):
        if k == '0':
            string += '+' + s[j+1]
            flag += int(s[j+1])
        else:
            string += '-' + s[j+1]
            flag -= int(s[j+1])

        if flag == 7:
            print(string + '=7')
            sys.exit()

Fixed code:
import sys
s = input()

for i in range(8):
    bit = bin(i)[2:].zfill(3)
    string = s[0]
    flag = int(s[0])

    for j,k in enumerate(bit):
        if k == '0':
            string += '+' + s[j+1]
            flag += int(s[j+1])
        else:
            string += '-' + s[j+1]
            flag -= int(s[j+1])

    if flag == 7:
        print(string + '=7')
        sys.exit()
Buggy code:
L = input()
N = [int(i) for i in list(L)]
def check(n):
  if n == -1:
    return '-'
  else:
    return '+'
for i in range(2):
  for j in range(2):
    for k in range(2):
      if N[0] + N[1] * pow(-1, i) + N[2] * pow(-1, j) + N[3] * pow(-1, k) == 7:
        ii = check(pow(-1, i))
        jj = check(pow(-1, j))
        kk = check(pow(-1, k))
        print(str(N[0]) + ii + str(N[1]) + jj + str(N[2]) + kk + str(N[3]) + "==7")
        exit(0)


Fixed code:
L = input()
N = [int(i) for i in list(L)]
def check(n):
  if n == -1:
    return '-'
  else:
    return '+'
for i in range(2):
  for j in range(2):
    for k in range(2):
      if N[0] + N[1] * pow(-1, i) + N[2] * pow(-1, j) + N[3] * pow(-1, k) == 7:
        ii = check(pow(-1, i))
        jj = check(pow(-1, j))
        kk = check(pow(-1, k))
        print(str(N[0]) + ii + str(N[1]) + jj + str(N[2]) + kk + str(N[3]) + "=7")
        exit(0)
Buggy code:
nums = list(map(int, input()))

ans_map = {}
for i in range(3):
    if i == 0:
        ans_map['-'] = nums[0] - nums[1]
        ans_map['+'] = nums[0] + nums[2]
        continue

    for operators in dict.fromkeys(ans_map):
        tmp_val = ans_map[operators]
        if i == 2:
            if tmp_val + nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '+',
                    nums[3]
                ))
                break

            if tmp_val - nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '-',
                    nums[3]
                ))
                break

        ans_map[operators + '-'] = tmp_val - nums[i + 1]
        ans_map[operators + '+'] = tmp_val + nums[i + 1]
        del ans_map[operators]

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

ans_map = {}
for i in range(3):
    if i == 0:
        ans_map['+'] = nums[0] + nums[1]
        ans_map['-'] = nums[0] - nums[1]
        continue

    for operators in dict.fromkeys(ans_map):
        tmp_val = ans_map[operators]
        if i == 2:
            if tmp_val + nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}=7'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '+',
                    nums[3]
                ))
                break

            if tmp_val - nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}=7'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '-',
                    nums[3]
                ))
                break
            continue

        ans_map[operators + '+'] = tmp_val + nums[i + 1]
        ans_map[operators + '-'] = tmp_val - nums[i + 1]
        del ans_map[operators]
Buggy code:
n = input()
b_l = []
for i in range(8):
  b = bin(i)[2:]
  le = len(b)
  b_l.append((3 - le)*"0" + b)


    

s_l = [int(n[i]) for i in range(4)]
    
for b in b_l:
  ans = s_l[0]
  f = 0
  b_s_l = ["+" if b[i] == "0" else "-" for i in range(3)]
  for i in range(3):
    if b_s_l[i] == "+":
      ans += s_l[i+1]
    else:
      ans -= s_l[i+1]
  if ans == 7:
    print(str(s_l[0]) + b_s_l[0] + str(s_l[1]) + b_s_l[1] + str(s_l[2]) + 
          b_s_l[2] + str(s_l[3])) 
    break

  

Fixed code:
n = input()
b_l = []
for i in range(8):
  b = bin(i)[2:]
  le = len(b)
  b_l.append((3 - le)*"0" + b)


    

s_l = [int(n[i]) for i in range(4)]
    
for b in b_l:
  ans = s_l[0]
  f = 0
  b_s_l = ["+" if b[i] == "0" else "-" for i in range(3)]
  for i in range(3):
    if b_s_l[i] == "+":
      ans += s_l[i+1]
    else:
      ans -= s_l[i+1]
  if ans == 7:
    print(str(s_l[0]) + b_s_l[0] + str(s_l[1]) + b_s_l[1] + str(s_l[2]) + 
          b_s_l[2] + str(s_l[3]) + "=7") 
    break
Buggy code:
N = list(input())
N = [int(i) for i in N]
for i in range(2**3):
    cur = bin(i)[2::].zfill(3)
    c = N[0]
    n = []
    for i in range(3):
        if cur[i]=='0':
            n.append('+')
            c += N[i+1]
        else:
            n.append('-')
            c -= N[i+1]
    if c==7:
        m = '='
        print(N[0],n[0],N[1],n[1],N[2],n[2],N[3],m,c,sep=(''))

Fixed code:
N = list(input())
N = [int(i) for i in N]
for i in range(2**3):
    cur = bin(i)[2::].zfill(3)
    c = N[0]
    n = []
    for i in range(3):
        if cur[i]=='0':
            n.append('+')
            c += N[i+1]
        else:
            n.append('-')
            c -= N[i+1]
    if c==7:
        m = '='
        print(N[0],n[0],N[1],n[1],N[2],n[2],N[3],m,c,sep=(''))
        break
Buggy code:
a, b, c, d = list(input())
op = '+-'
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a + op1 + b + op2 + c + op3 + d
            if eval(ans) == 7:
                print('{}=7'.format(ans))
                break


Fixed code:
a, b, c, d = list(input())
op = '+-'
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a + op1 + b + op2 + c + op3 + d
            # print(eval(ans))
            if eval(ans) == 7:
                print('{}=7'.format(ans))
                break
        else:
            continue
        break
    else:
        continue
    break
Buggy code:
A = list(input())
sign = ['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(A[0]+sign[i]+A[1]+sign[j]+A[2]+sign[k]+A[3]) == 7:
                print('{}{}{}{}{}{}{}'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3]))
                exit()

Fixed code:
A = list(input())
sign = ['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(A[0]+sign[i]+A[1]+sign[j]+A[2]+sign[k]+A[3]) == 7:
                print('{}{}{}{}{}{}{}=7'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3]))
                exit()
Buggy code:
S = input()
op = ["+", "-"]
for a in op:
    for b in op:
        for c in op:
            f = S[0] + a + S[1] + b + S[2] + c + S[3]
            if eval(f) == 7:
                print(f + "=7")
                break


Fixed code:
S=input()
op=["+","-"]
for a in op:
    for b in op:
        for c in op:
            f=S[0]+a+S[1]+b+S[2]+c+S[3]
            if eval(f)==7:
                print(f+"=7")
                exit()
Buggy code:
a = list(map(int, list(input())))

def calc(x, y, sym):
    if sym == 0:
        return x + y
    else:
        return x - y

def symbol(sym):
    if sym == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            tmp = calc(a[0], a[1], i)
            tmp = calc(tmp, a[2], j)
            tmp = calc(tmp, a[3], k)
            if tmp == 7:
                b = list(map(symbol, [i, j, k]))
                print("{}{}{}{}{}{}{}=7".format(a[0], b[0], a[1], b[1], a[2], b[2], a[3]))
                break


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

def calc(x, y, sym):
    if sym == 0:
        return x + y
    else:
        return x - y

def symbol(sym):
    if sym == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            tmp = calc(a[0], a[1], i)
            tmp = calc(tmp, a[2], j)
            tmp = calc(tmp, a[3], k)
            if tmp == 7:
                b = list(map(symbol, [i, j, k]))
                print("{}{}{}{}{}{}{}=7".format(a[0], b[0], a[1], b[1], a[2], b[2], a[3]))
                break
        else:
            continue
        break
    else:
        continue
    break
Buggy code:
a,b,c,d= map(int,input().split())
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')
else:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Fixed code:
a,b,c,d= map(int,input())
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')
else:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
Buggy code:
a,b,c,d=list(map(int,input()))

for i in range(6):  
  if i==0 and a+b+c+d==7:
    print('%d+%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==1 and a+b+c-d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==2 and a+b-c+d==7:
    print('%d+%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==3 and a+b-c-d==7:
    print('%d+%d-%d-%d=7' %(a,b,c,d))
    exit()
  elif i==4 and a-b+c+d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==5 and a-b+c-d==7:
    print('%d-%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==6 and a-b-c-d==7:
    print('%d-%d-%d-%d=7' %(a,b,c,d))
    exit()


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

for i in range(7):  
  if i==0 and a+b+c+d==7:
    print('%d+%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==1 and a+b+c-d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==2 and a+b-c+d==7:
    print('%d+%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==3 and a+b-c-d==7:
    print('%d+%d-%d-%d=7' %(a,b,c,d))
    exit()
  elif i==4 and a-b+c+d==7:
    print('%d-%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==5 and a-b+c-d==7:
    print('%d-%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==6 and a-b-c+d==7:
    print('%d-%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==7 and a-b-c-d==7:
    print('%d-%d-%d-%d=7' %(a,b,c,d))
    exit()
Buggy code:
a,b,c,d = list(map(int, list(str(input()))))

def calc(n, op, m):
  if(type(n) is not int):
    return False
  if(op == "+"):
    return n + m
  elif(op == "-"):
    return n - m
  elif(op == "*"):
    return n * m
  elif(m != 0):
    return n / m
  else:
    return False

ops1 = ["/", "+", "-", "*"]
ops2 = ["/", "+", "-", "*" ]
ops3 = ["/", "+", "-", "*" ]
for op1 in ops1:
  for op2 in ops2:
    for op3 in ops3:
      if(calc(calc(calc(a,op1,b),op2,c),op3,d) == 7):
        print(a,op1,b,op2,c,op3,d,sep="")
        exit()

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

def calc(n, op, m):
  if(type(n) is not int):
    return False
  if(op == "+"):
    return n + m
  elif(op == "-"):
    return n - m
  elif(op == "*"):
    return n * m
  elif(m != 0):
    return n / m
  else:
    return False

ops1 = ["/", "+", "-", "*"]
ops2 = ["/", "+", "-", "*" ]
ops3 = ["/", "+", "-", "*" ]
for op1 in ops1:
  for op2 in ops2:
    for op3 in ops3:
      if(calc(calc(calc(a,op1,b),op2,c),op3,d) == 7):
        print(a,op1,b,op2,c,op3,d,"=7", sep="")
        exit()
Buggy code:
#coding: utf-8

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

shiki = ''

for i in range(2):
    for j in range(2):
        for k in range(2):
            B = B * (-1) ** i
            C = C * (-1) ** j
            D = D * (-1) ** k
            if(A + B + C + D == 7):
                shiki += str(A)

                if(B<0):
                    shiki += '-' + str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += '-' + str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += '-' + str(D)
                else:
                    shiki += '+' + str(D)
                print(shiki,end='')
                break
        break
    break

Fixed code:
#coding: utf-8

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

for i in range(2):
    for j in range(2):
        for k in range(2):
            A = int(S[0])
            B = int(S[1])
            C = int(S[2])
            D = int(S[3])

            B *= (-1) ** i
            C *= (-1) ** j
            D *= (-1) ** k
            if(A + B + C + D == 7):
                shiki = ''
                shiki += str(A)
                if(B<0):
                    shiki += str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += str(D)
                else:
                    shiki += '+' + str(D)
                shiki += '=7'
                print(shiki)
                exit()
Buggy code:
a,b,c,d= list(input())
op = ['+','-']
for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d) == 7:
                print(str(a+i+b+j+c+k+d)+'=7')

Fixed code:
a,b,c,d= list(input())
op = ['+','-']
for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d) == 7:
                print(str(a+i+b+j+c+k+d)+'=7')
                exit()
Buggy code:
a, b, c, d = list(input())
ops = ['+', '-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      s = a+op1+b+op2+c+op3+d
      res = eval(s)
      if res == 7:
        print(s+'=7')
        break

Fixed code:
a, b, c, d = list(input())
ops = ['+', '-']
fin = False
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = a+op1+b+op2+c+op3+d
            res = eval(s)
            if res == 7:
                print(s+'=7')
                fin = True
                break
        if fin == True:
            break
    if fin == True:
        break
Buggy code:
from itertools import product

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

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

Fixed code:
from itertools import product

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

for pattern in product('+-', '+-', '+-'):
    f = '{}{}{}{}{}{}{}'.format(A, pattern[0], B, pattern[1], C, pattern[2], D)

    if eval(f) == 7:
        print(f+'=7')
        break