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 = list(input())
T = list(input())
ls = len(S)
lt = len(T)
res = 1000
for i in range(ls - lt + 1):
  temp = 0
  for j in range(lt):
    if S[i+j] != T[j]:
      temp += 1
  if res > temp:
    res = temp
print(res)

Submission status: Accepted

Solution code:
S=str(input())
T=str(input())
if T in S:
    print(0)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
S = input()#文字列を読み込む
T = input()#文字列を読み込む
min0 = len(T)#minの最悪な値


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

print(min0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
l = []
for i in range(len(s)-len(t) + 1):
    cnt = 0
    w = s[i:i+len(t)]
    for d in range(len(t)):
        if t[d] == w[d]:
            cnt += 1
    l.append(cnt)
print(len(t) - max(l))

Submission status: Accepted

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

# len of strs
n = len(s)
m = len(t)
min_ch = m

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

print(min_ch)

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

LS = len(S)
LT = len(T)

Eqnum = 0
for i in range(LS - LT + 1):
    cnt = 0
    for j in range(LT):
        if T[j] == S[i+j]:
            cnt += 1
    if cnt > Eqnum:
        Eqnum = cnt

print(LT - Eqnum)

Submission status: Accepted

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

co = 0
num = 0
N = 0
N_max = 0
for i in range(len(s)-len(t)+1):
    for k in range(len(t)):
        if s[i+k] == t[k]:
            N += 1
    N_max = max(N,N_max)
    N = 0
print(len(t)-N_max)

Submission status: Accepted

Solution code:
s=input()
t=input()
k=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
    if k>q:
        k=q
print(k)

Submission status: Accepted

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

for i in range(len(s)-len(t)+1):
    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:
def resolve():
    S = input()
    T = input()
    Min = 1000
    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
        Min = min(Min, C)
    print(Min)
    
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
import math
import time
import statistics
import math
import itertools
import bisect
import sys
from decimal import *
from collections import deque


def get_int():
    return int(input())

def get_string():
    return input()

def get_int_list():
    return [int(x) for x in input().split()]

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

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

def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# a_list = [0] * a
sys.setrecursionlimit(10 ** 6)

def main():
    start = time.time()

    s = get_string()
    t = get_string()

    ans = 10**5
    for i in range(len(s)-len(t)+1):
        wk = 0
        for ii in range(len(t)):
            if s[i+ii] != t[ii]:
                wk += 1
        ans = min(ans, wk)
    print(ans)



    #print(time.time() - start)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = len(t)

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import math

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

ans = len(T)

for i in range(0,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 = input()
t = input()

ans = len(s)

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

Submission status: Accepted

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

s_l = len(S)
t_l = len(T)

m =100*100
# SとTの長さの差分を取得しSをずらしながら繰り返しを実施
for i in range(s_l - t_l + 1):
  U = S[i:i + t_l]
  c = 0
  for j in range(t_l):
    if (U[j] != T[j]):
      c += 1
  m = min(c, m)

print(m)

Submission status: Accepted

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

max_match = 0
for i in range(len(s) - len(t) + 1):
    match = 0
    for j in range(len(t)):
        if t[j] == s[j + i]:
            match += 1
    if match > max_match:
        max_match = match

print(len(t) - max_match)

Submission status: Accepted

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

num = 10**10

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
same = 0
lt = len(T)
ls = len(S)
for i in range(ls-lt+1):
    tot = 0
    for j in range(lt):
        if T[j] == S[i+j]:
            tot += 1
    same = max(same, tot)
print(lt-same)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(str(input()))
t = list(str(input()))
a = []
for i in range(len(s) - len(t) + 1):
    if i != 0:
        t.insert(0, 0)
    count = 0
    for k in range(len(s)):
        if k < len(t):
            if s[k] != t[k] and t[k] != 0:
                count += 1
    a.append(count)
print(min(a))

Submission status: Accepted

Solution code:
S = input()
T = input()
min = 100000000 # 変更が必要な文字数の最大値
for i in range(len(S)-len(T)+1):
  s = 0 # 何文字変更が必要か
  for j in range(len(T)):
    if S[i+j] != T[j]:
      s = s + 1
  if s < min:
    min = s

print(min)

Submission status: Accepted

Solution code:
def d(s, t): return sum(i != j for i, j in zip(s, t))

s, t = input(), input()
n, m = len(s), len(t)
print(min(d(s[i:i + m], t) for i in range(n - m + 1)))

Submission status: Accepted

Solution code:
def d(s, t):
    cnt = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            cnt += 1
    return cnt


s, t = input(), input()
n = len(s)
m = len(t)
ans = 1000000
print(min(d(s[i:i + m], t) for i in range(n - m + 1)))

Submission status: Accepted

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

ans = len(t)

for i in range(len(s) - (len(t) - 1)):
    cnt = len(t)
    for j in range(len(t)):
        if s[i + j] == t[j]:
            cnt -= 1
    if cnt < ans:
        ans = cnt

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
ans = 10**10
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()
sn = len(s)
t = input()
tn = len(t)
ans = 10000
for i in range(sn-tn+1):
    cou = 0
    for j in range(tn):
        if s[i+j] != t[j]:
            cou += 1
    ans = min(ans,cou)
print(ans)

Submission status: Accepted

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

st = [0] * (len(S) - len(T) + 1)

for i in range(len(S) - len(T) + 1):
  for j,t in enumerate(T):
    st[i] += S[i+j] == t

print(len(T) - max(st))

Submission status: Accepted

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

ans = 1001

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

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

lS = len(S)
lT = len(T)
q = 0

for i in range(0,lS-lT+1):
    p = 0
    for j in range(0, lT):
        if S[i+j] == T[j]:
            p += 1
    q = max(q, p)
ans = lT-q
print(ans)

Submission status: Accepted

Solution code:
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


s = input()
t = input()


ans = math.inf 
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(cnt,ans)
print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
b=list()
for x in range(len(s)-len(t)+1):
    a=0
    for y in range(len(t)):
        #print(s[x+y],t[y],s[x+y]==t[y])
        if s[x+y]==t[y]:
            a+=1
    b.append(a)
print(len(t)-max(b))

Submission status: Accepted

Solution code:
S = input()
T = input()
ns = len(S)
nt = len(T)
idx_start = 0
n_eq_max = 0
for i in range(ns-nt+1):
    n_eq = 0
    for j in range(nt):
        if T[j] == S[i+j]:
            n_eq += 1
    if n_eq_max < n_eq:
        n_eq_max = n_eq
        idx_start = i
print(nt-n_eq_max)

Submission status: Accepted

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

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

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S = input()
T = input()

ans = 1e9
i = 0
while True:
    S2 = S[i:i+len(T)]
    if len(S2) != len(T):
        break
    i += 1

    tmp = 0
    for s, t in zip(S2, T):
        tmp += s != t
    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(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]:
            continue
        count += 1
    ans = min(ans,count)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input();T=input()
N=len(S);NP=len(T);M=len(T)
for i in range(N-M+1):
  cnt=0
  for j in range(M):
    if T[j]==S[j+i]:cnt+=1
  if NP>M-cnt: NP=M-cnt
print(NP)

Submission status: Accepted

Solution code:
s = input()
t = input()
counts = []
for i in range(len(s)):
    count = 0
    if len(s[i:]) < len(t):
        break
    tmp = s[i:]
    for j in range(len(t)):
        if tmp[j] != t[j]:
            count += 1
    counts.append(count)

print(min(counts))

Submission status: Accepted

Solution code:
s=input()
a=len(s)
t=input()
b=len(t)
maxcnt=0
for i in range(a-b+1):
	count=0
	for j in range(b):
		s1=s[i+j]
		s2=t[j]
		if(s1==s2):
			count+=1
	if(maxcnt<count):
		maxcnt=count	
print(b-maxcnt)

Submission status: Accepted

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

li=[]

for i in range(0,len(s)-len(t)+1):
    li.append(s[i:i+len(t)])

maxi=0
for w in li:
    count=0
    for k in range(len(t)):
        if(w[k]==t[k]):
            count+=1
    maxi=max(maxi,count)
print(len(t)-maxi)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8
s = input()
t = input()
ans = len(t)

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

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(len(s)):
    cnt = 0
    if i + len(t) - 1 >= len(s):
        break
    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 = str(input())
T = str(input())
length = len(T)
finish = len(S)-length+1
answer = 0
for i in range(finish):
    wordS = S[i:i+length]
    counter = 0
    for j in range(length):
        if wordS[j] == T[j]:
            counter += 1
    answer = max(answer,counter)
print(length-answer)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = len(T)
for num1 in range(len(S)-len(T)+1):
  temp = len(T)
  for num2 in range(len(T)):
    if S[num1+num2] == T[num2]:
      temp -= 1
  if temp < ans:
    ans = temp
print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = 1000
    for i in range(N-M+1):
        cnt = 0
        for j in range(M):
            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()
s = len(S)
t = len(T)
# Sの何文字目からTが開始されるか 1~ s-t+1
# Tと合致していない数の最小を探索
ans = t
for i in range(s-t+1):
    cnt = 0
    for j in range(t):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)

Submission status: Accepted

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

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:
import difflib

s = input()
t = input()

ans= len(t)

if t in s:
    print(0)
    exit()

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

    ans = min(ans, diff)

print(ans)

Submission status: Accepted

Solution code:
s = input() #efabdd
t = input() #abcd
sl = len(s) #6
tl = len(t) #4
ans = tl #4
for i in range(sl-tl+1): #6-4+1 => 0, 1, 2
    c = 0
    for j in range(min(tl, sl)): #min(4, 6) => 4
        if (s[i+j] != t[j]): #s[0] != t[0]..t[3]
            c += 1
    ans = min(c, ans) #min(0..4, 4)
print(ans)

Submission status: Accepted

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

num_list = []

for i in range(len(S)-len(T)+1):
    num = len(T)
    for j, target in enumerate(S[i:i+len(T)]):
        if target == T[j]:
            num -= 1
    num_list.append(num)
print(min(num_list))

Submission status: Accepted

Solution code:
S=input()
T=input()
cnt=0
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 S_start in range(len(S) - len(T) + 1):
    correct = 0
    for i in range(len(T)):
        if T[i] != S[S_start + i]:
            correct += 1
    ans = min(ans, correct)
    #print(ans)

print(ans)

Submission status: Accepted

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

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

max_ = 0
for i in range(0,(len(S)-len(T))+1):
    max_= max( count(S[i:len(T)+i],T) ,max_ )

print( len(T) - max_ )

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()
n, m = len(s), len(t)

ans = 0
for i in range(n):
    if n < i+m:
        break
    x = s[i:i+m]
    cnt = 0
    for a, b in zip(x, t):
        if a == b:
            cnt += 1
    if ans < cnt:
        ans = cnt

print(m-ans)

Submission status: Accepted

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

Submission status: Accepted

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

s_len = len(S)
t_len = len(T)

answer = 0
for i in range(s_len - t_len + 1):
  count = 0
  for j in range(t_len):
    if S[i+j] == T[j]:
      count += 1
  answer = max(answer, count)

print(str(t_len - answer))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
n,m = len(s),len(t)

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

Submission status: Accepted

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

num_s = len(s)
num_t = len(t)
ans = len(t)

# Tの各位置において、Sの文字数のうち何個一致しているのか、全数チェック。
# > O(T*S)＞　10**6オーダー

for i in range(num_s):
    end = i + num_t
    if (end > num_s):
        break
    tar_s = s[i:end]
    # print(tar_s)

    count = 0
    for a, b in zip(tar_s, t):
        if (a != b):
            #print('add', a)
            count += 1

    ans = min(ans, count)


print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
len_s = len(s)
len_t = len(t)
minimum = len_t

for i in range(len_s - len_t + 1):
  replace = 0
  for j in range(len_t):
    if s[i + j] != t[j]:
      replace += 1
  if replace < minimum:
    minimum = replace

print(minimum)

Submission status: Accepted

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

ans=float("inf")
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:
# ABC177
# B Substring
# 文字列sの中に文字列tを作る時、何回修正が必要か？
# 全探索で文字列sを文字列t文字づつ抜き出して
# 一番、不一致文字数が少ないのが答え
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 10000

# ls-lt+1文字列tのlt文字に、後ろが足りないのは探索しない
for i in range(ls - lt + 1):
    score = 0
    U = s[i:i + lt]  # チェック用文字列Uはs[i]からs[i+lt]までの文字列
    for j in range(lt):  # lt文字数分チェックする
        # U文字列とT文字列を1文字目から全文字不一致かチェック
        if U[j] != t[j]:
            score += 1  # 不一致なら1を足す（最後は不一致な文字数がscoreになる）
    ans = min(ans, score)  # ansとscoreの小さい方を返す

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
lt = len(t)
ls = len(s)
A = []
for i in range(ls-lt+1):
    cou = 0
    for j in range(lt):
        if s[i+j] == t[j]:
            cou += 1
    A.append(cou)
print(lt-max(A))

Submission status: Accepted

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

Submission status: Accepted

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

width = len(T)
predict_word = []
for s_index in range(len(S)):
    if(len(S) < s_index + width):
        break
    predict_word.append(S[s_index:s_index+width])


count_list, ans = [], []
for p_word in predict_word:
    tmp = []
    for count, word in enumerate(p_word):
        if(T[count] == word):
            tmp.append(word)
    count_list.append(tmp)

for count in count_list:
    ans.append(len(count))

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

Submission status: Accepted

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

ans = float("inf")
flag = False
for i in range(len(s)):
    curr = 0
    for j in range(len(t)):
        if i + j >= len(s):
            flag = True
            break
        if t[j] != s[i + j]:
            curr += 1
    if flag:
        break
    ans = min(ans, curr)
print(ans)

Submission status: Accepted

Solution code:
def matcher(s1,s2):
    match=0
    for i in range(len(s1)):
        if(s1[i]!=s2[i]):
            match+=1
            
    return match

#print(matcher("eforces","atcoder"))

s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Submission status: Accepted

Solution code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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:
s=str(input())
t=str(input())
a=len(s)
b=len(t)
c=a-b
list=[]
for i in range(c+1):
  ans=0
  for j in range(b):
    if s[i+j]==t[j]:
      ans+=1
  list.append(ans)
  ans=0

print(b-max(list))

Submission status: Accepted

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

ans = len(t)

for start in range(len(s) - len(t) + 1):
    diff = 0
    for i in range(len(t)):
        if t[i] != s[start + i]:
            diff += 1

    ans = min(ans, diff)

print(ans)

Submission status: Accepted

Solution code:
a = input()
b = input()
mn = len(b)
for i in range((len(a) - len(b)) + 1):
    c = a[i:i+len(b)]
    count = 0
    for j in range(len(b)):
        if c[j] != b[j]:
            count += 1
    if mn > count:
        mn = count
print(mn)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    count = max = 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 < count :
            max = count
    print(len(t) - max)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
lt = len(t)
ls = len(s)
ans = ls

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

mini = 10**9
for i in range(len(S)-len(T)+1):
    cnt = 0
    for ti in range(len(T)):
        cnt += 1 if S[i+ti] != T[ti] else 0
    mini = min(mini,cnt)
print(mini)

Submission status: Accepted

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

sl = len(s)
tl = len(t)
diff = tl
for i in range(sl-tl+1):
    curr = 0
    for j in range(tl):
        if s[i+j] != t[j]:
            curr += 1
    diff = min(diff, curr)
print(diff)

Submission status: Accepted

Solution code:
S = input()
T = input()
l = len(T)
min = l
max = 0
count = len(S) - l + 1
i = 0
while (i < count):
    c = 0
    for j in range(l):
        if S[i + j] == T[j]:
            c += 1
    if max < c:
        max = c
        min = l - max
    i += 1
print(min)

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,diff)

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
mic = len(T)
if T in S:
  print(0)
else:
  for i in range(len(S)-len(T)+1):
    counter = 0
    for l in range(len(T)):
      if T[l] != S[i+l]:
        counter+=1
    mic = min(mic,counter)
  print(mic)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b = input(), input()
res = len(b)
for i in range(len(a) - len(b) + 1):
  aa = a[i:len(b)+i]
  cnt = 0
  for x, y in zip(aa, b):
    if x != y:
      cnt += 1
  res = min(res, cnt)
print(res)

Submission status: Accepted

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

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

print(len(T) - max(counts))

Submission status: Accepted

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

Submission status: Accepted

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


def read():
    S = input().strip()
    T = input().strip()
    return S, T


def solve(S, T):
    mincost = 1000000
    for i in range(len(S)-len(T)+1):
        j = i + len(T)
        cost = 0
        for s, t in zip(S[i:j], T):
            if s != t:
                cost += 1
        mincost = min(mincost, cost)
    return mincost


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

Solution code:

S = input()
T = input()

def count_diff(Sp):
    cnt = 0
    for i in range(len(Sp)):
        if T[i] != Sp[i]:
            cnt += 1
    return cnt

saved_cnt = len(T)

for i in range(len(S) - len(T) + 1):

    Sp = S[i:i+len(T)]
    
    cnt = count_diff(Sp)
    
    saved_cnt = min(saved_cnt, cnt)
        
print(saved_cnt)

Submission status: Accepted

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

Submission status: Accepted

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

ans = len(T)
for s in range(len(S)-len(T)+1):
    # SとTの違いをスライドさせながら計算する
    diff = 0
    # Tを一文字目から順番に照らし合わせていく
    for t in range(len(T)):
        if T[t] != S[s+t]:
            diff += 1
    ans = min(diff,ans)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s)
m = len(t)
ans = 1000

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = input()
ans = 20000000
for i in range(len(s)):
  x = s[i:i+len(n)]
  con = 0
  if len(x) < len(n):
    break
  else:
    for y in range(len(n)):
      if x[y] != n[y]:
        con += 1
    ans = min(ans, con)
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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