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:
import numpy as np

s = np.array(list(input()), dtype=np.unicode)
t = np.array(list(input()), dtype=np.unicode)

ls = len(s)
lt = len(t)
L = ls- lt + 1
dif = np.empty(L, dtype=np.int64)
for i in range(L):
    dif[i] = np.count_nonzero(s[i:i+lt] != t)
ans = np.min(dif)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
 
L = len(s)
l = len(t)
Ans = 1000
 
for i in range(L-l+1):
    ans = 0
    for j in range(l):
        if s[i+j] != t[j]:
            ans += 1 
    Ans = min(ans,Ans)
 
print(Ans)

Submission status: Accepted

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

def kakikae_count(S_i):
    count = 0
    for i in range(len(T)):
        if S[S_i + i] != T[i]:
            count += 1
    return count

min_count = len(T)
for i in range(0, len(S) - len(T) + 1):
    need_count = kakikae_count(i)
    if need_count < min_count:
        min_count = need_count
print(min_count)

Submission status: Accepted

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

INF = 10**9
min_ans = INF
for i in range(len(s)-len(t)+1):
    c = 0
    for j in range(len(t)):
        si = s[i+j]
        ti = t[j]
        # print(i,j,si,ti)
        if si == ti:
            c += 1
    min_ans = min(min_ans, len(t)-c)
print(min_ans)

Submission status: Accepted

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

def find_common(s1, s2):
    count = 0
    for c,y in zip(s1, s2):
        if c == y:
            count += 1
    return count

start = 0 
end =  len(t)
ans  = 0
while end <= len(s):
    ans  = max(ans, find_common(t, s[start:end]))
    start+=1
    end+=1
print(len(t)- ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10004
cnt = 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
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

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

match = 0
for l in range(len(s)-len(t)+1):
    ma = 0
    for m in range(len(t)):
        if s[l+m] == t[m]:
            ma += 1
        match = max(match, ma)
            
print(len(t)-match)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
tmp = 0

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

for i in range(ls-lt+1):
    for j in range(lt):
        if s[i+j]==t[j]:
            tmp += 1
    cnt = max(cnt,tmp)
    tmp = 0

print(lt-cnt)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
def gmi(): return map(int, stdin.readline().strip().split())
def gms(): return map(str, stdin.readline().strip().split())
def gari(): return list(map(int, stdin.readline().strip().split()))
def gars(): return list(map(int, stdin.readline().strip().split()))
def gs(): return stdin.readline().strip()
def gls(): return list(stdin.readline())
def gi(): return int(stdin.readline())

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

Submission status: Accepted

Solution code:
S = input()
T = input()
l = []
for i in range(len(S)-len(T) + 1): 
        c = 0 
        s = S[i:i + len(T)]
        for j in range(len(T)):
                if s[j] != T[j]:
                        c += 1
        l.append(c)
print(min(l))

Submission status: Accepted

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

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

ans = len_T
for i in range(0, len_S - len_T + 1):
    match = 0
    for s, t in zip(S[i:i + len_T], T):
        if s == t:
            match += 1
    change = len_T - match
    ans = min(ans, change)

print(ans)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    s_len = len(s)
    t_len = len(t)
    if s==t:
        print(0)
        exit()

    max_match = 0
    for k1 in range(s_len - t_len + 1):
        match = 0
        for k2 in range(t_len):
            if s[k1+k2]==t[k2]:
                match+=1
        max_match = max(match, max_match)
    print(t_len - max_match)

if __name__=="__main__":
    main()

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(T)):
        #print(i, j, S[i], T[j])
        if S[i + j] == T[j]:
            count = count + 1
    if count > max:
        max = count

print(len(T) - max)

Submission status: Accepted

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy

import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class Point():
    def __init__(self,y,x):
        self.x=x
        self.y=y
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    from queue import PriorityQueue
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret
######################################################################################################
S=input()
T=input()
mmin=inf
for a in range(len(S)-len(T)+1):
    s=""
    for b in range(a,a+len(T)):
        s+=S[b]
    cnt=0
    for b in range(len(T)):
        if T[b]!=s[b]:cnt+=1
    mmin=min(mmin,cnt)
print(mmin)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    s_len, t_len = len(s), len(t)

    def gen():
        for left in range(0, s_len - t_len + 1):
            edit = sum((c_s != c_t) for c_s, c_t in zip(s[left:], t))
            yield edit
    return min(gen())


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

Submission status: Accepted

Solution code:
import math

S = input()
T = input()
ans = math.inf
for i in range(len(S) - len(T)+1):
    tmp = sum([s != t for s, t in zip(S[i:i + len(T)], T)])
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

n = len(s) - len(t) + 1
m = [0] * n

for i in range(n):
    for j in range(len(t)):
        if s[i + j] != t[j]:
            m[i] += 1

print(min(m))

Submission status: Accepted

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

LT = len(T)
same = 0
if len(S) - LT != 0:
    for i in range(len(S) - LT):
        tS = S[i:i+LT]
        tmp = 0
        for j in range(LT):
            if T[j] == tS[j]:
                tmp += 1
        same = max(same,tmp)
    print(LT - same)
else:
    ans = 0
    for i in range(LT):
        if T[i] == S[i]:
            ans += 1
    print(LT - ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


S=list(ns())
T=list(ns())

INF=10**9
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]):
            tmp+=1
    ans=min(ans,tmp)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
l = len(s) - len(t)
lt = int(len(t))
count = 0
max_count = 100000000000
for i in range(l+1):
  x = s[i:lt+i]
  for i in range(len(x)):
    if x[i] != t[i]:
      count += 1
  if count <= max_count:
    max_count = count
  count = 0
print(max_count)

Submission status: Accepted

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

tt = t

max_count = 0
while True:
    count = 0
    for i in range(len(tt)):
        if s[i] == tt[i]:
            count += 1 
    # print(count)
    max_count = max(max_count, count)
    
    # print(f"{len(s)} {len(t)}")
    if len(s) == len(tt):
        break
    
    tt = ' ' + tt
    
print(len(t) - max_count)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 10000
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)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
ss, tt = len(s), len(t)
flag = 0
for i in range(ss - tt + 1):
    temp = s[i: i + tt + 1]
    ttt = 0
    for k, j in zip(temp, t):
        if k == j:
            ttt += 1
    flag = max(flag, ttt)
print(tt - flag)

Submission status: Accepted

Solution code:
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x




	
def main():
	s=I().strip()
	t=I().strip()
	win=len(t)
	ans=999999
	for i in range(len(s)-win+1):
		x=0
		for j in range(win):
			if s[i+j]!=t[j]:
				x+=1
		ans=min(ans,x)
	print(ans)

			


	

























	
	
	





if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:

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

ls=len(S)
lt=len(T)

anslist=[]

for i in range(ls-lt+1):
    ans=lt
    S_list=S[i:i+lt]
    for j in range(lt):
        if S_list[j]==T[j]:
            ans-=1
    anslist.append(ans)

print(min(anslist))

Submission status: Accepted

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

ns= len(s)
nt = len(t)
ans =0


for i in range(ns-nt+1):
    count = 0
    for j in range(nt):
        if s[i+j] == t[j]:
            count +=1
    else:
        ans = max(ans, count)

print(nt-ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(t)-1
ans = len(t)
for i in range(len(s)-n):
  num = 0
  w = s[i:i+n+1]
  for l in range(len(t)):
    if t[l] != w[l]:
      num += 1
  ans = min(num,ans)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

    max = 0
    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 > max:
            max = count
    print(len(T) - max)


main()

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
ans = len(t)

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

    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

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

def solve(S,T):
    m = 1000000
    
    for i in range(len(S)-len(T)+1):
        cnt = difference(T,S[i:i+len(T)])

        m = min(m,cnt)

    return m


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

    return c

print(solve(S,T))

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(s,t):
    l = len(t)
    flags = [True]+[False]*3
    tmp = 0
    for i in range(len(s)-l+1):
        tmp2 = 0
        for j in range(l):
            if s[i+j] == t[j]:
                tmp2 += 1
        tmp = max(tmp,tmp2)
    print(l-tmp)

            

def main():
    s = input().rstrip()
    t = input().rstrip()
    solve(s,t)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = float("INF")
for i in range(len(s)-len(t)+1):
    x = 0
    for j in range(len(t)):
        x += (s[i+j] != t[j])
    ans = min(ans,x)
print(ans)

Submission status: Accepted

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

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

    if cnt > m_cnt:
        m_cnt = cnt
    cnt = 0

print(len(T) - m_cnt)

Submission status: Accepted

Solution code:
import math
import collections
import itertools

def resolve():
    #D,T,S=map(int,input().split())
    S=input()
    T=input()

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

resolve()

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
T = list(input())
n = len(T)
ans = n
for i in range(N - n + 1):
    s = S[i:i + n]
    a = 0
    for j in range(n):
        if T[j] != s[j]:
            a += 1
    if a < ans:
        ans = a
print(ans)

Submission status: Accepted

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

for i in range(len(s) - len(t) + 1):
    cor = 0
    for j in range(len(t)):
        if t[j] != s[i + j]:
            cor = cor + 1
    if min_cor > cor:
        min_cor = cor
print(min_cor)

Submission status: Accepted

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

max_count = 0
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
    max_count = max(max_count, count)

print(len(T)-max_count)

Submission status: Accepted

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


vals = []
for i in range(0, len(s) - len(t) + 1):
    q = s[i:i + len(t)]
    # print(t)

    cnt = 0
    for j in range(len(t)):
        # print(q[j])
        # print(t[j])
        if q[j] != t[j]:
            cnt += 1
        # print(cnt)

        # print(' --- ')

    vals.append(cnt)
    
print(min(vals))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
maxCnt = 0
len_s = len(s)
len_t = len(t)
for i in range(len_s - len_t + 1):
    cnt = 0 
    s_str = s[i:i+len_t]
    for j in range(len(t)):
        if t[j] == s_str[j]:
            cnt += 1
        else:
            pass
    maxCnt = max(maxCnt, cnt)
ans = len_t - maxCnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d = len(s) - len(t)
min_c = int(1e4)
for i in range(d+1):
    st = s[i:i+len(t)]
    c = 0
    for j in range(len(t)):
        if st[j] != t[j]:
            c += 1
            if c > min_c:
                break
    min_c = min(c, min_c)

print(min_c)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def matching(a,b):
    count=0
    for i in range(len(a)):
        if a[i]==b[i]:
            count+=1
    return len(a)-count

s=input()
t=input()
k=len(s)
l=len(t)
minChange=None
for i in range(k-l+1):
    temp=s[i:i+l]
    change=matching(temp,t)
    if minChange==None or change<minChange:
        minChange=change
print(minChange)

Submission status: Accepted

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

lenS = len(S)
lenT = len(T)

ans = lenT
for i in range(lenS - lenT + 1):
    mem = 0
    for j, t in enumerate(T):
        if S[i + j] != t:
            mem += 1
    ans = min(ans, mem)
print(ans)

Submission status: Accepted

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

d = len(S)-len(T)

cntlist = []
for i in range(d+1):
    cnt = 0
    s = S[i:i+len(T)]
    for j in range(len(T)):
        cnt += T[j] == s[j]
    cntlist.append(cnt)

print(len(T)-max(cntlist))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
t = input()
lens, lent = len(s), len(t)
n = lens - lent + 1
mi = lent
for i in range(n):
    temp = 0
    for j in range(lent):
        if s[i + j] != t[j]:
            temp += 1
    if temp <= mi:
        mi = temp
print(mi)

Submission status: Accepted

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

def func(s, t):
    x = len(t)
    for i in range(len(t)):
        if s[i]==t[i]:
            x-=1
    return x
ans = 10000
for j in range(len(S)-len(T)+1):
    s = S[j:j+len(T)]
    ans = min(ans, func(s,T))
print(ans)

Submission status: Accepted

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

s=len(S)
t=len(T)
s_end=s-t+1

def count_mismatch(a):
    global t
    global T

    c=0
    for i in range(t):
        if a[i] != T[i]:
            c+=1
    return c


ans = t
for i in range(s_end):
    c = count_mismatch(S[i:i+t])
    if c < ans:
        ans = c

print(ans)

Submission status: Accepted

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

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

res = 10000
for i in range(len(s)-len(t)+1):
    res = min(compare(s[i:i+len(t)], t), res)

print(res)

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
len_s = len(S)
len_t = len(T)

max_same = 0

for i in range(len_s - len_t + 1):
  tmp = 0
  for j in range(len_t):
    if S[i+j] == T[j]:
      tmp += 1
    max_same = max(max_same, tmp)

print(len_t - max_same)

Submission status: Accepted

Solution code:
x = input()
y = input()

re = 0

for a in range(0,len(x)-len(y)+1):
  z = 0
  for b in range(0,len(y)):
    if y[b] == x[b+a]:
      z = z+1
      if(z>re):
        re = z
dd = len(y) - re
print(dd)

Submission status: Accepted

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

len_s = len(S)
len_t = len(T)

max_count = 0
for x in range(len_s - len_t + 1):
    count = 0 #初期化
    for y in range(len_t):
#        print(S[y+x], T[y])
        if S[y+x] == T[y]:
            count += 1
        else:
            pass
#        print(count)

    if max_count < count:
        max_count = count
#    print(x, max_count)
    
print(len_t - max_count)

Submission status: Accepted

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

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

Submission status: Accepted

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

s = len(S)
t = len(T)

min_count = t
for i in range(s - t + 1):
    count = 0
    for j, tt in enumerate(T):
        if S[i: i + t][j] == tt:
            count += 1
    change = t - count
    if change < min_count:
        min_count = change
print(min_count)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = len(t)
for i in range(len(s) - len(t) + 1):
    ss = s[i:i + len(t)]
    # print(ss)
    cnt = 0
    for i,e in enumerate(ss):
        if e != t[i]:
            cnt += 1
    # print(cnt)
    ans = min(ans,cnt)

print(ans)

Submission status: Accepted

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

max_val = 0
index = 0
for i in range(len(s)- len(t) + 1):
    val = 0
    for c in range(len(t)):
        if s[i + c] == t[c]:
            val += 1
            if val > max_val:
                max_val = val
                index = [i]

print(len(t) - max_val)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
ans = 0
for i in range(n-m+1):
    cnt = 0
    for j in range(m):
        if s[i+j] == t[j]:
            cnt += 1
    ans = max(ans, cnt)
print(m - ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))

same = 0

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

print(max(0,len(t) - same))