Problem:


Score : 200 points

Problem Statement

Given are two strings S and T.

Let us change some of the characters in S so that T will be a substring of S.

At least how many characters do we need to change?

Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.

Constraints

The lengths of S and T are each at least 1 and at most 1000.

The length of T is at most that of S.

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

Print the minimum number of characters in S that need to be changed.

Sample Input 1

cabacc
abc

Sample Output 1

1

For example, changing the fourth character a in S to c will match the second through fourth characters in S to T.

Since S itself does not have T as its substring, this number of changes - one - is the minimum needed.

Sample Input 2

codeforces
atcoder

Sample Output 2

6



Sample input:
cabacc
abc


Sample output:
1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ss = str(input())
tt = str(input())
#print(ss,tt)
maxmatch = 0
#
for i in range(len(ss)-len(tt)+1):
    nofmatch = 0
    for j in range(len(tt)):
        #print(ss[i + j], tt[j])
        if ss[i+j] == tt[j]:
            nofmatch += 1
    if nofmatch > maxmatch:
        maxmatch = nofmatch

print(len(tt)-maxmatch)

Submission status: Accepted

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

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

ans = 0
for i in range(len(s)):
    x = check(s[i:i + len(t)], t)
    if ans  < x:
        ans = x

print(len(t) - ans)

Submission status: Accepted

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

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

print(len(t)-ans)

Submission status: Accepted

Solution code:
# from pprint import pprint
# import math
# import collections

s = input()
t = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

max_cnt = 0
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

    # print(_s,t, 'match', cnt)

    if max_cnt < cnt:
        max_cnt = cnt

print(len(t) - max_cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
T = input()

S_len = len(S)
T_len = len(T)
diff_len = S_len - T_len
tmp_count = 0
mached = 100000

for i in range(diff_len + 1):
    for j in range(T_len):
        if T[j] != S[j + i]:
            tmp_count = tmp_count + 1
    if tmp_count < mached:
        mached = tmp_count
    tmp_count = 0

print(mached)

Submission status: Accepted

Solution code:
N = input()
S = input()
a = 0
nums = list(N[i:i+len(S)] for i in range(len(N)) if i+len(S)-1 < len(N))
nums_max  = 0
for i in nums:
  tmp = 0
  for j in range(len(S)):
    if i[j] == S[j]:
      tmp += 1
  if nums_max < tmp:
    nums_max = tmp
print(len(S)-nums_max)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import sys
import math

s = input()
t = input()

dist_list = []

for i in range(len(s) - len(t) + 1):
    #tと同じ文字数をsから切り出す
    sd = s[i:i+len(t)]

    #ハミング距離を求める
    dist = 0
    for j in range(len(t)):
        if sd[j] != t[j]:
            dist += 1
    
    dist_list.append(dist)

print(min(dist_list))

Submission status: Accepted

Solution code:
def compare(ar1,ar2):
    count = 0
    for i in range(len(ar1)):
        if ar1[i] != ar2[i]:
            count+=1
    return count

s = input()
t = input()
lowest = len(t)
for i in range(len(s)-len(t)+1):
    res = compare(t,s[i:i+len(t)])
    if res < lowest:
        lowest = res
print(lowest)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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


s = input()
t = input()

result = 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


    if result > dif:
        result = dif

print(result)

Submission status: Accepted

Solution code:
s = input()
t = input()
s_len = len(s)
t_len = len(t)

max_c = 0
if t in s:
    print(0)
    exit()
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
    if count > max_c:
        max_c = count
print(t_len-max_c)

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
count=0
hako=[]
for i in range(len(S)-len(T)+1):
  for k in range(len(T)):
    if S[i+k]!=T[k]:
      count+=1
  hako.append(count)
  count=0
fin=min(hako)
print(fin)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 10 ** 9

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()
new = list(S)
main = list(T)

thelist = []

for i in range(len(new)):
    if len(new[i:i+len(main)]) < len(main):
        break
    thelist += [new[i:i+len(main)]]

counter = 0

for lists in thelist:
    second_counter = 0
    for i in range(len(main)):
        if main[i] != lists[i]:
            second_counter += 1
    if counter == 0:
        counter = second_counter
    elif second_counter < counter:
        counter = second_counter

print(counter)

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
result = 0
diff = len(s) - len(t) + 1
start = 0
end = len(t)
strimlist = []
diflist = []


for i in range(diff):
  strim = s[start:end]
  strimlist.append(strim)
  start += 1
  end += 1

for j in strimlist:
  index = 0
  difresult = 0
  for k in range(len(t)):
    if j[index] == t[index]:
      index += 1
    else:
      difresult += 1
      index += 1
  diflist.append(difresult)
  diflist.sort()
print(diflist[0])

Submission status: Accepted

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

s=input().strip()
t=input().strip()
n=len(s)
m=len(t)
M=[]
for i in range(n-m+1):
    count=0
    for j in range(m):
        if s[i+j]==t[j]:
            count+=1
    M.append(m-count)
print(min(M))

Submission status: Accepted

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

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

Submission status: Accepted

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

ans_list = []
end = len(s) - len(t) + 1
for i in range(end):
    word = s[i:i+len(t)]
    tmp = 0
    for j in range(len(t)):
        if t[j] != word[j]:
            tmp += 1
    ans_list.append(tmp)

ans_list.sort()
ans = ans_list[0]

print(ans)

Submission status: Accepted

Solution code:

S = input()
T = input()

cnt = 0
l = []
for i in range(len(S)-len(T)+1):
    text = S[i:i + len(T)]
    for j in range(len(T)):
        if text[j] == T[j]:
            cnt += 1
    l.append(cnt)
    cnt = 0

print(len(T)-max(l))

Submission status: Accepted

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

Submission status: Accepted

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

thelist = []

for i in range(len(new)):
    if len(new[i:i+len(main)]) < len(main):
        break
    thelist += [new[i:i+len(main)]]

counter = 0

for lists in thelist:
    second_counter = 0
    for i in range(len(main)):
        if main[i] != lists[i]:
            second_counter += 1
    if counter == 0:
        counter = second_counter
    elif second_counter < counter:
        counter = second_counter
print(counter)

Submission status: Accepted

Solution code:
a = input()
b = input()
d = []
for i in range(0,len(a)-len(b)+1):
    c = 0
    for j in range(0,len(b)):
        if a[i+j] != b[j]:
            c = c + 1
        
    d.append(c)

print(min(d))

Submission status: Accepted

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

def diff(s,t):
    count = 0
    #print(s,t)
    for i in range(len(t)):
        if s[i]!=t[i]:
            count+=1
    #print(count)
    return count
min_c = diff(S,T)

for i in range(len(S)-len(T)):
    d = diff(S[i:],T)
    #print(d)
    if d<min_c:
        min_c = d
print(min_c)

Submission status: Accepted

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

mS = []
d = len(S) - len(T)
m = 0

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

else :

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

        mS.append(m)
        S = S[1:]
    print(min(mS))

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
ns = len(s)
nt = len(t)

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

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

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
m = len(t)
for i in range(len(s)-len(t)+1):
    c = 0
    target = s[i:i+len(t)]
    # print(target)
    for j in range(len(t)):
        # print(target[j],t[j])
        if not target[j] == t[j]:
            c += 1
    # print(m,c)
    if c < m :
        m = c
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

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

i = tlen
n = 0
a = 0
# tuu = [0] * tlen
# ans = [0] * tlen
max_count = 0
while i <= slen:
    ps = s[ n : i + tlen -1 ]
    count = 0
    for j in range(tlen):
        if ps[j] == t[j]:
            count += 1
#             tuu[j] = "True"
#             print("通った")
#     print(count)
    if max_count < count:
        max_count = count
    n += 1
    i += 1
print(tlen - max_count)

Submission status: Accepted

Solution code:
def input_from_console():
    s = input()
    t = input()
    return s, t


def solve(s, t):
    min_count = len(t)
    for i in range(len(s)-len(t) + 1):
        temp_count = 0
        for j in range(len(t)):
            if s[j+i] != t[j]:
                temp_count += 1
        min_count = min(min_count, temp_count)
    return min_count


def main():
    s, t = input_from_console()
    print(solve(s, t))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Accepted

Solution code:
S = input()
T = input()
s = len(S)
t = len(T)
M = 0
tmp = [ord(char) for char in T]
for n in range(s-t+1):
  m = [ord(char) - tmp[i] for i, char in enumerate(S[n:n+t])].count(0)
  if M < m:
    M = m
print(t-M)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()
T = input()

m = 0

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

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

print(len(T)-m)

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

Submission status: Accepted

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

if T in S:
    print(0)
    sys.exit(0)

ans = []
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    cnt = 0
    for x, y in zip(s, T):
        if x == y:
            cnt += 1
    ans.append(cnt)
    
print(len(T)-max(ans))

Submission status: Accepted

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

sl=[]
tl=[]

for i in range(len(s)):
  sl.append(s[i])
for i in range(len(t)):
  tl.append(t[i])
  
m=100000
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
  m=min(m,cnt)
print(m)

Submission status: Accepted

Solution code:
S = input()
T = input()
i = 0
min = len(T)
#print(S[2])
if(T in S):
    print("0")
else:
    while(i <= len(S)-len(T)):
        count = 0
        #print("count min")
        #print(count)
        #print(min)
        for j in range(len(T)):
            #print("T S")
            #print(T[j])
            #print(S[j + i])
            if(T[j] != S[j + i]):
                count+=1
        #print("now count")
        #print(count)
        if(count <= min and count != 0):
            min = count
            #print("Change!!!!!")
        i+=1
    print(min)

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

s = input()[:-1]
t = input()[:-1]
num = len(t)
ans = 1000

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
#a = list(map(int,input().split()))
m = 1001

#print(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
  m = min(m,count)
  
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(input())
b = list(input())
min_k = len(b)
for i in range(len(a)-len(b)+1):
  c = a[i:i+len(b)]
  count=0
  for k,j in enumerate(c):
    if b[k]==j:
      count+=1
        
  min_k = min(min_k,len(b)-count)

print(min_k)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

S = str(input())
T=str(input())
ans = 0
temp = 0


for i in range(len(S)):
    temp = 0
    for j in range(len(T)):
        if(len(S)<i+len(T)):
            break
        if(S[i+j]==T[j]):
            temp += 1
    ans = max(ans,temp)

print(len(T)-ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
i,m=0,1e9
while(i+len(t)<=len(s)):
    c=0
    for j in range(len(t)):
        if(s[i+j]!=t[j]):
            c+=1
    m=min(m,c)
    i+=1
print(m)

Submission status: Accepted

Solution code:
s = input()
t = input()
res = []
for i in range(len(s)-len(t)+1):
    x = s[i:i+len(t)]
    count = sum(1 for a, b in zip(t, x) if a != b)
    res.append(count)

print(min(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

s=input()
t=input()
idx=0
wk=0
while 1:
    mt=0
    for idx2,val in enumerate(t):
        if s[idx+idx2]==val:
            mt+=1
    wk=max(wk,mt)
    if idx+len(t)>=len(s):break
    else:idx+=1
    
print(len(t)-wk)

Submission status: Accepted

Solution code:
s1 = input()
s2 = input()
a = len(s2)
m = 10**18
for x in range(len(s1)-a+1):
  s3 = s1[x:x+a]
  s = 0
  for y in range(a):
    if s3[y]!=s2[y]:
      s+=1
  m = min(m,s)
print(m)

Submission status: Accepted

Solution code:
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    s = list(S())
    t = list(S())
    lst = []
    ans = []
    for i in range(len(s) - len(t)+1):
        lst.append(s[i: i + len(t)])
    for l in lst:
        cnt = 0
        for i in range(len(t)):
            if l[i] == t[i]:
                cnt += 1
            ans.append(len(t) - cnt)
    print(min(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
x = len(t)
mx= 0

res= 0
for i in range(len(s) - x+1):
    # print(i)
    tmp = s[i:i+x]
    cntmp = 0
    for j in range(x):
        if t[j] == tmp[j]:
            cntmp += 1
    # print(tmp, i)
    res = max(res, cntmp)
print(x-res)

Submission status: Accepted

Solution code:
s= input()
t= input()
a = len(s)
b = len(t)
i = 0
j = 0
cnt = 0
ans = b
while(j <= a - b):
    while (i < b):
        if (s[i + j] != t[i]):
            cnt+=1
        i+=1
    ans = min(ans, cnt)
    cnt = 0
    i = 0
    j+=1
print(ans)

Submission status: Accepted

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

m = len(a)
n = len(b)

ans = 10e9+7

for i in range(m-n+1):
	c=0;
	for j in range(n):
		if(a[i+j]!=b[j]):
			c+=1
	ans = min(c,ans)

print(ans)

Submission status: Accepted

Solution code:
def main():
    s_long = input()
    s_shor = input()

    ans = len(s_shor)
    max_len = len(s_long) - len(s_shor) + 1


    for i in range(max_len):
        cnt = 0

        for j in range(len(s_shor)):

            short = s_shor[j]
            longg = s_long[i + j]
            
            if (short != longg):
                cnt += 1
        
        ans = min(ans, cnt)
        
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

	else:
		l = []
		for i in range(len(s)-len(t)):
			l.append(s[i:i+len(t)])
		
		ans = []
		for c in l:
			counter = 0
			for i in range(len(c)):
				if list(c)[i] == list(t)[i]:
					counter += 1
			ans.append(counter)

		if not ans:
			print(len(t))
		else:
			print(len(t)-max(ans))





	

if __name__ == '__main__':
	main()

Submission status: Accepted

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

ans = 10000
for i in range(len(S) - len(T) + 1):
    subset = S[i:i + len(T)]
    # print(f'{subset=}, {T=}')
    cnt = 0
    for s, t in zip(subset, T):
        # print(f'{s=}, {t=}')
        if s != t:
            cnt += 1
    ans = min(ans, cnt)
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):
    count=len(t)
    for j in range(len(t)):
        if s[i+j]==t[j]:
            count-=1
    if count<ans:
        ans=count
print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
lt=len(t)
ls=len(s)
differ=ls-lt
ans=[]
for i in range(0,differ+1,1):
  cnt=0
  st=differ-i
  s_cont=s[st:]
  for a in range(lt):
    if s_cont[a]==t[a]:
      cnt+=1
    ans.append(lt-cnt)
print(min(ans))

Submission status: Accepted

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

S=input().strip()
T=input().strip()

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

print(len(T)-max)

Submission status: Accepted

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

Submission status: Accepted

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

lstS = list(S)
lstT = list(T)

difMin = 1000

for i in range(len(lstS)-len(lstT)+1):
  dif = 0
  
  for j in range(len(lstT)):
    if(lstT[j] != lstS[i+j]):
      dif += 1
  
  if(dif < difMin):
    difMin = dif

print(difMin)

Submission status: Accepted

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

Submission status: Accepted

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

ans = []

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
lens = int(len(s))
lent = int(len(t))
icchi = []
c = 0
for i in range(lens-lent+1):
    scut = s[i:lent+i]
    for j in range(lent):
        if scut[j] == t[j]:
            c += 1
    icchi.append(c)
    c=0
print(lent-max(icchi))

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s)
l=len(t)
count=l
for j in range(n-l+1):
    sj=s[j:j+l]
    res=0
    for k in range(l):
        if sj[k]!=t[k]:
            res+=1
    if res<count:
        count=res



print(count)

Submission status: Accepted

Solution code:
import sys

s = input()
t = input()
a = len(s)
b = len(t)
c = sys.maxsize
for i in range(a - b + 1):
    d = 0
    for k in range(b):
        if t[k] != s[i+k]:
            d += 1
    c = min(d, c)
print(c)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
tempcount = 0
mincount = 0

for i in range(len(S) - len(T)+1):
    for j in range(len(T)):
        if S[i + j] != T[j]:
            tempcount += 1
    if i == 0:
        mincount = tempcount
    elif tempcount < mincount:
        mincount = tempcount
    tempcount = 0
    
print(mincount)

Submission status: Accepted

Solution code:
S = input().strip() ;
T = input().strip() ;


c = len(T) ;
for idx in range ( len ( S ) ) :
	if idx+len(T) >len(S) : break ;
	S2 = S[idx:idx+len(T)] ;
	
	x = 0 ;
	for c1  ,c2  in zip ( S2 , T ) :
		if c1 != c2 :
			x += 1; 
	c = min ( x  ,c ) ; 
print ( c ) ;

Submission status: Accepted

Solution code:
import numpy as np
import sys

S = input()
T = input()

counter = 0
max_counter = 0

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        if S[j+i] == T[j]:
            counter = counter + 1
    if counter > max_counter:
        max_counter = counter
    # print(counter)
    # print('max = ' + str(max_counter))
    counter = 0

print(int(len(T)) - int(max_counter))

Submission status: Accepted

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

def check(l, r):
    res = 0
    for i, j in zip(l, r):
        if i != j:
            res += 1
    return res
ans = float("inf")
for i in range(len(s)-len(t)+1):
    ans = min(ans, check(s[i:len(t)+i], t))
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
S = [i for i in S]
T = [i for i in T]
Cnt = []
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
    Cnt.append(cnt)
Cnt.sort()
print(Cnt[0])

Submission status: Accepted

Solution code:
s=input()
t=input()
ans = 0
c = 0
m = 1001

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
max_change = 1000
s = input()
t = input()
list_t = np.array([ _ for _ in t])
if len(s) == len(t):
    list_s = np.array([ _ for _ in s])
    list_tf = list_t == list_s
    n_change = len(list_t) - sum(list_tf)
    if n_change < max_change:
        max_change = n_change
    else:
        pass
else:
    for i in range(1,len(s) - len(t) + 1):
        s_sample = s[i-1:len(t)+i-1]
        list_ss = np.array([ _ for _ in s_sample])
        list_tf = list_t == list_ss
        n_change = len(list_t) - sum(list_tf)
        if n_change < max_change:
            max_change = n_change
        else:
            pass
print(max_change)

Submission status: Accepted

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = input()
T = input()

lis = list(T)

max_count = 0
for i in range(len(S) - len(T)+1):
    subS = list(S[i:i+len(T)])
    count = 0
    for j in range(len(T)):
        if subS[j] == T[j]:
            count += 1
    # print(subS, count)
    max_count = max(max_count, count)

print(len(T) - max_count)

Submission status: Accepted

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

Submission status: Accepted

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

index = 0
tmp = 0
ans = float('inf')

loop_time = len(S) - len(T) + 1
T_len = len(T)
for i in range(loop_time):
    S_new = S[i:T_len+i]
    tmp = T_len
    for s,t in zip(S_new,T):
        if s == t:
            tmp -= 1
    ans = min(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
s=str(input())
l=len(s)
t=str(input())
n=len(t)
ans=n
sum=0
for i in range(l+1-n):
    cutted=s[i:i+n]
    for j in range(n):
        if cutted[j]==t[j]:
            continue
        else:
            sum+=1
    ans=min(ans,sum)
    sum=0
print(ans)

Submission status: Accepted

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

    min_count = len_t
    for i in range(len_s-len_t+1):
        count = len_t
        for j in range(len_t):
            if s[i+j] == t[j]:
                count -= 1
        if count < min_count:
            min_count = count
    return min_count


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
s = input()
t = input()
y = 1001
for i in range(len(s) - len(t) + 1): #sの始め
    x = 0
    for j in range(len(t)): #何文字目を調べるか
        if s[i + j] != t[j]:
            x += 1
    if x < y:
        y = x
print(y)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 100000
for i in range(len(s) - len(t) + 1):
    lt = len(t)
    cnt = 0
    for a, b in zip(s[i:i+lt], t):
        if a != b:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

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

ans = 100000
for start in range(len(s)-len(t)+1):
    substr = s[start:start+len(t)]

    cnt = len(t)
    for i in range(len(substr)):
        if t[i] == substr[i]:
            cnt -= 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

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

num = 0;
cnt = 0
min = len(t)
for i in range(len(s)-len(t)+1):
    ss = s[num:num+len(t)]
    for x,y in zip(ss,t):
        if x != y:
            cnt += 1
    if cnt < min:
        min = cnt
    cnt = 0
    num = num +1

print(min)

Submission status: Accepted

Solution code:
S = input()
T = input()
ls = len(S)
lt = len(T)

m = 0
for i in range(ls-lt + 1):
    x = 0
    for j in range(lt):
        if S[j + i] == T[j]:
            x += 1
    m = max(x, m)
print(lt - m)

Submission status: Accepted

Solution code:
S=input()
S1=list(S)
T=input()
T1=list(T)
ans=[]
for i in range(len(S1)-len(T1)+1):
  d=len(T1)
  for j in range(len(T1)):
    if T1[j]==S1[j+i]:
      d-=1
  ans.append(d)
an=min(ans)
print(an)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
maxCount = len(T)
for i in range(len(S)-len(T)+1):
    countNotEqual = 0
    for j in range(len(T)):
        if S[j+i] != T[j]:
            countNotEqual += 1
    if countNotEqual < maxCount:
        maxCount = countNotEqual
print(maxCount)