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,t=open(0)
print(min(sum(a!=b for a,b in zip(s[i:-1],t[:-1]))for i in range(len(s)-len(t)+1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = input()
T = input()
s = len(S)
t = len(T)
#A=[0]*(len(S))
 
ans = t
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 = min(ans, x)
 
#print(s)
#print(t)
#print(A)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
#A=[0]*(len(S))
 
ans = float('inf')
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 = min(ans, x)

print(ans)

Submission status: Accepted

Solution code:
#input = sys.stdin.readline
 
S = input()
T = input()
 
result = float('inf')
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
    result = min(result, t)
print(result)

Submission status: Accepted

Solution code:
from collections import deque
import sys, copy, itertools,heapq
#input = sys.stdin.readline
 
S = input()
T = input()
 
result = float('inf')
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
    result = min(result, t)
print(result)

Submission status: Accepted

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

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 パターンあります

for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Submission status: Accepted

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

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

c=[]

for i in range(sl-tl+1):
    cnt=0
    for j in range(tl):
        if s[i+j]==t[j]:
            cnt+=1
    c.append(cnt)
    cnt=0

print(tl-max(c))

Submission status: Accepted

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

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

A = []

for i in range(len_s - len_t + 1):
    total = 0
    for j in range(len_t):
        if t[j] != s[i + j]:
            total += 1
    A.append(total)

print(min(A))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

min_ = 1000
for i in range(len(S) - len_T + 1):
  s = S[i:i+len_T]
  cnt = 0
  for j in range(len_T):
    if s[j] != T[j]: cnt += 1
  min_ = min(min_, cnt)
print(min_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
list1 = list()
y = list()
for i in range(len(s)):
    if i < (len(s)-len(t)+1):
        list1.append(s[i:(i+len(t))])
for j in range(len(list1)):
    count = 0
    for k in range(len(t)):
        if list1[j][k] != t[k]:
            count = count + 1
    y.append(count)
print(min(y))

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 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
    ans = min(ans, c)
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
import sys


def dump(x):
    print(x, file=sys.stderr)


s = input()
t = input()

min_diff = 100000000000


for i in range(len(s)-len(t)+1):
    matches = [1 if s[i+j] != t[j] else 0 for j in range(len(t))]
    diffn = sum(matches)
    min_diff = min(diffn,min_diff)
    dump(min_diff)

print(min_diff)

Submission status: Accepted

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

t_l = len(t)
diff_min = 999999999

def diff_str(s1, s2):
    diff_c = 0
    for j in range(len(s1)):
        if s1[j] != s2[j]:
            diff_c += 1
    return diff_c

if len(s) == len(t):
    diff_min = diff_str(s, t)

for i in range(len(s)-t_l):
    seq=s[i:i+t_l]
    diff_c = diff_str(seq, t)
    if diff_c < diff_min:
        diff_min = diff_c


print(diff_min)

Submission status: Accepted

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

# ans = []
# for i in range(len(t)):
#     # print(t[i:])
#     # print(s[i:])
#     if t[i:] in s[i:]:
#         break
#     for j in range(1,len(t[i:])):
#         # print(t[i:][:-j])
#         # print(s[i:][:-j])
#         if t[i:][:-j] in s[i:][:-j]:
#             ans.append(i+j)
#             break
# if t in s:
#     print(0)
# elif len(ans) == 0:
#     print(len(t))
# else:
#     print(min(ans))
ans = len(t)
for i in range(len(s)-len(t)+1):
    dif = 0
    for j in range(len(t)):
        if t[j] != s[i:i+len(t)][j]:
            dif += 1
    ans = min(dif,ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result = 10000
for i in range(len(S) - len(T) + 1):
  # print(i)
  start = i
  count = 0
  for j in range(len(T)):
    if T[j] != S[i + j]:
      count += 1
  result = min(count, result)

print(result)

Submission status: Accepted

Solution code:
s=input()
t=input()
ls=len(s);lt=len(t)
ans=10000
for i in range(ls-lt+1):##
    ss=list(s[i:i+lt])
    tt=list(t)
    
    tmp=[tt[j] for j in range(lt) if tt[j]!=ss[j]]
    ans=min(ans,len(tmp))
print(ans)

Submission status: Accepted

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

for i in range(len(a)-len(b)+1):
  d=0
  for j in range(len(b)):
    if a[i+j]!=b[j]:
      d+=1
  if d<c:
    c=d
print(c)

Submission status: Accepted

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

if(t in s):
    print(0)

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

Submission status: Accepted

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

l = [len(T)] * (len(S) - len(T) + 1)
for i in range(len(S) - len(T) + 1):
    split_str = S[i:len(T) + i]
    ck = [int(1) for i in range(len(T))]
    for j in range(len(T)):
        if T[j] == split_str[j]:
            ck[j] = 0

    l[i] = sum(ck)
print(min(l))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#模範解答 tの文字列の数に絞って全探索を掛ける
S = input()
T = input()

N = len(T)

s_list = []
for i in range(len(S) - N + 1):
    s = S[i: i + N]
    s_list.append(s)

answer = N
for s in s_list:
    counter = 0
    for i in range(N):
        if s[i] != T[i]:
            counter += 1

    answer = min(answer, counter)

print(answer)

Submission status: Accepted

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

    ans = float('inf')
    for i in range(0, len(s) - len(t) + 1):
        diff_sum = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                diff_sum += 1
        if ans > diff_sum:
            ans = diff_sum

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


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

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

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

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

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

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


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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    S = rl().rstrip()
    T = rl().rstrip()
    
    ans = 1001
    for i in range(len(S) - len(T) + 1):
        cnt = len(T)
        for j in range(len(T)):
            cnt -= S[i + j] == T[j]
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

s=input()
t=input()
sl=len(s)
tl=len(t)
ans=10**18
for i in range(sl-tl+1):
    tmp=s[i:i+tl]
    cnt=0
    for j in range(tl):
        if tmp[j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)

Submission status: Accepted

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

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

sone = ''

small = 0

if slen != tlen:
    for i in range(slen-tlen):
        sone = s[i:i+tlen]
        count = 0
        for e in range(tlen):
            if sone[e] != t[e]:
                count = count + 1
        if i == 0:
            small = count
        else:
            if count <= small:
                small = count
else:
    sone = s
    count = 0
    for e in range(tlen):
        if sone[e] != t[e]:
            count = count + 1
    small = count

print(small)

Submission status: Accepted

Solution code:
S = input()
T = input()
match = 0
ans = 0
 
for n in range(len(S)-len(T)+1):
  match2 = 0
  U = S[n:n+len(T)]
  for m in range(len(T)):
    if U[m]==T[m]:
      match2+=1
  match = max(match,match2)
      
print(len(T)-match)

Submission status: Accepted

Solution code:
from typing import List
import sys


def solution(inp: List) -> int:
    S = inp[0]
    T = inp[1]
    ans = len(T)

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


inp: List = []
for j in sys.stdin:
    inp += j.split()
print(solution(inp))

Submission status: Accepted

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

d = 0
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
    d = max(c,d)
print(len(t)-d)

Submission status: Accepted

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

d = 10000
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
    d = min(c,d)
print(d)

Submission status: Accepted

Solution code:
from functools import reduce
s, t = input(), input()
ans = 10**9
for i in range(0, len(s) - len(t)+1):
    ans = min(ans, reduce(lambda x, a: x + (1 if a[0] != a[1] else 0), zip(s[i:], t), 0))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

l=[]
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
        else:
            pass
    l.append(cnt)
print(len(t)-max(l))

Submission status: Accepted

Solution code:
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
S =input().strip()
T =input().strip()
match =[]

for s_start in range(len(S)):
    S2 =S[s_start:]
    a=0
    if len(S2) < len(T):
        break
    for t in range(len(T)):
        if S2[t] ==T[t]:
            a +=1
    match.append(a)
ans =len(T) -max(match)
print(ans)

Submission status: Accepted

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

for n in range(len(S)-len(T)+1):
  match2 = 0
  U = S[n:n+len(T)]
  for m in range(len(T)):
    if U[m]==T[m]:
      match2+=1
  match = max(match,match2)
      
print(len(T)-match)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(T)
ans = float('inf')
for i in range(len(S) - N + 1):
    a = 0
    for s, t in zip(S[i:], T):
        if s != t:
            a += 1
    ans = min(ans, a)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
minCount = len(t)
i = 0
while i < len(s) and i + len(t) <= len(s):
    countSame = 0
    j = 0
    while j < len(t):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)

Submission status: Accepted

Solution code:
def main():
  s=input()
  t=input()
  ls=len(s)
  lt=len(t)
  r=0
  if ls==lt:
    for i in range(ls):
      if s[i]==t[i]:
        r+=1
    print(lt-r)
    exit()
  st= [ [ 0 for y in range(ls ) ] for x in range( lt ) ]
  for si in range(ls):
    for ti in range(lt):
      if s[si]==t[ti]:
        st[ti][si]=1
  r=0
  for si in range(ls-lt):
    rt=0
    for ti in range(lt):
      rt+=st[ti][(si+ti)]
    if r<rt:
      r=rt
  print(lt-r)
main()

Submission status: Accepted

Solution code:
S = input()
T = 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:
import sys
def minimumChar(T,S): 
    n, m = len(T), len(S) 
    ans = sys.maxsize 
    for i in range(m - n + 1): 
        minRemovedChar = 0
        for j in range(n): 
            if (T[j] != S[i + j]): 
                minRemovedChar += 1
        ans = min(minRemovedChar, ans) 
    return ans 
      
S=input()
T=input()

print(minimumChar(T,S))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if t != s:
            print(1)
            sys.exit()
    lens = len(s)
    lent = len(t)
    res = set()
    for i1 in range(lens - lent + 1):
        tmp1 = sum([c1 == c2 for c1, c2 in zip(t, s[i1:i1+lent])])
        res.add(lent - tmp1)
        #print(s[i1:i1+lent], res)
    if res:
        r = min(res)
        print(r)
    else:
        print(lent)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s)
m=len(t)
ans=100000000
for i in range(n-m+1):
    tmp=0
    for x,y in zip(t,s[i:i+m]):
        if x!=y:
            tmp+=1
    ans=min(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
n = len(T)
ans = N
for i in range(N-n+1):
    s = S[i:i+n]
    temp = 0
    for ss, t in zip(s, T):
        temp += ss != t
    ans = min(ans, temp)

print(ans)

Submission status: Accepted

Solution code:
def minChange(S, T):
    m, n = len(S), len(T)
    
    min_change = n
    
    # check each character in the larger string
    for i in range(0, m - n + 1):
        total_diff = 0
        # with this substring
        for j in range(0, n):
            # count the differences
            if T[j] != S[i+j]:
                total_diff += 1
        # update the global minimum value
        min_change = min(min_change, total_diff)
    
    return min_change    

S = str(input())
T = str(input())
print(minChange(S, T))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import sys

def main():
    # input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)-len(t)+1):
        diff = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

min_count = len(T)
for s in range(len(S) - len(T) + 1):  # T cannot exceed the length of S
    matched = 0
    for i in range(len(T)):
        # print(f'S[{s + i}] == T[{i}]')
        if S[s + i] == T[i]:
            matched += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

Submission status: Accepted

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

Submission status: Accepted

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

N = len(T)

s_list = []
for i in range(len(S) - N + 1):
    s = S[i:i + N]
    s_list.append(s)
    
answer = N
for s in s_list:
    counter = 0
    for i in range(N):
        if s[i] != T[i]:
            counter += 1
    answer = min(answer, counter)

print(answer)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
n=len(t)
val=0
for i in range(len(s)-n+1):
    temp=0
    for j in range(n):
        if s[i+j]==t[j]:
            temp+=1
    val=max(val,temp)
    if val==n:
        break
print(n-val)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = []
for i in range(len(s) - len(t) + 1):
    cnt1 = 0
    for k in range(len(t)):
        if t[k] == s[i: i + len(t)][k]:
            cnt1 += 1
            cnt.append(cnt1)
            #print(t[i:k], s[i:], k-i)
        else:
            cnt.append(0)
            #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
S = input()
T = input()

a = 0
ans = len(T)

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

print(ans)

Submission status: Accepted

Solution code:
INF = 10 ** 19
s = list(input())
t = list(input())
N = len(s)
M = len(t)

def check(s,t):
    res = 0
    for i in range(M):
        if s[i] != t[i]:
            res += 1
    return res

ans = INF
for i in range(N-M+1):
    ans = min(ans, check(s[i:i+M], t))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

S_list = list(S)
T_list = list(T)

con = 0
for i in range(len(S_list)-len(T_list) + 1):
  count = 0
  for j in range(len(T_list)):
    if S_list[i + j] == T_list[j]:
      count +=1
  if count > con:
    con = count

ans = len(T_list) - con
print(ans)

Submission status: Accepted

Solution code:
S =input()
T = input()
a = len(S)
x = len(T)
ans = 0
sum_l = []
if a == x:
  for i in range(a):
    if S[i] != T[i]:
      ans += 1
  print(ans)
else:
  for i in range(a-x+1):
    for j in range(x):
      if S[i+j] != T[j]:
        ans += 1
    sum_l.append(ans)
    ans = 0
  print(min(sum_l))

Submission status: Accepted

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

cnt = []
for i in range(len(s) - len(t) + 1):
    cnt1 = 0
    for k in range(len(t)):
        if t[k] == s[i: i + len(t)][k]:
            cnt1 += 1
            cnt.append(cnt1)
            #print(t[i:k], s[i:], k-i)
    else:
        cnt.append(0)
            #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S,T=open(0).read().split()
score = 0
for i in range(len(S)-len(T)+1):
    score=max(score,sum([T[k]==S[i+k] for k in range(len(T))]))
print(len(T)-score)

Submission status: Accepted

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

Submission status: Accepted

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

count = len(t)

for i in range(len(s) - len(t) + 1):
    str_ = s[i:i + len(t)]
    temp = 0
    for i in range(len(str_)):
        #print(str_[i])
        if str_[i] != t[i]:
            temp += 1
    count = min(count, temp)    
        
print(count)

Submission status: Accepted

Solution code:
import sys
s = list(input())
t = list(input())
ans = float('inf')

for i in range(len(s)):
    count = 0
    for j in range(len(t)):
        if i + j >= len(s):
            print(ans)
            sys.exit()

        if s[i+j] != t[j]:
            count += 1
    ans = min(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):
  c = 0
  for j in range(len(T)):
    if T[j] != S[i+j] :
      c = c + 1
  ans = min(ans, c)

print(ans)

Submission status: Accepted

Solution code:
a = input()
b = input()
c = int(len(a))
d = int(len(b))
e = c-d+1
ans = int(0)
temp = int(0)
for i in range(e):
  temp = 0
  for j in range(d):
    if a[j+i] == b[j]:
      temp += 1
  if ans < temp:
    ans = temp

print(d-ans)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    len_s = len(s)
    len_t = len(t)
    ans = 10 ** 12

    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
n, m = len(s), len(t)
print(min(sum(si != ti for si, ti in zip(s[i: i+m], t)) for i in range(n-m+1)))

Submission status: Accepted

Solution code:
S = input()
T = input()
MIS = len(S)
for TS in range(0,len(S)-len(T)+1):
    LS = S[TS:TS+len(T)]
    Count = sum(True if LS[TT]!=T[TT] else False for TT in range(0,len(T)))
    MIS = min(MIS,Count)
print(MIS)

Submission status: Accepted

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

res = 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
  res = max(cnt, res)
  
print(len(t)-res)

Submission status: Accepted

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

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    S = input()
    T = input()

    return S, T


def main(S: str, T: str) -> None:
    """
    メイン処理.

    Args:\n
        S (str): 文字列(1 <= |S| <= 1000)
        T (str): 文字列(1 <= |T| <= |S|)
    """
    # 求解処理
    ans = len(T)
    for i in range(len(S) - len(T) + 1):
        diff = 0
        for j in range(len(T)):
            if T[j] != S[i + j]:
                diff += 1
        ans = min(ans, diff)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    S, T = get_input()

    # メイン処理
    main(S, T)

Submission status: Accepted

Solution code:
S, T = input(), input();print(min([sum([0 if x == y else 1 for x, y in zip(S[i:], T)]) for i in range(len(S) - len(T) + 1)]))

Submission status: Accepted

Solution code:
s = input()
t = input()
a = set()
for i in range(len(s) - len(t) + 1):
  u = s[i: i + len(t)]
  k = len(t)
  for j in range(len(t)):
    if u[j] == t[j]:
      k -= 1
  a.add(k)
ans = min(list(a))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys

# 標準入力を取得
S = input()
T = input()

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

# 結果出力
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
tmp = 0
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
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
x = [input() for i in range(2)]
S = x[0]
T = x[1]
moji = len(T)

for a in range(len(S) - len(T) + 1):
  count = 0
  for b in range(len(T)):
    
    if S[a+b] != T[b]:
      count += 1
  if count < moji:
    moji = count

print(moji)

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
x=[1000]*(len(S)+1)
for i in range(len(S)-len(T)+1):
    p=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            p+=1
    x[i]=p
print(min(x))

Submission status: Accepted

Solution code:
S, T = input(), input()
print(min([sum([0 if x == y else 1 for x, y in zip(S[i:i + len(T)], T)]) for i in range(len(S) - len(T) + 1)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
s=input()
t=input()
if(len(s)==len(t)):
    ans=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans+=1
    print(ans)
else:
    ans=1e9
    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:
s = list(input())
t = list(input())
tmp = 0
ans = len(t)
# j_tmp = 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
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))


def main():
    S = rs()
    T = rs()
    ls = len(S)
    lt = len(T)
    print(min([sum([0 if x == y else 1 for x, y in zip(S[i:i + lt], T)]) for i in range(ls - lt + 1)]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

ans = nt

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

Submission status: Accepted

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

ans = len(s)

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

Submission status: Accepted

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

ma=0
mamax=0

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

Submission status: Accepted

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

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

print(ans)