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

ans = []

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

print(min(ans))

Submission status: Accepted

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

for i in range(len(S)-len(T)+1):
  Si = S[i:i+len(T)]
  count = 0
  for j in range(len(T)):
    if Si[j] != T[j]:
      count += 1
  if ans > count:
    ans = count

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution 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 s[i+j]!=t[j]:
            tmp+=1
    ans=min(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 1e9
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)

Submission status: Accepted

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

Submission status: Accepted

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

s_n = len(s)
t_n = len(t)

ans = 1200
for i in range(s_n - t_n + 1):
    cnt = 0
    for j in range(t_n):
        if s[i + j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)
    
print(ans)

Submission status: Accepted

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

size = len(t)
ms = []
for i in range(len(s)-size+1):
    # print(s[i:i+size])
    m = sum([a==b for a,b in zip(s[i:i+size], t)])
    ms.append(m)

print(size - max(ms))

Submission status: Accepted

Solution code:
s=input()
t=input()
li=[]
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
    li.append([count,i])
li=sorted(li)
print(li[0][0])

Submission status: Accepted

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

mincount = 9999

for i in range(len(s)-len(t)+1):
    c=0
    ss = s[i:len(t)+i]
    for j in range(len(t)):
        if ss[j] != t[j]:
            c+=1
    
    if mincount > c:
        mincount = c

print(mincount)

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s);k=len(t)
an=k
for i in range(n-k+1):
  a=s[i:i+k]
  ct=0
  for j in range(k):
    if a[j]!=t[j]:
      ct+=1
  an=min(an,ct)
print(an)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = float('inf')
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
  ans = min(ans, count)
print(ans)

Submission status: Accepted

Solution code:
def equ(a, b):
    if a == b:
        return 1
    else:
        return 0


s = input()
t = input()
max_equ = 0

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    length = len(t)
    mn = 9999
    for i in range(len(s) - length+1):
        counter = 0
        temp = s[i:i+length]
        #print(temp)
        for j,c in enumerate(temp):
            if t[j] != c:
                counter += 1
        mn = min(mn,counter)
    print(mn)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    S = list(input().strip())
    T = list(input().strip())
    tt = 0
    for i in range(len(S)-len(T)+1):
        t = 0
        for j in range(len(T)):
            if S[i+j] == T[j]:
                t += 1
        tt = max(tt, t)
    print(len(T)-tt)


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Accepted

Solution code:
S = input()
T = input()
max_a = -1
for i in range(len(S)-len(T)):
    a = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            a += 1
    if a > max_a:
        idx = i
        max_a = a
if len(S) == len(T):
    max_a = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            max_a += 1
print(len(T) - max_a)

Submission status: Accepted

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

#input = sys.stdin.readline

########################################


s = input()
t = input()
n = len(s)
m = len(t)
ans = -float("inf")
for i in range(n-m+1):
	temp = 0
	for j in range(i,i+m):
	#	print("!!",i,s[j],t[j-i])
		if t[j-i]==s[j]:
			temp+=1
	#print(i,temp)
	ans = max(temp , ans)
print(m - ans)

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    s = IS()
    t = IS()
    len_s = len(s)
    len_t = len(t)
    minv = 10**5
    for i in range(0, len_s - len_t + 1):
        cnt = 0
        for j in range(len_t):
            if s[i+j] != t[j]:
                cnt += 1
        minv = min(minv, cnt)
    print(minv)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
ans=10**7
for i in range(len(s)-len(t)+1):
  c=0
  for j in range(len(t)):
    if s[i+j]!=t[j]:
      c=c+1
  if c<ans:
    ans=c
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())
ans=len(t)
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(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ms=1000
for i in range(len(s) - len(t) + 1):
    u = 0
    for j in range(len(t)):
        if t[j] != s[i+j]:
            u += 1
    if u < ms:
        ms = u

print(ms)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 1001

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
maxMatch = 0
for x in range(len(S) - len(T) + 1):
    count = 0
    for y in range(len(T)):
        if S[x + y] == T[y]:
            count += 1
    if count >= maxMatch:
        maxMatch = count
print(len(T) - maxMatch)

Submission status: Accepted

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

mi = 10000

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
  if mi>cnt: mi=cnt
      
print(mi)

Submission status: Accepted

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

# bfで行ける
size = len(T)
ans = float("inf")
for i in range(len(S)-size+1):
    if S[i:i+size] == T:
        ans = 0
    else:
        cnt = 0
        sub_S = S[i:i+size]
        for t, s in zip(T, sub_S):
            if t != s:
                cnt += 1
        ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
res = len(t)
for i in range(0, len(s) - len(t) + 1):
    si = s[i:i + len(s)]
    tmp = len(t)
    for i in range(len(t)):
        if si[i] == t[i]:
            tmp -= 1
    res = min(res, tmp)

print(res)

Submission status: Accepted

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

lst = []

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

Submission status: Accepted

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

mx = -1
for i in range(len(S) - l + 1):
    m = [a == b for a, b in zip(S[i:i + l], T)].count(True)
    mx = max(m, mx)

print(l - mx)

Submission status: Accepted

Solution code:
s = input()
s=list(s)
t = input()
t=list(t)
k=len(t)
ans=k
for i in range(len(s)-k+1):
    su=0
    for j in range(k):

        if t[j]==s[i+j]:
            su+=1
        
    ans=min(ans,k-su)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = len(T)
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(ans, a)
print(ans)

Submission status: Accepted

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

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    s = read(str)
    t = read(str)

    min_mismatch = 10000
    for start in range(0, len(s) - len(t) + 1):
        mismatch = 0
        for i in range(start, start + len(t)):
            if s[i] != t[i - start]:
                mismatch += 1
        if mismatch < min_mismatch:
            min_mismatch = mismatch
    print(min_mismatch)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    ans = max(ans,count)
print(len(T)-ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

minnum = 1000
i = 0
while i <= len(S)-len(T):
  num = 0
  j = 0
  
  while j < len(T):
    if S[i+j] != T[j]:
      num += 1
    j += 1
  
  if minnum > num:
    minnum = num
  i += 1

print(minnum)

Submission status: Accepted

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

ans_list=[]
for s in range(len(S)-len(T)+1):
    ans = 0
    for t in range(len(T)):
        if S[s+t] != T[t]:
            ans += 1
    ans_list.append(ans)
print(min(ans_list))

Submission status: Accepted

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

anses = []
for i in range(len(s) - len(t)+1):
  cnt = 0
  for c, d in zip(s[i:i + len(t)], t):
    if c != d:
      cnt += 1
  anses.append(cnt)

print(min(anses))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    if count < min_count:
        min_count = count

print(min_count)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
sa = float('inf')

for i in range(len(s)-len(t)+1):
    s_part = s[i:(i+len(t))]
    huitti = len(t)
    for j in range(len(t)):
        if s_part[j] == t[j]:
            huitti -= 1
    sa = min(sa, huitti)

print(sa)

Submission status: Accepted

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

ans = 10**9

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 < ans:
        ans = count

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = len(T)
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
    if ans > a:
        ans = a
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
s_len = len(S)
t_len = len(T)
cnt = t_len
for idx in range(s_len - t_len + 1):
    # print(S[idx:idx+t_len],T)
    tmp_cnt = 0
    for in_idx in range(t_len):
        if T[in_idx] != S[idx + in_idx]:
            tmp_cnt += 1
    if tmp_cnt < cnt:
        cnt = tmp_cnt
print(cnt)

Submission status: Accepted

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

ans = 9999999999999999999
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())

ans = 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 = max(ans, cnt)

print(len(t) - ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = []
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.append(cnt)
    cnt = 0
print(min(ans))

Submission status: Accepted

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

min_c = len(S)

for i in range(len(T)-len(S)+1):
    Ti = T[i : i + len(S)]
    #print(Ti)
    c = 0
    for j in range(len(S)):
        if Ti[j] != S[j]:
            c += 1
    if c < min_c:
        min_c = c

print(min_c)

Submission status: Accepted

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

Submission status: Accepted

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

lens = len(s)
lent = len(t)

chk = []
for i in range(lens-lent+1):
    chk_sum = 0
    tmp = s[i:i+lens]
    for j in range(lent):
        if tmp[j] == t[j]:
            chk_sum += 1
    chk.append(chk_sum)
#print (chk)
print(lent - max(chk))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input(): return sys.stdin.readline().rstrip()

def hantei(S,T):
    anss=0
    for i in range(len(S)):
        if S[i]!=T[i]:
            anss+=1
    return anss

def main():
    S=input()
    T=input()
    ans=10000
    for i in range(len(S)-len(T)+1):
        ans=min(ans,hantei(T,S[i:i+len(T)]))
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

for i in range(0):
    print(i)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
s=input();n=len(s)
t=input();n1=len(t);ans=n1
for i in range(n-n1+1):
    s1=s[i:i+n1]
    changes=sum(1 for ch,ch1 in zip(t,s1) if ch!=ch1)
    ans=min(ans,changes)
print(ans)

Submission status: Accepted

Solution code:
from math import ceil
from collections import defaultdict, deque


def A(d, t, s):
  if t * s >= d:
    return 'Yes'
  return 'No'


def B(s, t):
  len_t = len(t)
  len_s = len(s)

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

  min_to_change = 1001
  for i in range(len_s - len_t + 1):
    to_change = _get_to_change(s[i:i + len_t], t)
    if to_change < min_to_change:
      min_to_change = to_change
  return min_to_change


def C(n, a):
  pass


def D(n):
  pass


def main():
  # d, t, s = map(int, input().split())
  # print(A(d, t, s))
  s = input()
  t = input()
  print(B(s, t))


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

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

Submission status: Accepted

Solution code:
# Date [ 2020-08-29 21:01:08 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    s = list(read_str())
    t = list(read_str())
    ans = INF

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

if __name__ == '__main__':
    Main()

Submission status: Accepted

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

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

l_S = len(S)
l_T = len(T)
ans = l_T
for i in range(l_S - l_T + 1):
    S2 = S[i:i+l_T]
    ans = min(ans, check(S2, T, l_T))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    ans = 10**4
    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 

    if ans == 10**4:
        print(len(T))
    else:
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
 
 
def main():

    s=input()
    t=input()
    n=len(s)
    m=len(t)
    ans=m
    for x in range(n-m+1):
        count=0
        cc=0
        for y in range(x,x+m):
            #print(s[y],end="")
            if s[y]!=t[cc]:
                count+=1
            cc+=1
        ans=min(count,ans)
    print(ans)


#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
mod = 10**9 + 7
def solve():
    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[j + i]:
                tmp += 1
        ans = min(ans, tmp)
    print(ans)
t = 1
while t > 0:
    solve()
    t -= 1

Submission status: Accepted

Solution code:
S = input()
T = input()
mx = 0
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if i + j < len(S) and S[i + j] == T[j]:
            t += 1
    mx = max(mx, t)
print(len(T) - mx)

Submission status: Accepted

Solution code:
s, t = list(input()), list(input())
ans = 10**10
if len(s) == len(t):
    tmp = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            tmp += 1
    ans = min(ans, tmp)
else:
    for i in range(len(s) - len(t)):
        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:
import sys
s = sys.stdin.readline().rstrip("\n")
t = sys.stdin.readline().rstrip("\n")
l = len(s)-len(t)+1
ans = 10000000000
for i in range(l):
    s_ = s[i:i+len(t)]
    ans_ = 0
    for j in range(len(t)):
        if t[j] != s_[j]:
            ans_ += 1
    ans = min(ans,ans_)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
S = list(input())
T = list(input())
ans=10000000

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(ans,tmp)

print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
mini=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
    mini=min(mini, cnt)
print(mini)

Submission status: Accepted

Solution code:
# ####################################################################
# import io
# import sys

# _INPUT = """\
# abcdefg
# abcdefg
# """
# sys.stdin = io.StringIO(_INPUT)
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################

S = input()
T = input()

ans = len(T)
# _p(len(S))
# _p(len(T))

for i in range(len(S)-len(T)+1):
  k = 0
  # _p("i=",i)
  for j in range(len(T)):
    if S[i+j] != T[j]: k += 1
  # _p(ans, k)
  ans = min(ans, k)

print(ans)

Submission status: Accepted

Solution code:
S=input()
T=input()
s,t=len(S),len(T)
n=t
for i in range(s-t+1):
    m=0
    for j in range(i,i+t):
        m+=(S[j]!=T[j-i])
    if m<n:n=m
print(n)

Submission status: Accepted

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

ls = len(s)
lt = len(t)
n = ls - lt + 1
l = []

cnt = 0
for i in range(n):
    for j in range(lt):
        if t[j] != s[i + j]:
            cnt += 1
    l.append(cnt)
    cnt = 0
    
print(min(l))

Submission status: Accepted

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

ans = 10**10

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

Submission status: Accepted

Solution code:

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

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



if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans=float("inf")
for i in range(len(S)):
    tmp=0
    for j in range(len(T)):
        if i+j>=len(S):
            break
        if S[i+j]==T[j]:
            continue
        else:
            tmp+=1
    else:
        ans=min(ans,tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    len_s = len(s)
    len_t = len(t)
    ans = float("inf")
    for i in range(len_s - len_t + 1):
        now = 0
        for j in range(len_t):
            if s[i + j] != t[j]:
                now += 1
        ans = min(ans, now)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
s=input()
t=input()
max=10000
for i in range(len(s)-len(t)+1):
    num=0
    for j in range(len(t)):
        if(t[j]!=s[i+j]):
            num+=1  
    if num<max:
        max=num
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    ld = len(s)-len(t)
    ans = 9999999999
    for i in range(ld+1):
        v = sum([0 if a==b else 1 for (a,b) in zip(list(s[i:]),list(t))])
        ans = min(ans, v)
    print(ans)

main()

Submission status: Accepted

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

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

print(len(T) - best_score)

Submission status: Accepted

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

l=len(s)
r=len(t)

ans=10000000

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
t = input()
n = len(s)
m = len(t)
ans = float("inf")
for i in range(n):
    if i+m>n:
        break
    val = sum((c!=c2) for c,c2 in zip(s[i:i+m], t))
    ans = min(ans, val)
#     print(val)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
ans=float("INF")
s=list(input())
t=list(input())
s_len=len(s)
t_len=len(t)

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

Submission status: Accepted

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

ans = len(T)

def n_gram(target, n):
  # 基準を1文字(単語)ずつ ずらしながらn文字分抜き出す
  return [ target[idx:idx + n] for idx in range(len(target) - n + 1)]

for s in n_gram(S,len(T)):
  mini = 0
  for s1,t1 in zip(s,T):
    if s1 != t1: mini+=1
  ans = min(ans,mini)
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#d,t,s = map(int,read().split())
s = input()
t = input()

ans = 1000000

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

for i in range(ls-lt+1):
    ss = s[i:i+lt]
    #print(ss)
    r = sum(a!=b for a,b in zip(ss,t))
    
    ans = min(ans,r)

print(ans)