qyliang/CodeNanoFix huggingface dataset:
Buggy code:
main = input()
word = input()
temp = main
resultArray = []
final = len(word)
for j in range(len(main) - (len(word) - 1)):
    result = ''
    for i in range(len(word)):
        if main[j + i] == word[i]:
            result += '1'
        else:
            result += '0'
    resultArray.append(result)
for i in resultArray:
    if i.count('0') < final:
        final = i.count('0')
print(resultArray)
print(final)


Fixed code:
main = input()
word = input()
temp = main
resultArray = []
final = len(word)
for j in range(len(main) - (len(word) - 1)):
    result = ''
    for i in range(len(word)):
        if main[j + i] == word[i]:
            result += '1'
        else:
            result += '0'
    resultArray.append(result)
for i in resultArray:
    if i.count('0') < final:
        final = i.count('0')
print(final)
Buggy code:
S = list(input())
T = list(input())
ans = 1e9

for i in range(len(S) - len(T) + 1):
    print(S[i:len(T)+i],T)
    tmp = 0
    for j in range(len(T)):
        if S[i:len(T)+i][j] == T[j]: continue
        tmp += 1
    ans = min (ans,tmp)

print(ans)

Fixed code:
S = list(input())
T = list(input())
ans = 1e9

for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if S[i:len(T)+i][j] == T[j]: continue
        tmp += 1
    ans = min (ans,tmp)

print(ans)
Buggy code:
s = str(input())
t = str(input())
ans = 10000
for i in range(len(s)-len(t)+1):
  num = 0
  for j in range(len(t)):
    if s[i+j] != t[i]:
      num += 1
  ans = min(ans,num)
print(ans)

Fixed code:
s = str(input())
t = str(input())
ans = 10000
for i in range(len(s)-len(t)+1):
  num = 0
  for j in range(len(t)):

    if s[i+j] != t[j]:
      num += 1
  ans = min(ans,num)
print(ans)
Buggy code:
s=input()
t=input()

print(s)
a = len(s)
b = len(t)
c = a-b;
min1 = 0;
min2 = 0;
for i in range(c):
  for j in range(b):
    if s[j]==t[i+j]:
      min2 += 1
  if min1>min2:
    min1 = min2
print(min1)

Fixed code:
s=input()
t=input()

a = len(s)
b = len(t)
c = a-b;
min1 = 0;
min2 = 0;
for i in range(c+1):
  for j in range(b):
    
    if s[j+i]==t[j]:
      
      min2 += 1
  if min1<min2:
    min1 = min2
  min2 =0
print(b-min1)
Buggy code:
s, t = input(), input()

ans = 0

for i in range(len(s) - len(t) + 1):
  count = 0
  for j in range(len(t)):
    if s[i][j] == t[j]:
      count += 1

if ans <= count:
  ans = count
print(len(t) - count)

Fixed code:
s = input()
t = input()
 
ans = 0
 
for i in range(len(s) - len(t) + 1):
  count = 0
  for j in range(len(t)):
    if s[i + j] == t[j]:
      count += 1
 
  if ans <= count:
    ans = count
print(len(t) - ans)
Buggy code:
s = input()
t = input()
maxi = 0 
for i in range(len(s)):
    maxG = 0
    print(s[i:len(t)+i])
    if len(s[i:len(t)+i]) >= len(t):
        for l, j in zip(s[i:len(t)+i], t):
            if l == j:
                maxG += 1
        maxi = max(maxi, maxG)
print(len(t)-maxi)


Fixed code:
s = input()
t = input()
maxi = 0 
for i in range(len(s)):
    maxG = 0
    if len(s[i:len(t)+i]) >= len(t):
        for l, j in zip(s[i:len(t)+i], t):
            if l == j:
                maxG += 1
        maxi = max(maxi, maxG)
print(len(t)-maxi)
Buggy code:
S = input()
T = input()
sl = len(S)
tl = len(T)
ans = tl
for i in range(sl - tl + 1):
    flag = 0
    tmp = 0
    for j in range(tl):
        if S[j + i] == T[j]:
            tmp += 1
            flag = 1
    if flag == 1:
        ans = min(ans,tmp)
print(ans)

Fixed code:
S = input()
T = input()
sl = len(S)
tl = len(T)
ans = tl
for i in range(sl - tl + 1):
    flag = 0
    tmp = 0
    for j in range(tl):
        if S[j + i] == T[j]:
            tmp += 1
    ans = min(ans,tl - tmp)

print(ans)
Buggy code:
S = input()
T = input()

iteration = len(S) - len(T) + 1

if T in S:
    ans = 0
else:
    minimum = len(T)
    for i in range(iteration):
        s = S[i:len(T)+i]
        for j in range(len(T)):
            count = 0
            if s[j] != T[j]:
                count += 1
        minimum = min(minimum, count)
    ans = minimum
    
print(ans)

Fixed code:
S = input()
T = input()

iteration = len(S) - len(T) + 1

if T in S:
    ans = 0
else:
    minimum = len(T)
    for i in range(iteration):
#         print('---------------')
        s = S[i:len(T)+i]
#         print(s)
#         print(T)
        count = 0
        for j in range(len(T)):
            if s[j] != T[j]:
                count += 1
#             print(count)
        minimum = min(minimum, count)
    ans = minimum
    
print(ans)
Buggy code:
S=input()
T=input()

if T in S:
  print(0)
  exit()

def f(s1,s2):
  print(s1, s2)
  r=0
  for i,j in zip(s1,s2):
    if i != j: r += 1
  return r

a=len(S)
for i in range(len(S)-len(T)+1):
  r = f(S[i:i+len(T)],T)
  if a > r: a = r

print(a)

Fixed code:
S=input()
T=input()

if T in S:
  print(0)
  exit()

def f(s1,s2):
  r=0
  for i,j in zip(s1,s2):
    if i != j: r += 1
  return r

a=len(S)
for i in range(len(S)-len(T)+1):
  r = f(S[i:i+len(T)],T)
  if a > r: a = r

print(a)
Buggy code:
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = 10*5
for i in range(len_S - len_T+1):
    num = 0
    tmp = S[i:i+len_T]
    print(tmp)
    for j in range(len(tmp)):
        print(tmp[j])
        if tmp[j] != T[j]:
            num+=1
    ans = min(ans, num)

print(ans)

Fixed code:
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = 10**10
for i in range(len_S - len_T+1):
    num = 0
    for j in range(len_T):
        if S[i+j] != T[j]:
            num+=1
    ans = min(ans, num)

print(ans)
Buggy code:
S = input()
T = input()

ans = len(T)

for i in range(len(S) - len(T)):
    diff = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            diff += 1
print(min(ans, diff))

Fixed code:
S = input()
T = input()

ans = len(T)

for i in range(len(S) - len(T) + 1):
    diff = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            diff += 1
    ans = min(ans, diff)
    
print(ans)
Buggy code:
import sys
s = input()
t = input()
d = 0
m = sys.maxsize
for i in range(len(s)-len(t)+1):
  c = 0
  for j in range(i,i+len(t)):
    if t[i-j]!=s[j]:
      c+=1
  m = min(m,c)
print(m)

Fixed code:
import sys
def sol(s,t):
    m = sys.maxsize
    for i in range(len(s)-len(t)+1):
        c = 0
        for j in range(i,i+len(t)):
            if t[j-i]!=s[j]:
                c+=1
        m = min(m,c)
    print(m)
s = input()
t = input()
sol(s,t)
Buggy code:
s, t = [input() for i in range(2)]
ans = float("inf")
for i in range(len(s) - len(t)+1):
        cnt = 0
        for j in range(len(t)):
                if s[i + j] != t[j]:
                        cnt += 1
        print(s[i:i+len(t)], cnt)
        if ans  > cnt:
                ans = cnt
print(ans)       

Fixed code:
s, t = [input() for i in range(2)]
ans = float("inf")
for i in range(len(s) - len(t)+1):
        cnt = 0
        for j in range(len(t)):
                if s[i + j] != t[j]:
                        cnt += 1
        if ans  > cnt:
                ans = cnt
print(ans)
Buggy code:
S = input()
t = input()
neq = len(t)
for i in range(len(S)-len(t)+1):
  if S[i]==t[0]:
    neq_temp = 0
    for j in range(1,len(t)):
      if S[i+j]!=t[j]:
        neq += 1
    neq = min(neq,neq_temp)
print(neq)

Fixed code:
S = input()
t = input()
neq = len(t)
for i in range(len(S)-len(t)+1):
  neq_temp = 0
  for j in range(len(t)):
    if S[i+j]!=t[j]:
      neq_temp += 1
  neq = min(neq,neq_temp)
print(neq)
Buggy code:
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0
print(t_len - max_ + 1)

Fixed code:
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len + 1):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0

print(t_len - max_)
Buggy code:
s = input()
t = input()
result = len(t)
for i in range(len(s) - len(t) + 1):
  box = 0
  for j in range(len(t)):
    if t[j] == s[i + j]:
      box += 1
  if result > box :
    result = box
print(result)

Fixed code:
s = input()
t = input()
result = len(t)
for i in range(len(s) - len(t) + 1):
  box = 0
  for j in range(len(t)):
    if t[j] != s[i + j]:
      box += 1
  if result > box :
    result = box
print(result)
Buggy code:
s = input()
t = input()
ans = 10**8
for i in range(len(s)):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]: cnt += 1
    ans = min(ans, cnt)

print(ans)


Fixed code:
s = input()
t = input()
ans = 10**8
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]: cnt += 1
    ans = min(ans, cnt)

print(ans)
Buggy code:
s = input()
t = input()
list = []

for i in range(len(s)-len(t)+1):
    n=0
    for j in range(len(t)):
        if s[i] != t[j]:
            n+=1
    list.append(n)
print(min(list))


Fixed code:
s = input()
t = input()
list = []

for i in range(len(s)-len(t)+1):
    n=0
    U = s[i:i + len(t)]
    for j in range(len(t)):
        if U[j] != t[j]:
            n+=1
    list.append(n)
print(min(list))
Buggy code:
s = input()
t = input()


s_len = len(s)
t_len = len(t)
ans = s_len
for i in range(0,s_len):
    tmp = 0
    for j in range(0,t_len):
        if i+j >= s_len:
            continue
        if s[i+j] != t[j]:
            tmp = tmp + 1
    ans = min(tmp,ans)

print(ans)

Fixed code:
s = input()
t = input()


s_len = len(s)
t_len = len(t)
ans = s_len
for i in range(0,s_len):
    if i+t_len > s_len:
        continue
    tmp = 0
    for j in range(0,t_len):
        if s[i+j] != t[j]:
            tmp = tmp + 1
    ans = min(tmp,ans)

print(ans)
Buggy code:
#long
long=input()
 
#short
short=input()
 
maximum_same=0
for i in range(len(long)-len(short)+1):
  newLong=long[i:i+len(short)]
  
  print(newLong)
  same=0
  for j in range(len(short)):
    if newLong[j]==short[j]:
      same+=1
  if same>maximum_same:
    maximum_same=same
 
print(len(short)-maximum_same)

Fixed code:
#long
long=input()
 
#short
short=input()
 
maximum_same=0
for i in range(len(long)-len(short)+1):
  newLong=long[i:i+len(short)]
  
  #print(newLong)
  same=0
  for j in range(len(short)):
    if newLong[j]==short[j]:
      same+=1
  if same>maximum_same:
    maximum_same=same
 
print(len(short)-maximum_same)
Buggy code:
def check(S,T,i):
	count=0
	for j in range(i,len(T)+i):
		if S[j] == T[j-i]:
			count+=1
	return count

S=input()
T=input()
b=[]
for i in range(0,len(S)-len(T)+1):
	b.append(check(S,T,i))
b.sort()
print(b[0])



Fixed code:
def check(S,T,i):
	count=0
	for j in range(i,len(T)+i):
		if S[j] != T[j-i]:
			count+=1
	return count

S=input()
T=input()
b=[]
for i in range(0,len(S)-len(T)+1):
	b.append(check(S,T,i))
b.sort()
print(b[0])
Buggy code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    S = Scanner.string()
    T = Scanner.string()
    ma = len(S) - len(T) + 1
    ans = len(T)
    for i in range(0, ma):
        cnt = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Fixed code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    S = Scanner.string()
    T = Scanner.string()
    ma = len(S) - len(T) + 1
    ans = len(T)
    for i in range(0, ma):
        cnt = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


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

res = 10000000000

for i in range(0, len(s)-len(t)+1):
    m = 0
    # print(s[i:], t)
    # for j, k in zip(s[i:],t):
    #     print(j,k)
    #     if j==k:
    #         m += 1
    for j in range(0, len(t)):
        # print(s[j], t[j])
        if(s[j]==t[j]):
            m+=1
            
    res = min(res, len(t)-m)
    # print(len(t)-m)

print(res)

Fixed code:
s = input()
t = input()

res = 10000000000

for i in range(0, len(s)-len(t)+1):
    m = 0
    # print(s[i:], t)
    for j, k in zip(s[i:],t):
        # print(j,k)
        if j==k:
            m += 1
            
    res = min(res, len(t)-m)

if(res==10000000000):
    print(len(t))
else: 
    print(res)
Buggy code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = [_ for _ in input()]
t = [_ for _ in input()]

ans = 10**10

for i in range(len(s) - len(t)):
  a = 0
  for j in range(len(t)):
    if s[+j] != t[j]:
      a+=1
  ans = min(a,ans)
print(ans)


Fixed code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = [_ for _ in input()]
t = [_ for _ in input()]

ans = 10**10

for i in range(len(s) - len(t)+1):
  a = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      a+=1
  ans = min(a,ans)
print(ans)
Buggy code:
S = list(input())
T = list(input())

T_length = len(T)
max_count = 0

for i in range(len(S)-T_length+1):
  count = 0
  for j in range(T_length):
    if S[i:i + T_length][j] == T[j]:
      count += 1
  else:
    if max_count > count:
      max_count = count

print(T_length - max_count)


Fixed code:
S = list(input())
T = list(input())

T_length = len(T)
max_count = 0

for i in range(len(S)-T_length+1):
  count = 0
  for j in range(T_length):
    if S[i:i + T_length][j] == T[j]:
      count += 1
  else:
    if max_count < count:
      max_count = count

print(T_length - max_count)
Buggy code:
S = input()
T = input()
min = len(S)
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if T[j] == S[i+j]:
            count += 1
    if min >= count and count != 0:
        min = count

if T in S:
    min = 0
print(min)

Fixed code:
S = input()
T = input()
min = len(S)
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if T[j] != S[i+j]:
            count += 1
    if min >= count:
        min = count

print(min)
Buggy code:
# 171 B
S = input()
T = input()
ans = [0]
tmp = 0
for i in range(0, (len(S)-len(T))):
    if S[i] == T[0]:
        for j in range(1, len(T)):
            if T[j] != S[i + j]:
                tmp += 1
        ans.append(tmp)
        
print(min(ans))
        

Fixed code:
# 171 B
S = input()
T = input()
ans = []
for i in range(0, (len(S)-len(T) + 1)):
    tmp = 0
    #print(i)
    for j in range(0, len(T)):
        if T[j] != S[i +j]:
            tmp += 1
            #print(S[i +j] + T[j])
        #print('tmp:' + str(tmp))
    ans.append(tmp)
        
print(min(ans))
Buggy code:
S = str(input())
T = str(input())
tempcount = 0
mincount = 0

if S in T:
    print("0")
    exit

for i in range(len(S) - len(T)+1):
    for j in range(len(T)+1):
        if S[i + j] != T[j]:
            tempcount += 1
    if i == 0:
        mincount = tempcount
    elif tempcount < mincount:
        mincount = tempcount
    tempcount = 0
    
print(mincount)



Fixed code:
S = str(input())
T = str(input())
tempcount = 0
mincount = 0

for i in range(len(S) - len(T)+1):
    for j in range(len(T)):
        if S[i + j] != T[j]:
            tempcount += 1
    if i == 0:
        mincount = tempcount
    elif tempcount < mincount:
        mincount = tempcount
    tempcount = 0
    
print(mincount)
Buggy code:
s = input()
t = input()

s_l = len(s)
t_l = len(t)

max_count = 0
for i in range(0, s_l - t_l + 1):
  count = 0
  for j in range(0, t_l):
    print(i, j)
    if s[i+j] == t[j]:
      count += 1
  if count > max_count:
    max_count = count

diff = t_l - max_count
print(diff)


Fixed code:
s = input()
t = input()

s_l = len(s)
t_l = len(t)

max_count = 0
for i in range(0, s_l - t_l + 1):
  count = 0
  for j in range(0, t_l):
    if s[i+j] == t[j]:
      count += 1
  if count > max_count:
    max_count = count

diff = t_l - max_count
print(diff)
Buggy code:
S = input()
T = input()

for i in range(len(S) - len(T)):
    count = 0
    maxcount = 0
    for j in range(len(T)):
        if S[i + j] == T[j]:
            count += 1
        maxcount = max(maxcount, count)
print(len(T) - maxcount)


Fixed code:
S = input()
T = input()

maxcount = 0
for i in range(len(S) - len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i + j] == T[j]:
            count += 1
        maxcount = max(maxcount, count)
print(len(T) - maxcount)
Buggy code:
S = input()
T = input()

cnt = 0

for i in range(len(s)-len(t)+1):
    same = 0
    for j in range(len(t)):
        if S[i + j] == T[j]:
            same += 1
        cnt = max(same, cnt)
print(len(t)-cnt)


Fixed code:
S = input()
T = input()

cnt = 0

for i in range(len(S)-len(T)+1):
    same = 0
    for j in range(len(T)):
        if S[i + j] == T[j]:
            same += 1
        cnt = max(same, cnt)
print(len(T)-cnt)
Buggy code:
def Qb():
    s = input()
    t = input()

    ans = len(t)
    for v in range(len(s) - len(t) + 1):
        print(f'{v=}')
        a = [t[i] != x for i, x in enumerate(s[v:len(t)+v])]
        print(s[v:v + len(t) - v])
        print(a)
        print(s[v:len(t)+v])
        if sum(a) < ans:
            ans = sum(a)
    print(ans)


if __name__ == '__main__':
    Qb()


Fixed code:
def Qb():
    s = input()
    t = input()

    ans = len(t)
    for v in range(len(s) - len(t) + 1):
        a = [t[i] != x for i, x in enumerate(s[v:len(t)+v])]
        if sum(a) < ans:
            ans = sum(a)
    print(ans)


if __name__ == '__main__':
    Qb()
Buggy code:
S, T = [input() for x in range(2)]
lenT = len(T)
max_match_len = 0

for i in range(len(S)-lenT):
  compareS = S[i:i+lenT]
  match_len = 0
  print(compareS)
  for j in range(lenT):
    if compareS[j] == T[j]:
      match_len += 1
  else:
    if max_match_len < match_len:
      max_match_len = match_len
print(len(T) - max_match_len)

Fixed code:
S, T = [input() for x in range(2)]
max_match_len = 0

for i in range(len(S)):
  if len(S) - len(T) < i:
    break
  compare_s = S[i:i+len(T)]
  match_len = 0
  for j in range(len(T)):
    if compare_s[j] == T[j]:
      match_len += 1
  else:
    if max_match_len < match_len:
      max_match_len = match_len
print(len(T) - max_match_len)
Buggy code:
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
	diff = 0
	for j in range(len(t)):
		if not s[i+j] == t[j]:
			diff=diff+1
	print(diff)
	ans = min(ans, diff)
print(ans)

Fixed code:
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
	diff = 0
	for j in range(len(t)):
		if not s[i+j] == t[j]:
			diff=diff+1
	ans = min(ans, diff)
print(ans)
Buggy code:
s = input()
t = input()

ans = len(t)
for i in range(len(s)-len(t)+1):
  tmp=0
  for j in range(len(t)):
    if t[j] == s[i+j]:
      tmp+=1
  ans = min(tmp,ans)
  
print(ans)

Fixed code:
s = input()
t = input()

ans = len(t)
for i in range(len(s)-len(t)+1):
  tmp=0
  for j in range(len(t)):
    if t[j] != s[i+j]:
      tmp+=1
  ans = min(tmp,ans)
  
print(ans)
Buggy code:
s=input()
t=input()

count_min = 1000

for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      count++
  if count < count_min:
    count_min = count

print(count_min)      

Fixed code:
s=input()
t=input()

count_min = 1000

for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      count+=1 
  if count < count_min:
    count_min = count

print(count_min)
Buggy code:
S = list(input())
T = list(input())

min_ = 99999
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    if count < min_:
        min_ = count
count

Fixed code:
S = list(input())
T = list(input())

min_ = 99999
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    if count < min_:
        min_ = count
print(min_)
Buggy code:
s = input()
t = input()

ans = len(t)
for i in range(len(s)):
    if i + len(t) - 1 >= len(s):break
    dif = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            dif += 1
        ans = min(ans, dif)

print(ans)

Fixed code:
s = input()
t = input()

ans = len(s)
for i in range(len(s)):
    if i + len(t) - 1 >= len(s):break
    dif = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            dif += 1
    ans = min(ans, dif)

print(ans)
Buggy code:
S = input()
T = input()

print(S)
print(T)

lens = len(S)
lent = len(T)

ans = 1000000

for i in range(lens - lent):
  count = 0
  for j in range(lent):
    if(S[i+j] != T[j]):
      count = count + 1

  if count < ans:
    ans = count
    
print(ans)

Fixed code:
S = input()
T = input()

lens = len(S)
lent = len(T)

ans = lent

for i in range(lens - lent + 1):
  count = 0
  for j in range(lent):
    if S[i+j] != T[j]:
      count = count + 1

  if count < ans:
    ans = count
    
print(ans)
Buggy code:
import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   for j in range(l):
      ans = 0
      if i + j > L-1:
         continue
      if T[j] == S[i + j]:
         ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Fixed code:

import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   ans = 0
   if i + l > L:
      continue
   for j in range(l):
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)
Buggy code:
s = list(input())
t = list(input())
m = len(t)
for i in range(len(s)-len(t)+1):
    c = 0
    target = s[i:i+len(t)]
    print(target)
    for j in range(len(t)):
        print(target[j],t[j])
        if not target[j] == t[j]:
            c += 1
    print(m,c)
    if c < m :
        m = c
print(m)

Fixed code:
s = list(input())
t = list(input())
m = len(t)
for i in range(len(s)-len(t)+1):
    c = 0
    target = s[i:i+len(t)]
    # print(target)
    for j in range(len(t)):
        # print(target[j],t[j])
        if not target[j] == t[j]:
            c += 1
    # print(m,c)
    if c < m :
        m = c
print(m)
Buggy code:
S=input()
T=input()
ans=len(T)
for i in range(len(S)-len(T)+1):
  _ans=0
  for j in range(len(T)):
    if S[i+j]!=T[i+j]:
      _ans+=1
  ans=min(ans,_ans)
print(ans)

Fixed code:
S=input()
T=input()
ans=len(T)
for i in range(len(S)-len(T)+1):
  _ans=0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      _ans+=1
  ans=min(ans,_ans)
print(ans)