Problem:


Score : 200 points

Problem Statement

Given are two strings S and T.

Let us change some of the characters in S so that T will be a substring of S.

At least how many characters do we need to change?

Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.

Constraints

The lengths of S and T are each at least 1 and at most 1000.

The length of T is at most that of S.

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

Print the minimum number of characters in S that need to be changed.

Sample Input 1

cabacc
abc

Sample Output 1

1

For example, changing the fourth character a in S to c will match the second through fourth characters in S to T.

Since S itself does not have T as its substring, this number of changes - one - is the minimum needed.

Sample Input 2

codeforces
atcoder

Sample Output 2

6



Sample input:
cabacc
abc


Sample output:
1

Submission status: Accepted

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

Min = 100000

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

print(Min)

Submission status: Accepted

Solution code:
S=list(map(str,input()))
T=list(map(str,input()))
X=[]
Z=0
for I in range(len(S)-len(T)+1):
    Y=S[I:I+len(T)]
    Z=0
    for J in range(len(T)):
        if Y[J]==T[J]:
            Z=Z+1
    X.append(Z)
if not X==[]:
    print(len(T)-max(X))
elif S==T:
    print(0)
else:
    print(len(T))

Submission status: Accepted

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

max = 0

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

Submission status: Accepted

Solution code:
S = input()
T = input()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT + 1):
        d = 0
        for lt in range(LT):
            if S[ls + lt] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))

Submission status: Accepted

Solution code:
S=str(input())
T=str(input())
t=1000
Slen=1000
Tlen=1000
for i in range(1000):
  try:
    k=S[i]
  except IndexError:
    Slen=i
    break
for j in range(1000):
  try:
    k=T[j]
  except IndexError:
    Tlen=j
    break

for i in range(Slen-Tlen+1):
  s=0
  for j in range(Tlen):
    if S[i+j]==T[j]:
      s+=1
    else:
      continue
  t=min(t,Tlen-s)
print (t)

Submission status: Accepted

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

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

Submission status: Accepted

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

mincount=len(T)

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

print(mincount)

Submission status: Accepted

Solution code:
S = input()
T = input()
if S.find(T) != -1:
    min = 0
else:
    min = float('inf')
    r = len(S) - len(T)
    for i in range(r+1):
        t = 0
        for j, v in enumerate(T):
            t += int(S[i+j] != v)
        if min > t:
            min = t

print(min)

Submission status: Accepted

Solution code:
S = input()
T = input()
s = len(S)
t = len(T)

ans = 1000

for i in range(s-t+1):
  cnt = 0
  for j in range(t):
    if S[i+j] != T[j]:
      cnt += 1
  ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
M = len(S)
N = len(T)

ans = N
diff = M - N

for i in range(diff + 1):
    U = '0' * i + T
    count = N
    for j in range(N + i):
        if U[j] == S[j]:
            count -= 1
    ans = min(ans, count)
print(ans)

Submission status: Accepted

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

ls = len(s)
lt = len(t)

if ls == lt:
    tmp = s[0:lt]
    score = 0
    for j in range(lt):
        if tmp[j] != t[j]:
            score += 1
    print(score)
    exit()

ans = 10000000
for i in range(ls - lt):
    tmp = s[i:i+lt]
    score = 0
    for j in range(lt):
        if tmp[j] != t[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Submission status: Accepted

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

b = 1000

for i in range(len(S) - len(T) + 1):
  a = 0
  for j in range(len(T)):
    if list(S[i + j]) == list(T[j]):
      a = a
    elif list(S[i + j]) != list(T[j]):
      a += 1
  if a < b:
    b = a
  else:
    b = b

print(b)

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def kotonaru_num(a, b):
	if len(a) != len(b):
		return 1/0
	ret = 0
	for c, s in zip(a, b):
		if c != s:
			ret += 1
			
	return ret
 

def main():
	#a = int(input())
	#b , c = tin()
	s = input()	
	t = input()
	ret = mod
	for i in range(len(s) - len(t)+1):
		cc = s[i:i+len(t)]
		#pa(cc)
		tr = kotonaru_num(cc, t)
		ret = min(ret, tr)
	print(ret)
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
mini = []

if len(S) != len(T):
    for i in range(len(S) - len(T)):
        count = 0
        for j in range(len(T)):
            if T[j] == S[j+i]:        
                count+=1
        mini.append(len(T) - count)
    print(min(mini))
else:
    count = 0
    for i in range(len(S)):
       if T[i] == S[i]:
           count+=1
    print(len(T) - count)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
ans = []
if len(s)-len(t) == 0:
  an = 0
  for j in range(len(t)):
      if s[j] == t[j]:
        an += 1
  print(len(t)-an)
else:
  for i in range(len(s)-len(t)):
    ans.append(0)
    for j in range(len(t)):
      if s[i+j] == t[j]:
        ans[i] += 1
  print(len(t) - max(ans))

Submission status: Accepted

Solution code:
S = input()
T = input()
 
ans = 0
if T in S:
  print(ans)
  exit()
ls = len(S)
lt = len(T)
ans = 100000
for i in range(ls-lt+1):
  cnt = 0
  for j in range(lt):
    if S[i+j] != T[j]:
      cnt += 1
  ans = min(ans,cnt)
 
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
cnt = 0
min = 0
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 min < cnt:
        min = cnt
ans = len(t)-min

s = s[::-1]
t = t[::-1]
cnt=0
min=0
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 min < cnt:
        min = cnt
if ans > len(t)-min:
    ans = len(t)-min
f = s.find(t)
if f < ans and f != -1:
    ans = f
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
Slen = len(S)
Tlen = len(T)
N = max(Slen - Tlen, 1)
ans = Tlen
for i in range(N):
	tmp = 0
	for j in range(Tlen):
		if S[i + j] != T[j]:
			tmp += 1
	ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
Slist = list(S)
Tlist = list(T)
Ulist = []
ans = len(T)
count = 0

for i in range(len(S)-len(T)+1):
    Ulist = Slist[i:len(T)+i:] 
    for j in range(len(T)):
        if(Tlist[j] == Ulist[j]):
            count += 1
    ans = min(ans,len(T)-count)
    count = 0

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
buf =[]
for i in range(len(S)-len(T)+1):
    A=S[i:(i+len(T))]
    same = 0
    for j in range(len(T)):
        if A[j]==T[j]:
            same+=1
    buf.append(same)
print(len(T)-max(buf))

Submission status: Accepted

Solution code:
import sys
s = input()
t = input()

n,m = len(s),len(t)

ans = sys.maxsize


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

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s)
m = len(t)
x = 0
for i in range(n - m + 1):
    c = 0
    for j in range(m):
        if s[i:(i + m)][j] == t[j]:
            c += 1
    if c > x:
        x = c
print(m - x)

Submission status: Accepted

Solution code:
S = input()
T = input()
n = len(T)

if S.count(T) > 0:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
S = input()
T = input()
Sli = list(S)
Tli = list(T)
cli = []

for i in range(len(Sli) - len(Tli) + 1):
    c = len(Tli)
    for j in range(len(Tli)):
        if Sli[i + j] == Tli[j]:
            c -= 1
    cli.append(c)

print(min(cli))

Submission status: Accepted

Solution code:
s=input()
t=input()
y=len(t)
z=len(s)
yy=y
for i in range(0,(z-y+1)):
    xx=i+y
    s1=s[i:xx]
    ct=0
    
    for j in range(0,y):
        if(s1[j]==t[j]):
            ct+=1
    z=y-ct
    if(z<yy):
        yy=z
print(yy)

Submission status: Accepted

Solution code:
import numpy as np
s = input()
t = input()
strs = []
t_size = len(t)
for i in np.arange(len(s)-len(t)+1):
    strs.append(s[i:i+t_size])
n = 0
max_n = 0
for ss in strs:
    for i in np.arange(len(t)):
        if t[i]==ss[i]:
            n += 1
        if max_n < n:
            max_n = n
    n = 0
print(len(t)-max_n)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
S = input()
s = list(S)
T = input()
t = list(T)
ss = len(s)
tt = len(t)
ll = ss - tt +1

A = [[] for _ in range(ll)]

for i in range(ll):
  for j in range(tt):
    A[i].append(s[int(i)+int(j)])
    
d = tt

for i in range(ll):
  e = 0
  for j in range(tt):
    if A[i][j] != t[j]:
      e += 1
  if e<d:
    d = e
  else:
    d = d
    
print(d)

Submission status: Accepted

Solution code:
s=input()
t=input()
track=len(t)
for i in range(len(s)-len(t)+1):
	x=0
	for k in range(len(t)):	
		if t[k]!=s[i+k]:
			x+=1
	track=min(track,x)
print(track)

Submission status: Accepted

Solution code:
S = input()
T = input()
ls = len(S)
lt = len(T)


m = 0
for i in range(ls-lt+1):
    tmp = S[i:i+lt]
    cnt = 0
    for idx,j in enumerate(tmp):
        if T[idx]==j:
            cnt+=1
    m = max(cnt,m)

print(lt-m)

Submission status: Accepted

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


num_same_all = 0
for i in range(len(S)-len(T)+1):
    num_same = 0
    for j in range(len(T)):
        if S[j+i] == T[j]:
            num_same += 1
    
    if num_same_all < num_same:
        num_same_all = num_same

print(len(T)-num_same_all)

Submission status: Accepted

Solution code:
S=input()
T=input()
k = len(T)
ans=k
lim=0
for i in range(len(S)-len(T)+1):
  for j in range(k):
    #print(i, j, S[i+j],T[j])
    if S[i+j]!=T[j]:
      lim+=1
  if lim<=ans:
    ans=lim
  lim=0
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
d = len(s)-len(t)+1
max = 0
for i in range(d):
    n = 0
    for j in range(len(t)):
        if s[j+i] == t[j]:
            n += 1
    if n > max:
        max = n
print(len(t)-max)

Submission status: Accepted

Solution code:
s=input()
t=input()
sz=len(t)
ans=100000000000
c=0
if len(s)==sz:
    c=0
    for j in range(sz):
        if s[j]==t[j]:
            c+=1
        else:
            ans=min(ans,sz-c)
else:
    for i in range(0,len(s)-sz):
        k=s[i:i+sz]
        c=0
        for j in range(sz):
            if k[j]==t[j]:
                c+=1
            else:
                ans=min(ans,sz-c)
        # print(c)
ans=min(ans,sz-c)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s)-len(t)+1
tn = len(t) 

ans = tn
for i in range(n):
    si = s[i:i+tn]
    cnt = 0
    for j in range(tn):
        if si[j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
score=[]
for i in range(len(s)-len(t)+1):
  point=0
  for j in range(len(t)):
    if s[i+j]==t[j]:
      point+=1
  score.append(point)
cnt=0
w=max(score)
w_iti=score.index(w)
for i in range(len(t)):
  if s[w_iti+i] != t[i]:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
n=len(t)
m=len(s)
mn=n
for i in range(m-n+1):
    err=0
    for j in range(n):
        if s[i+j]!=t[j]:
            err+=1
    mn=min(mn,err)
print(mn)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = list(input())
    t = list(input())

    max_score = 0
    if len(s) == len(t):
        max_score = sum([s[j] == t[j] for j in range(len(t))])
    else:
        for i in range(0, len(s) - len(t)):
            score = sum([s[i + j] == t[j] for j in range(len(t))])
            if max_score < score:
                max_score = score
    print(len(t) - max_score)

Submission status: Accepted

Solution code:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    S = input()
    T = input()

    min_len = len(T)
    for i, s in enumerate(S[:len(S)-len(T)+1]):
        sub = S[i:i+len(T)]
        # print(sub)
        count = 0
        for j, t in enumerate(T):
            if sub == T:
                break
            if sub[j] == t:
                continue
            sub = sub[:j] + t + sub[j+1:]
            count += 1

        min_len = min(min_len, count)

    return min_len


def main():
    print(solve())


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
m = len(S)
n = len(T)
mn = m
for i in range(m-n+1):
    sub = S[i:i+n]
    counter = 0
    for j in range(n):
        if sub[j] != T[j]:
            counter += 1
    if mn > counter:
       mn = counter 
print(mn)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')
import sys
import itertools
import copy


def main():
    # D, T, S = MI()
    # L = LLIN(N)
    S = ST()
    T = ST()

    if T in S:
        print(0)
        sys.exit()
    len_s = len(S)
    len_t = len(T)
    diff = len_s - len_t
    match_list = []

    if len_t == len_s:
        cnt_match = 0
        for j in range(len_t):
            if S[j] == T[j]:
                cnt_match+=1
        match_list.append(cnt_match)
        print(len_t - max(match_list))
        sys.exit()

    for i in range(diff):
        cnt_match = 0
        for j in range(len_t):
            if S[j + i] == T[j]:
                cnt_match+=1
        match_list.append(cnt_match)
    # print(match_list)
    # print(len_t)
    # print(max(match_list))
    # if len(match_list) == 0:

    print(len_t - max(match_list))
    # ushiro = 0
    # for i in range(len(T)):
    #     print(T[0:len(T)-i])
    #     a = T[0:len(T)-i]
    #     ushiro = i
    #     if a in S:
    #         break
    # mae = 0
    # for i in range(len(T)):
    #     print(T[i:len(T)])
    #     b = T[i:len(T)]
    #     mae = i
    #     if b in S:
    #         break
    # print(ushiro)
    # print(mae)
    # if min(ushiro,mae) == 0:
    #     print(0)
    #     sys.exit()

    # print(min(ushiro,mae) - 1)
    #     if T[-i]
    # if D / T <= S:
    #     print('Yes')
    # else:
    #     print('No') 
    # cnt = 0
    # for l in L:
    #     num = l[0] ** 2 + l[1] ** 2 
    #     if num <= D ** 2:
    #         cnt+=1
    # print(cnt)
    # print(row)
    # total = sum(row)
    # target = total - K
    # if K == total:
    #     print(1)
    #     sys.exit()
    # col = []
    # for w in range(W):
    #     cnt = 0
    #     for h in range(H):    
    #         print(A[h][w])
    #         if A[h][w] == '#':
    #             cnt += 1
    #     col.append(cnt)
    # print(col)
    # ans = 0
    # for w in range(W):
    #     for h in range(H):
    #         if A[h][w] == '#':
    #             if col[w] + row[h] - 1 == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    #         else:
    #             if col[w] + row[h] == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    # print(ans)
    #     for  in x:


    # print('AC x ' + str(cnt['AC']))
    # print('WA x ' + str(cnt['WA']))
    # print('TLE x ' + str(cnt['TLE']))
    # print('RE x ' + str(cnt['RE']))
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = input()
b = input()

l = []
for i in range(len(a) - len(b) + 1):
    cnt = 0
    for j in range(len(b)):
        if b[j] == a[i + j]:
            cnt += 1
    l.append(cnt)

#print(l)
print(len(b) - max(l))

Submission status: Accepted

Solution 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)

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
n = len(T)
ans = 0

x = 0
y = 0
s = ''
for i in range(N - n + 1):
    s = S[i:i + n]
    for j in range(n):
        if s[j] == T[j]:
            x += 1
    ans = max(ans, x)
    x = 0
ans = n - ans
print(ans)

Submission status: Accepted

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

Sn = len(S)
Tn = len(T)

ans = 0

for i in range(Sn - Tn + 1):
    L = S[i:i + Tn]
    ans_ = 0
    for j, k in zip(L, T):
        if j == k:
            ans_ += 1
    ans = max(ans, ans_)

print(Tn - ans)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''

    S = input()
    T = input()

    if T in S:
        print(0)
    else:
        res = 0
        for i in range(len(S) - len(T) +1):
            temp = S[i:]
            max_num = 0
            for j in range(len(T)):
                if temp[j] == T[j]:
                    max_num += 1
            res = max(res, max_num)

        print(len(T) - res)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

l = len(t)
same = 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 count > same:
        same = count

print(len(t) - same)

Submission status: Accepted

Solution code:
S=str(input())
T =str(input())
c=len(T)
for i in range(len(S)-len(T)+1):
    count=len(T)
    for n in range(len(T)):
        if S[i+n] == T[n]:
            count -=1
       
    
    
    
    if count <c:
        c=count
print(c)

Submission status: Accepted

Solution code:
import sys

s = input()
t = input()
ls = len(s)
lt = len(t)

ans = lt
for i in range(ls -lt + 1):
  tmp = lt
  for j in range(lt):
    if s[i + j] == t[j]:
      tmp -= 1
  ans = min(ans, tmp)
  if ans == 0:
    print(0)
    sys.exit()
  
print(ans)

Submission status: Accepted

Solution code:
import sys 

string1 = str(input())
string2 = str(input())

n, m = len(string2), len(string1) 

ans = sys.maxsize 
for i in range(m - n + 1): 
    minRemovedChar = 0 
    for j in range(n): 
        if (string2[j] != string1[i + j]): 
            minRemovedChar += 1
    ans = min(minRemovedChar, ans) 

print(ans)

Submission status: Accepted

Solution code:
def compute(a,b):
	# print(a,b)
	n = len(a)
	cnt = 0
	for i in range(n):
		if(a[i] == b[i]):
			cnt+=1
	return cnt

s = input()
t = input()
# print(s,t)


sl = len(s)
tl = len(t)

ans = tl

tmp1 = s[0:tl]
tmp2 = t 
# print(compute(tmp1,tmp2))
ans = min(tl - compute(tmp1,tmp2), ans)
# ans = min(tl - compute(tmp1[::-1], tmp2[::-1]), ans)

for i in range(sl-tl):
	tmp1 = s[i:i+tl]
	tmp2 = t
	ans = min(tl - compute(tmp1,tmp2), ans)
	# ans = min(tl - compute(tmp1[::-1], tmp2[::-1]), ans)

print(ans)

Submission status: Accepted

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

def count_diff2(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

temp = 0
ans = len(T)

for i in range(len(S)-len(T) + 1) :
    temp = count_diff2(T, S[i:len(T) + i])
    if temp < ans:
        ans = temp

print(ans)

Submission status: Accepted

Solution code:
#one, two, three, four, five = map(int, input().split())
#li = list(map(int, input().split()))
def Levenshtein(str1,str2):
  count = 0
  for i in range(len(str1)):
    if str1[i] != str2[i]:
      count += 1
  return count

S = input()
T = input()
min_ = 9999999
for i in range(len(S)-len(T)):
  str1 = S[i:i+len(T)]
  str2 = T
  #print(str1,str2)
  leven = Levenshtein(str1,str2)
  if(leven < min_):
    min_ = leven
if len(S)==len(T):
  if S==T:
    min_=0
  else:
    min_=Levenshtein(S,T)
print(min_)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    s = S()
    t = S()
    ans = inf
    for i in range(len(s) - len(t) +1):
        tmp = 0
        for j in range(len(t)):
            if s[i + j] == t[j]:
                continue
            tmp += 1
        ans = min(ans, tmp)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

n = len(t)

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

Submission status: Accepted

Solution code:
S = input()
T = input()
MIN = len(T)

while len(T) <= len(S):
  cnt = 0
  for(SL,TL) in zip(list(S),list(T)):
    if SL != TL:
      cnt = cnt + 1
  
  if MIN > cnt:
   MIN = cnt
  
  S = S[1:]

print(MIN)

Submission status: Accepted

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

length_s, length_t = len(S), len(T)

dif = length_s-length_t+1

res = 0
for i in range(dif):
    st = sum(1 if s == t else 0 for s, t in zip(S[i:i+length_t], T))
    res = max(res, st)

print(length_t-res)

Submission status: Accepted

Solution 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])

Submission status: Accepted

Solution code:
import sys
def minimumchar(s1,s2):
	n,m=len(s1),len(s2)
	ans=sys.maxsize
	for i in range(m-n+1):
		minRemovedChar=0
		for j in range(n):
			if (s1[j]!=s2[i+j]):
				minRemovedChar+=1
		ans=min(minRemovedChar,ans)
	return ans
	
s2=input()
s1=input()

print(minimumchar(s1,s2))

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
cnt = 0
s_len = len(s)
t_len = len(t)
sa = s_len - t_len
Max = 0
for i in range(len(s) - len(t) + 1):
    ss = s[i:i+len(t)]
    for j in range(len(t)):
        if ss[j] == t[j]:
            cnt += 1
    Max = max(Max,cnt)
    cnt = 0
print(len(t) - Max)

Submission status: Accepted

Solution code:
S = input()
T= input()
ans=0
if T in S:
  ans=0
  
S=list(S)
T=list(T)


S_pattern=[]
pre=0
lat=len(T)
while True:
  S_pattern.append(list(S[pre:lat]))
  pre+=1
  lat+=1
  if lat==len(S)+1:
    break

scores=[]
for i in S_pattern:
  score=0
  for k in range(len(i)):
    if T[k] != i[k]:
      i[k] = T[k]
      score+=1
  scores.append(score)
  
print(min(scores))

Submission status: Accepted

Solution code:
S = input()
T = input()
 
min = len(T)
for t in range(len(S) - len(T)+1):
    tmp = 0
    for i in range(len(T)):
        if S[i+t] != T[i]:
            tmp+=1
    
    if tmp < min:
        min = tmp
 
print(min)

Submission status: Accepted

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

from collections import deque

if T in S:
    print(0)

else:
    n = len(S) - len(T)
    lst = []
    for x in range(n + 1):
        s = S[x:(len(T) + x)]
        ds = deque(s)
        dt = deque(T)
        count = 0
        while ds:
            if ds.popleft() == dt.popleft():
                count += 1
        lst.append(count)
    print(len(T) - max(lst))

Submission status: Accepted

Solution code:

S = list(input())
T = list(input())

diff = len(S) - len(T)

mins = []
for i in range(diff+1):
    s = S[i:i+len(T)]
    c = 0
    #print(s)
    for ss, tt in zip(s, T):
        if(ss != tt):
            c += 1
    mins.append(c)     

print(min(mins))

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())
n=len(t)
m=len(s)
a=[]
if t in s:
  print(0)
else:
  for i in range(m-n+1): #ずらす文字数
    ans=0
    for j in range(n):
      if s[i+j]!=t[j]:
        ans+=1
    a.append(ans)
  print(min(a))

Submission status: Accepted

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

min_diff=len(T)
for i in range(len(S)-len(T)+1):
    diff=len(T)
    for j in range(len(T)):
        if T[j]==S[i+j]:
            diff -= 1
    if diff<min_diff:
        min_diff = diff
ans = min_diff
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

count = len(t)

for i in range(0, len(s) - len(t) + 1):
    x = s[i : i + len(t)]
    cnt = 0
    for i in range(len(t)):
        if t[i] != x[i]:
            cnt += 1
    if count >= cnt:
        count = cnt

print(count)

Submission status: Accepted

Solution code:
s,t=input(),input()
l=len(t)
print(l-max(sum(s[i+j]==t[j] for j in range(l)) for i in range(len(s)-l+1)))

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
SA = []
ans = [0]

for i in range( (len(S)-len(T)) + 1):
    SA = S[i:i+len(T)]
    for j in range(len(T)):
        if (SA[j] == T[j]) == True:
            count += 1
    ans.append(count)
    count = 0

print(len(T) - max(ans))

Submission status: Accepted

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

ns = len(list(S))
nt = len(list(T))

node = [0] * (ns-nt+1)

for i in range(ns-nt+1):
    for j in range(nt):
        if S[i+j] == T[j]:
            node[i] += 1


print(nt - max(node))

Submission status: Accepted

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

def count_mismatch(a, b):
    ans = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            ans += 1

    return ans

lt = len(t)
ans = len(s)
for i in range(len(s)-lt+1):
    part = (s[i:i+lt])
    tmp_ans = count_mismatch(part, t)
    ans = min(ans, tmp_ans)

print(ans)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    t = list(input())

    min_v = len(t)
    
    for i in range(len(s)-len(t)+1):
        cnt = 0
        for x, y in zip(s[i:i+len(t)], t): 
            if not(x == y):
                cnt += 1
            
        if min_v > cnt:
            min_v = cnt

    print(min_v)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S = str(input())
    T = str(input())
    counter = 0
    max_match = 0

    if T in S:
        print(0)
    else:
        for i in range(len(T), len(S)+1):
            counter = 0
            for j in range(len(T)):
                if S[i-len(T)+j] == T[j]:
                    counter += 1
            if max_match < counter:
                max_match = counter
        print(len(T)-max_match)
main()

Submission status: Accepted

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

c1 = len(s)
c2 = len(t)
max_count = 0
if c1 != c2:
  for i in range(c1 - c2):
    count = 0
    for j in range(c2):
      if s[i + j] == t[j]:
        count += 1
    if count > max_count:
      max_count = count
else:
  for i in range(c1):
    if s[i] == t[i]:
      max_count += 1
print(c2-max_count)

Submission status: Accepted

Solution code:
s = input()
t = input()
count_list = []
count = 0

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

print(min(count_list))

Submission status: Accepted

Solution code:
s = input()
t = input()
res = []
for i in range(len(s)-len(t)+1):
    x = s[i:i+len(t)]
    count = sum(1 for a, b in zip(t, x) if a != b)
    res.append(count)
print(min(res))

Submission status: Accepted

Solution code:
xmoji=input()
ymoji=input()

x=len(xmoji)
y=len(ymoji)
tempmin = 0
for i in range(0,x-y+1):
    xmin=xmoji[i:i+y]
    samenum=0
    for j in range(0,y):
        if(xmin[j]==ymoji[j]):
            samenum+=1
    if(tempmin<samenum):
        tempmin = samenum
print(y-tempmin)