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

result = float("inf")
count = len(S) - len(T) + 1

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

import math
import re
import numpy as np
import copy

#読み込む
S = input()
T = input()

ans = len(S)

#高々(10^3)^2
for i in range(len(S) - len(T)):
    #何文字違うかをチェック
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[i+j]:
            cnt += 1

    if cnt < ans:
        ans = cnt

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

    ans = cnt

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=str(input())
T=str(input())
ls=len(S)
lt=len(T)
m=0
for i in range(ls-lt+1):
  A=S[i:i+lt]
  a=0
  for s,t in zip(A,T):
    if s==t:
      a+=1
  m=max(m,a)
print(lt-m)

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = [_ for _ in input()]
t = [_ for _ in input()]

ans = 10**10

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

Submission status: Accepted

Solution code:
A=list(input())
B=list(input())
lengthA=len(A)
lengthB=len(B)
maxi=[]
for i in range(lengthA-lengthB+1):
	counter=0
	C=A[i:lengthB+i]
	for j in range(lengthB):
		if C[j]==B[j]:
			counter+=1
	maxi.append(lengthB-counter)
print(min(maxi))

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 100000
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

s = X()
t = X()

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

print(cnt)

Submission status: Accepted

Solution code:
#S, T = map(int, input().split())
S = input()
T = input()

myans = float('INF')
for s in range(len(S) - len(T)+1 ):
    mycnt = 0
    for t in range(len(T)):
        #print(S[s+t], T[t])
        if S[s+t] != T[t]:
            mycnt += 1
    if mycnt < myans:
        myans = mycnt
print(myans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = []
for i in range(len(S)-len(T)+1):
  ans.append(S[i:len(T)+i])
s = []

for i in ans:
  count = 0
  for k in range(len(T)):
    if i[k]==T[k]:
      count+=1
  s.append(count)
  
print(len(T)-max(s))

Submission status: Accepted

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

ls = len(s)
lt = len(t)
max = 0
for i in range(ls-lt+1):
  k = 0
  for j in range(i,i+lt):
    if s[j] == t[j-i]:
      k += 1
  if max < k:
    max = k
    
print(lt-max)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

s = input()
t = input()

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

print(min(ans))

Submission status: Accepted

Solution code:
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

dx=[-1,1,0,0]
dy=[0,0,1,-1]


sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")


def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    s=input()
    t=input()
    ans=float('inf')
    i=0
    while i<len(s)-len(t)+1:
        x=0
        c=0
        j=i
        
        while x<len(t):
            
            if t[x]!=s[i+x]:
                c+=1
            j+=1
            x+=1
        
        ans=min(ans,c)
        i+=1
    print(ans)
        


for _ in range(1):
    solve()

Submission status: Accepted

Solution code:
s = input().rstrip()
t = input().rstrip()
ns = len(s)
nt = len(t)
ans = ns
for i in range(ns-nt+1):
    tmp = s[i:i+nt]
    n=0
    for j in range(nt):
         if tmp[j]!=t[j]:
                n+=1
    if ans>n:
        ans=n
print(ans)

Submission status: Accepted

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

mi = 100000
l_s = len(s)
l_t = len(t)

for i in range(l_s-l_t+1):
    sub = s[i:i+l_t]
    d = 0
    for j in range(l_t):
        if sub[j] is not t[j]:
            d += 1
    if d < mi:
        mi = d

print(mi)

Submission status: Accepted

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

Submission status: Accepted

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

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:
import numpy as np
S = np.array(list(input()))
T = np.array(list(input()))

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

# 一番重なりが多い部分を探す
max_kasanari = np.sum(S[:lenT] == T)  # Sの最初lenT文字と、Tの重なっている部分
for i in  range(lenS - lenT + 1):
    kasanari = np.sum(S[i:lenT+i] == T)
    if max_kasanari < kasanari:
        max_kasanari = kasanari

print(lenT - max_kasanari)

Submission status: Accepted

Solution code:
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input()
    T = input()
    min_count = math.inf
    for start in range(len(S)-len(T)+1):
        end = start+len(T)
        count = sum(c0 != c1 for c0, c1 in zip(S[start:end], T))
        min_count = min(min_count, count)
    return min_count


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

Submission status: Accepted

Solution code:
def dif (s,t):
    ans=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans+=1
    return ans
s=input()
t=input()
k=len(t)
ans=99999999999999999
for i in range(len(s)-k+1):
    a=s[i:i+k]
    b=dif(a,t)
    ans=min(ans,b)
print (ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 100000000
for i in range(len(S) - len(T)+1):
    val = 0
    #print(i)
    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:
Y = input().strip()
X = input()
X_len = len(X)
ss = 100000
for i in range(len(Y) - X_len + 1):
    s = 0
    for j in range(X_len):
        if Y[i + j] != X[j]:
            s += 1
    ss = min(ss, s)
print(ss)

Submission status: Accepted

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

ans = lent
cnt = 0

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(t)
ans = []
def f(i):
  sum = 0
  for ch1, ch2 in zip(s[i: i+n], t):
    if ch1 != ch2:
      sum += 1
  return sum
for i in range(len(s)-n+1):
  ans.append(f(i))

print(min(ans))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:


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

Submission status: Accepted

Solution code:
#abc177 b
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 T[j] != S[i+j]:
            cnt +=1
    ans = min(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
S, T = input(), input()
def different(A, B):
    res = 0
    for a, b in zip(A, B):
        if a != b:
            res += 1
    return res

lenS = len(S)
lenT = len(T)
Change = [different(S[i:i+lenT], T) for i in range(lenS-lenT+1)]
print(min(Change))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

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

max_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

        
    max_cnt = max(cnt, max_cnt)

print(len(T) - max_cnt)

Submission status: Accepted

Solution code:
s= input()
t =  input()
n =  len(s)
n1 = len(t)
ans= 100000
for i in range(n-n1+1):
    count= 0
    for j in range(n1):
        #print(i,j,n,n1)
        if s[i+j]==t[j]:
            continue
        else:
            count+=1
    #print(count)
    ans = min(ans,count)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = float('inf')
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:
S = input()
SS = list(S)
T = input()
TT = list(T)
X = len(SS) -len(TT)
mini = 1000
for i in range(X+1):
  count = 0
  for j in range(len(TT)):
    if SS[j + i] != TT[j]:
      count +=1
  if count < mini:
    mini = count
print(mini)

Submission status: Accepted

Solution code:
# 入力
S = str(input())
T = str(input())

ans = len(T)

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

print(ans)

Submission status: Accepted

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

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

for iis in range(0,slen-tlen+1):
  diff=0
  for iit in range(0,tlen):
    if (s[iis+iit] != t[iit]):
      diff+=1
  diffmin=min(diffmin, diff)
print(diffmin)

Submission status: Accepted

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

Tn = len(T)
best = 0
for s in range(len(S)-len(T)+1):
    count = 0
    for t in range(Tn):
        if S[s+t] == T[t]:
            count += 1
    if count > best:
        best = count

print(Tn-best)

Submission status: Accepted

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

ans = 9999

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

lens = len(s)
lent = len(t)
cnt_min = 10**5
for i in range(lens-lent+1):
  tmp = 0
  for j in range(lent):
    if s[i+j] != t[j]:
      tmp += 1
  if tmp < cnt_min:
    cnt_min = tmp
    
print(cnt_min)

Submission status: Accepted

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

ans = 10**9

for i in range(len(S)-len(T)+1):
    Spart = S[i:i+len(T)]
    #print(Spart)
    temp_ans = 0
    
    for j in range(len(T)):
        #print(Spart[j],T[j])
        if Spart[j] != T[j]:
            temp_ans += 1
            
    if temp_ans < ans:
        ans = temp_ans
        
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

s=input().rstrip()
t=input().rstrip()

ans=10**10

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

Submission status: Accepted

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    S, T = sys.stdin.read().split()

    ls, lt = len(S), len(T)
    ans = lt
    for i in range(ls - lt+1):
        x = 0
        for j in range(lt):
            if S[i+j] == T[j]:
                continue
            x += 1
            if x > ans:
                break
        else:
            if x < ans:
                ans = x

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

dismatch = []
for sx in range(len(s)-len(t)+1):
    tmp = 0
    for tx in range(len(t)):
        if s[sx+tx] != t[tx]:
            tmp += 1
    dismatch.append(tmp)
print(min(dismatch))

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
S = list(input())
T = list(input())


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


i = 0
len_t = len(T)
ans = 10**10
while i+len_t <= len(S):
    s_bubun = S[i:i+len_t]
    kouho = count_diff(s_bubun, T)
    ans = min(kouho, ans)
    i += 1

print(ans) if ans != 10**10 else print(0)

Submission status: Accepted

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

def num_replace(string, sub, shift):
    ans = 0
    for i in range(len(sub)):
        if string[i + shift] != sub[i]:
            ans += 1
    return ans
#print(num_replace(s, t, 0))

min_num = float("inf")
for shift in range(0, len(s) - len(t) + 1):
    min_num = min(min_num, num_replace(s, t, shift))
print(min_num)

Submission status: Accepted

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


min_diff = 10000
window = len(T)
for i in range(0, len(S) - window + 1):
    x = S[i: i+window]
    count = 0
    for a, b in zip(T, x):
        if a != b:
            count += 1
    min_diff = min(count, min_diff)
print(min_diff)

Submission status: Accepted

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

Submission status: Accepted

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

counters = []
for i in range(len(s) - len(t) + 1):
  part_of_s = s[i: i + len(t)]
  counter = 0
  for sss, ttt in zip(part_of_s, t):
    if sss != ttt:
      counter += 1
  counters.append(counter)
print(min(counters))

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    t = list(input())
    lt = len(t)
    ls = len(s)
    ans = 1000
    
    
    def dis(a, b):
        d = 0
        for ai, bi in zip(a, b):
            if ai == bi:
                continue
            d += 1
        return d
    
    for i in range(ls-lt+1):
        ans = min(ans, dis(s[i:i+lt], t))
    
    print(ans)
        
    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

tl = len(T)

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

print(tl-ans)

Submission status: Accepted

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

len_diff = len(S) - len(T)

min_diff = len(S)

for i in range(len_diff + 1):
    s = S[i:i+len(T)]
    diff = 0
    for j in range(len(T)):
        if s[j] != T[j]:
            diff += 1
    min_diff = min(min_diff, diff)
    
print(min_diff)

Submission status: Accepted

Solution code:
a,b = open(0).read().split()
na = len(a)
nb = len(b)

ans = float('inf')
for i in range(na-nb+1):
#     print(a[i:i+nb])
    tmp = nb
    for j in range(nb):
        if a[i+j] == b[j]:
            tmp -= 1
    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
r=0
for c in range(len(s)-len(t)+1):
    x=0
    for d in range(len(t)):
        if s[c+d]==t[d]:
            x+=1
    if x>r:
        r=x
print(len(t)-r)

Submission status: Accepted

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

ans = 2000  # 制約以上の大きな値
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(diff, ans)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

l = len(T)

if l == len(S):
    cnt = 0
    for i in range(l):
        if S[i] != T[i]:
            cnt += 1
    print(cnt)
    exit()

ans = []
for i in range(len(S)-l):
    cnt = 0
    for n in range(l):
        if S[i+n] != T[n]:
            cnt += 1
    ans.append(cnt)
    
print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math


def distance(s, t):
    assert len(s) == len(t)

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

    return cnt


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

    dist = float('inf')
    
    for i in range(len(S) - len(T) + 1):
        dist = min(dist, distance(S[i:i+len(T)], T))

    print(dist)


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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    S = input()
    T = input()

    ans = 10 ** 6
    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()
def same(U):
    k = 0
    for i in range(len(U)):
        if U[i] == T[i]:
            k += 1
    return k
ans = 0
for i in range(len(S)-len(T)+1):
    ans = max(ans,same(S[i:i+len(T)]))
print(len(T)-ans)

Submission status: Accepted

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

cnt = []
for i in range(len(S)-len(T)+1):
    unmch = 0
    for j, t in enumerate(T):
        if t != S[i+j]:
            unmch +=1     
    cnt += [unmch]

print(min(cnt))

Submission status: Accepted

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

Submission status: Accepted

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

l1 = len(S)
l = len(T)

min_ = float('inf')

for i in range(l1 - l + 1):
    cnt = 0

    for j in range(l):
        if S[i + j] != T[j]:
            cnt += 1

    min_ = min(min_, cnt)

print(min_)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    
    n = len(t)
    ans = n
    if len(s)==n:
        temp = 0
        for i in range(n):
            if s[i] != t[i]:
                temp+=1
        ans = temp

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

        if ans > temp:
            ans = temp
    
    print(ans)
main()

Submission status: Accepted

Solution code:
def solution(s,t):
    minv = float("inf")
    for i in range(len(s) - len(t) + 1):
        v = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                v += 1
        minv = min(minv, v)
    return minv

s = input()
t = input()
print(solution(s, t))

Submission status: Accepted

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

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

out = tl
for i in range(sl - tl + 1):
    sub = s[i:i + tl]
    d = 0
    for j, k in zip(sub, t):
        if j != k:
            d += 1
    out = min(out, d)
print(out)

Submission status: Accepted

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

import sys


INF = sys.maxsize // 10


def minimize(s, t):
    ns = len(s)
    nt = len(t)
    res = INF
    for start_idx in range(ns - nt + 1):
        cand = sum(c != d for c, d in zip(s[start_idx: start_idx + nt], t))
        res = min(res, cand)
    return res


def main():
    s = input()
    t = input()
    print(minimize(s, t))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
n_s = len(s)
n_t = len(t)

count = n_t
for i in range(n_s-n_t+1):
  tmp = 0
  for s1, s2 in zip(s[i:n_t+i], t):
    if s1 != s2:
      tmp += 1
  if count > tmp:
    count = tmp
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def read():
    S = input()
    T = input()
    return S, T


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

def func(S, T):
    lt = len(T)
    ans = lt
    for i in range(len(S) - len(T) + 1):
        d = diff(T, S[i:i+lt])
        if d < ans:
            ans = d
    return ans


if __name__ == '__main__':
    S, T = read()
    print(func(S, T))

Submission status: Accepted

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

slen = len(S)
tlen = len(T)

maxnum = -1
for i in range(slen-tlen+1):
    match = 0
    for j in range(tlen):
        if S[i+j] == T[j]:
            match += 1
    if maxnum < match:
        maxnum = match

print(tlen - maxnum)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# map(int, input().split())

S = input()
T = input()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


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


def solve(S, T):
    buf = []
    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
        buf.append(diff)
    return min(buf)


def main():
    # parse input
    S = input().strip()
    T = input().strip()
    print(solve(S, T))


# tests
T1 = """
cabacc
abc
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""

T2 = """
codeforces
atcoder
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
6
"""

T3 = """
aaa
bbb
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
3
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

Submission status: Accepted

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

def equal(x,y):
    s = 0
    for i in range(len(x)):
        if x[i]==y[i]:
            s += 1
    return s

m = len(T)

for i in range(len(S)-len(T)+1):
    m = min(m, len(T) - equal(T,S[i:i+len(T)]))

print(m)

Submission status: Accepted

Solution code:
import math

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:
s, t = input(), 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:
def hw(a,b):
  w = 0
  for i,j in zip(a,b):
    #print(i,j)
    if i == j:
      w+=1
  return w

s = input()
t = input()
ans = len(t)
tl = len(t)
for i in range(len(s)-tl+1):
  #print(s[i:i+tl])
  tmp = tl - hw(s[i:i+tl], t)
  ans = min(tmp, ans)
print(ans)

Submission status: Accepted

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

res = 10**6
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
    res = min(res, val)
print(res)

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=10000
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:
#!/usr/bin/env python3

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


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

    S_ary = list(S)
    T_ary = list(T)

    diff = len(S_ary) - len(T_ary) + 1
    tLen = len(T_ary)

    minCounter = 1000
    for i in range(diff):
        tempS = S_ary[i : i + tLen]

        counter = 0
        for charIndex in range(tLen):
            if tempS[charIndex] != T_ary[charIndex]:
                counter += 1
        minCounter = min(minCounter, counter)

    print(minCounter)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = []
for i in range(len(s)-len(t) + 1):
  s_i = s[i:i+len(t)]
  count_diff = 0
  for t_j, s_j in zip(t, s_i):
    if t_j != s_j:
      count_diff += 1
  ans.append(count_diff)
print(min(ans))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
T = input()
M = len(T)
ans = float("inf")
for i in range(N - M + 1):
    tmp = S[i : i + M]
    diff = 0
    for j in range(M):
        if tmp[j] != T[j]:
            diff += 1
    ans = min(ans, diff)
print(ans)

Submission status: Accepted

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

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

            tmp += 1
    result.append(tmp)

print(len(t)-max(result))

Submission status: Accepted

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