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()
answer = 0
for i in range(len(S)-len(T)+1):
    samecnt = 0
    for j in range(len(T)):
        if S[j+i] == T[j]:
            samecnt += 1
    answer = max(answer, samecnt)

print(len(T)-answer)

Submission status: Accepted

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

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

for j in range(lenS - lenT + 1):
  sameCnt = 0
  for i in range(lenT):
    if S[j + i] == T[i]:
      sameCnt += 1
  if chgCnt < sameCnt:
    chgCnt = sameCnt
    
print(lenT - chgCnt)

Submission status: Accepted

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

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

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

diff = t_l - max_count
print(diff)

Submission status: Accepted

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

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

print(minc)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 0
if T in S:
    print(ans)
else:
    s = list(S)
    t = list(T)
    ans = 10000
    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 = list(input())
t = list(input())

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


print(ans)

Submission status: Accepted

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

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

answer = 10**3

for s in range(len(S)):
  if s + len(T) <= len(S):
    count = 0
    for t in range(len(T)):
      if S[s+t] != T[t]:
        count += 1
    answer = min(answer, count)
print(answer)

Submission status: Accepted

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

def func():
    z=0
    for i in range(0,len(S)-len(T)+1):
        p=0
        for j in range(0,len(T)):
            if T[j]==S[i+j]:
                p+=1
        if z<p:
            z=p
    return(len(T)-z)

print(func())

Submission status: Accepted

Solution code:
#d,t,s=map(int,input().split())
s=str(input())
t=str(input())
cans=10000
for i in range(len(s)-len(t)+1):
  ans=0
  for j in range(len(t)):
    if s[i]!=t[j]:
      ans+=1
    i+=1
  cans=min(ans,cans)
print(cans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  S = input("")
  T = input("")
  
  length = len(T)
  S_sub_T = len(S) - length

  max_match = 0
  S_offset = 0
  for i in range(S_sub_T+1):
    match = 0
    for j in range(length):
      if(S[i + j] == T[j]):
        match += 1
    if(max_match < match):
      max_match = match
  
  need_replace = length - max_match
  print(need_replace)
 
if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
S = input()
T = input()
list_s = list(S)
list_t = list(T)
A = []
for i in range(len(list_s)-len(list_t)+1):
    t = i
    count = 0
    for j in range(len(list_t)):
        if list_t[j] == list_s[t]:
            t +=1
            count +=1
        else:
            t +=1
    A.append(count)
print(len(list_t) - max(A))

Submission status: Accepted

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

slen = len(s)
tlen = len(t)

now = 0
fg=0

for i in range(slen):
    count=0
    for j in range (tlen):
        if i + j > slen-1:
            fg = 1
            continue
        if (s[i+j]) == t[j]:
            count+=1
    if fg == 1:
        break
    if now < count:
        now = count

print(tlen-now)

Submission status: Accepted

Solution code:
def hamming2(s1, s2):
       """Calculate the Hamming distance between two bit strings"""
       assert len(s1) == len(s2)
       return sum(c1 != c2 for c1, c2 in zip(s1, s2))

   
S = input()
T = input()

len_t = len(T)

min_d = 10000
for i in range(len(S)-len_t+1):
    s = S[i:i+len_t]
    d = hamming2(s, T)
    if d < min_d:
        min_d = d

print(min_d)

Submission status: Accepted

Solution code:
x=input()
y=input()
dist=len(x)
for a in range(len(x)-len(y)+1):
  tmp=0
  for b in range(len(y)):
    if x[b+a]!=y[b]:
      tmp+=1
  if dist>tmp:
    dist=tmp
print(dist)

Submission status: Accepted

Solution code:
from sys import stdin

S = list(stdin.readline().rstrip())
T = list(stdin.readline().rstrip())

result_array = []
count = 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
    result_array.append(len(T)-count)


print(min(result_array))

Submission status: Accepted

Solution code:
def minimumChar(S1, S2): 
    n, m = len(S1), len(S2) 
    ans = len(t) 
    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 
s = list(input())
t = list(input())
print(minimumChar(t,s))

# s = list(input())
# t = list(input())
# ans,i = len(t),0
# while i < len(s):
#     res,k = 0,i
#     if i+len(t) >= len(s):
#         break
#     for j,cc in enumerate(t):
#         if s[k] != t[j]:
#             res += 1
#         k += 1
#     ans = min(ans,res)
#     i += 1
# print(ans)

Submission status: Accepted

Solution code:
import sys
import math

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

if len(S) == len(T):
    ans = len(T)
    change = 0
    for j in range(len(T)):
        if T[j] != S[j]:
            change += 1
    ans = min(ans, change)
else:
    ans = len(T)
    for i in range(len(S) - len(T)):
        change = 0
        for j in range(len(T)):
            # print(f'i {i}, j {j}')
            if T[j] != S[i + j]:
                change += 1
    
        ans = min(ans, change)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
s = np.array(list(input()))
t = np.array(list(input()))
s_sub = np.array(list((s[i:i+len(t)] for i in range(len(s)-len(t)+1))))
ans = [0]*len(s_sub)
for i in range(len(s_sub)):
    ans[i] = np.count_nonzero(s_sub[i] == t)
print(len(t)-max(ans))

Submission status: Accepted

Solution code:
import sys

# 全体
s = input()
s_len = len(s)

# 部分
t = input()
t_len = len(t)

results = []

for start in range(0, s_len - t_len + 1):
    cut = s[start:start + t_len]
    diff_count = 0
    for i in range(0, t_len):
        if cut[i] != t[i]:
            diff_count += 1
    results.append(diff_count)

print(min(results))

Submission status: Accepted

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

    min_change = 1e5
    for i in range(len(S)-len(T)+1):
        tmp_change = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                tmp_change += 1
        min_change = min(min_change, tmp_change)

    if len(S) == len(T):
        min_change = 0
        for i in range(len(T)):
            if S[i] != T[i]:
                min_change += 1

    print(min_change)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin

S = stdin.readline().rstrip().split()[0]
T = stdin.readline().rstrip().split()[0]

count = 0
maxc = 0
for i in range(len(S) - len(T) + 1):
    for j,t in enumerate(T):
        if t == S[i + j]:
            count += 1
    if count >= maxc:
        maxc = count
    count = 0
print(len(T) - maxc)

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    s = input()
    t = input()
    n = len(s)
    m = len(t)
    ans = inf
    for i in range(n - m + 1):
        # s[i:i+m]
        tmp = m
        for j in range(m):
            if t[j] == s[i + j]:
                tmp -= 1
        ans = min(tmp, ans)
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=0

mylist=[]

for i in range(s-t+1):
    for j in range(t):
        if S[i:i+t][j]==T[j]:
            ans=ans+1
    mylist.append(ans)
    ans=0
print(t-max(mylist))

Submission status: Accepted

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

S= list(input().rstrip('\n'))
T= list(input().rstrip('\n'))
result = []
for i in range(len(S)-len(T)+1):
  s = S[i:len(T)+i]
  c = [1 for x in range(len(T)) if s[x]!=T[x]]
  result.append(sum(c))
print(min(result))

Submission status: Accepted

Solution code:
# from math import 

s = input()
t = input()

def distance(s, t):
    assert(len(s) == len(t))
    return len(s) - sum([c1 == c2 for c1, c2 in zip(s, t)])


min_d = len(s)

for i in range(len(s) - len(t) + 1):
    min_d = min(min_d, distance(s[i:i+len(t)], t))

print(min_d)

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())
list1=[]
c=0

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def comp_word(w1, w2, len):
    cnt = len
    for i,w in enumerate(w1):
        if w == w2[i]:
            cnt -= 1
    
    return cnt


def main(S, T):
    T_len = len(T)
    cnt_min = T_len
    for i in range(len(S)-T_len+1):
        sub_S = S[i:i+T_len]
        if len(sub_S) == T_len:
            cnt = comp_word(sub_S, T, T_len)
            if cnt < cnt_min:
                cnt_min = cnt 

    print(cnt_min)


S = input()
T = input()
main(S, T)

Submission status: Accepted

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

cnt = len(S)-len(T)+1
man = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
cou = 0
ans = len(t)
for i in range(len(s)-len(t)+1):
    moji = s[i:i+len(t)]
    #print(moji)
    for j in range(len(t)):
        if t[j] != moji[j]:
            cou += 1
    if ans > cou:
        ans = cou
        if ans == 0:
            break
    cou = 0
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
m = len(t)
for i in range(len(s) - len(t) + 1):
    x = s[i:i+len(t)]
    count = 0
    for a, b in zip(list(t), list(x)):
        if a != b:
            count += 1
    if m > count:
        m = count
print(m)

Submission status: Accepted

Solution code:
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = 0

s = input()
t = input()
l = len(t)
if l == 1:
    if t in s: ans = 0
    else: ans = 1
else:
    mx = 0
    for idx, _ in enumerate(s[:-(l-1)]):
        word = ''
        for i in range(l):
            word += s[idx+i]
        x = 0
        for a, b in zip(word, t):
            if a == b: x += 1
        if x > mx: mx = x

    ans = l - mx

print(ans)

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]:
      tmp += 1
  ans = max(ans, tmp)

print(len(T) - ans)

Submission status: Accepted

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

Slen = len(S)
Tlen = len(T)
diff = Slen - Tlen

maxRes = 0

if diff == 0:
  for j in range(Tlen):
    if S[j] == T[j]:
      maxRes += 1
else: 
  for i in range(diff):
    res = 0
    for j in range(Tlen):
      if S[i + j] == T[j]:
        res += 1
    maxRes = max(maxRes, res)

ans = Tlen - maxRes

print(ans)

Submission status: Accepted

Solution code:
'''
Contest 177 - Task B


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

if __name__ == "__main__":
    haystack = input()
    needle = input()

    dists = []
    for i in range(len(haystack) - len(needle) + 1):
        sub = haystack[i : i+len(needle)]
        dists.append(count_changed_chars(sub, needle))
    print(min(dists))

Submission status: Accepted

Solution code:
import bisect
import sys,io
import math
from collections import deque
from heapq import heappush, heappop

input = sys.stdin.buffer.readline

def sRaw():
    return input().decode("utf-8").rstrip("\n").rstrip("\r")


def iRaw():
    return int(input())


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


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    S= sRaw()
    T =sRaw()
    ans = 10**10
    for sidx in range(0,len(S)-len(T)+1):
        score = sum([1 for idx in range(len(T)) if S[sidx+idx]!=T[idx]])
        ans=min(score,ans)
    print(ans)

main()

Submission status: Accepted

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

s_len = len(S)
t_len = len(T)
R = s_len - t_len
ans = 1000

for i in range(R + 1):
  s_new = S[i : t_len + i]
  count = 0
  for j in range(t_len):
    if s_new[j] != T[j]:
      count += 1
  ans = min(ans, count)

print(ans)

Submission status: Accepted

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

def compare( s, t ):
    count = 0
    for i in range( len( s ) ):
        if s[ i ] != t[ i ]:
            count += 1
    return count

ans = 10 ** 10
for i in range( len( s ) - len( t ) + 1 ):
    ans_i = compare( s[ i : i + len( t ) ], t )
    if ans_i < ans or i == 0:
        ans = ans_i

print( ans )

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)+1):
    ts=s[i:i+len(s)]
    c=0
    for x,y in zip(t,ts):
        if x==y:
            c+=1
    ans.append(c)
print(len(t)-max(ans))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import difflib
S,T = [input() for i in range(2)]
lent=len(T)
lens=len(S)
min=10000
for i in range (0,lens-lent+1):
  now=S[i:i+lent]
  curnum=0
  for j in range(0,lent):
    if now[j]!=T[j]:
      curnum=curnum+1
  if curnum<min:
    min=curnum
print(min)

Submission status: Accepted

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

res = 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
    res = max(res, tmp)

print(len(T) - res)

Submission status: Accepted

Solution code:

def check(s,t):
    count=[]
    if t in s:
        return 0
    else    :
        for i in range(len(s)-len(t)+1):
            count.append(0)
            for j in range(len(t)):
                if not t[j]==s[i+j]:
                    count[i]+=1
    return min(count)
if __name__ == '__main__':
    s = input().rstrip()
    t= input().rstrip()

    print(check(s,t))

Submission status: Accepted

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

Submission status: Accepted

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


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

nux = 0
for i in range(1000):
    count = 0
    if i+nt-1 >= ns:
        break
    for j in range(nt):
        if s[i+j] == t[j]:
            count += 1

    nux = max(nux, count)

print(nt-nux)

Submission status: Accepted

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

def count_letter(A,B):
  score=0
  for i in range(len(A)):
    if A[i]==B[i]:
      score+=1
  return score

count_max=0
for i in range(len(S)-len(T)+1):
  count_max=max(count_max,count_letter(S[i:i+len(T)],T))
print(len(T)-count_max)

Submission status: Accepted

Solution code:
def solve(s, t):
    c = 0
    for i, j in enumerate(s):
        if j != t[i]:
            c += 1
    return c


S = input()
T = input()

count = 0
ans = float("inf")
while count + len(T) <= len(S):
    a = solve(S[count:count + len(T)], T)
    if ans > a:
        ans = a
    count += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    t = input()
    
    ans = 100000
    for i in range(len(s)-len(t)+1):
        tmp = s[i:i+len(t)]
        cnt = 0
        for j in range(len(t)):
            if t[j] != tmp[j]:
                cnt += 1
        ans = min(ans, cnt)
        
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

ans = tl
def check(t, s):
    temp = 0
    for i in range(len(t)):
        if t[i] != s[i]:
            temp += 1
        else:
            pass
    return temp
for i in range(sl-tl+1):
    if ans > check(t,s[i:i+tl]):
        ans = check(t,s[i:i+tl])
    else:
        pass
print(ans)

Submission status: Accepted

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

min_cnt = 9999999999
for i in range(0, len(S) - len(T)+1):
    s = S[i: i + len(T)]
    cnt = 0
    for m, n in zip(s, T):
        if m != n:
            cnt +=1
    min_cnt = min(min_cnt, cnt)

print(min_cnt)

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
a = []

for i in range(len(S)-len(T)+1):
    n = 0
    for j in range(len(T)):
        if S[j+i] == T[j]:
            n += 1
        else:
            continue
    a.append(n)

print(len(T)-max(a))

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 t[j] == s[i+j]:
            cnt += 1
    ans = min(ans,len(t)-cnt)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve(a, b):
	l = len(b)
	maxx = -1
	for i in range(len(a)-l+1):
		val = diff(b, a[i:i+len(b)])
		maxx = max(maxx, val)
	return l - maxx

a = input()
b = input()
print(solve(a, b))

Submission status: Accepted

Solution code:
s = input()
t = input()
x = len(t)
y = len(s) - len(t) + 1
z = 0
for i in range(y):
    a = 0
    for j in range(x):
        if s[i + j] == t[j]:
            a += 1
    z = max(z, a)

print(x - z)

Submission status: Accepted

Solution code:
S = input()
T = input()
L = len(T)
ans = L
for i in range(len(S)-L+1):
    s = S[i:i+L]
    cnt = 0
    for cs, ct in zip(s, T):
        if cs!=ct: cnt+=1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

fans = 100000000
for i in range(len(s) - len(t) + 1):
    ans = 0
    for j in range(len(t)):
        if (s[i+j] == t[j]):
            pass
        else:
            ans += 1
    fans = min(fans, ans)

print(fans)

Submission status: Accepted

Solution code:
import difflib as diff
S=input()
T=input()
diff_count=10001
count=10002
#print(diff.context_diff("aaa","bbb"))

def count_diff2(q, a):
    return sum(
        c1 != c2 for c1, c2 in zip(q, a)
    )

if __name__=="__main__":
    for i in range(len(S)-len(T)+1):
        count=count_diff2(S[i:len(T)+i],T)
        if count <= diff_count:
            diff_count=count

print(diff_count)

Submission status: Accepted

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

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

Submission status: Accepted

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

    len_s = len(s)
    len_t = len(t)

    if len_s == len_t:
        ans = 0
        for i in range(len_s):
            if s[i] != t[i]:
                ans += 1
        print(ans)
    else:
        ans = 1001
        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 cnt < ans:
                ans = cnt
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

x = len(s)
y = len(t)
list1 = []
for i in range(x-y+1):
    z = s[i:i+y]
    count = 0
    for n in range(y):
        if z[n] == t[n]:
            count += 1
    list1.append(count)

saidai = max(list1)

saisyo = y - saidai

print(saisyo)

Submission status: Accepted

Solution code:
s = input()
t = input()
s_list = list(s)
t_list = list(t)
compare = []
score = []

if s == t:
    print(0)
else:
    for i in range(len(s) - len(t) + 1):
        compare.append(s[i : i + len(t)])
    
    for v in compare:
        count = 0
        for v1, v2 in zip(list(v), t_list):
            #print(v1, v2)
            if v1 == v2:
                count += 1
        score.append(count)
    print(len(t) - max(score))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
s= input()
t = input()
ans = []
for j in range(len(s)-len(t)+1):
    cnt = 0
    moji = s[j:j+len(t)]
    for k in range(len(t)):
        if moji[k] != t[k]:
            cnt += 1
    ans.append(cnt)
print(min(ans))

Submission status: Accepted

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

flag=False

m=0

for i in range(len(s)-len(t)+1):
  cnt=0
  for j in range(len(t)):
    #print(s[i+j],t[j])
    if s[i+j]==t[j]:
      cnt+=1
      flag=True
    
  if m==0 or m<cnt:
    m=cnt

print(len(t)-m)

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

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

def cnt(a,b):
    ret = 0
    for i in range(len(a)):
        ret += a[i]!=b[i]
    return ret

ans = 1000
for i in range(sl-tl+1):
    ans = min(ans, cnt(s[i:i+tl], t))
print(ans)