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

sl = len(S)
tl = len(T)

ans = tl
if sl == tl:
    ans = tl - sum([1 for a,b in zip(S, T) if a == b])

for i in range(sl):
    if i+tl >= sl:
        break
    count = tl - sum([1 for a,b in zip(S[i:i+tl], T) if a == b])
    ans = min(ans, count)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
max_cnt = 0
cnt = 0
for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if s[i + j] in t[j]:
            cnt += 1
    if max_cnt < cnt:
        max_cnt = cnt
print(len(t) - max_cnt)

Submission status: Accepted

Solution code:
S=input()
T=input()
n=len(T)
l=len(S)-n
p=0
for i in range(l+1):
    j=0
    m=S[i:i+n]
    
    for k in range(n):
        if(m[k]==T[k]):
            j+=1

    if(p<j):
        p=j
print(n-p)

Submission status: Accepted

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

c = [0] * (len(s) - len(t)+1)

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

print(len(t)-max(c))

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
cnt = [0] * (len(s) - len(t) + 1)
for i in range(len(s) - len(t) + 1):
    x = s[i : i + len(t)]
    for j in range(len(t)):
        if x[j] == t[j]:
            continue
        else:
            cnt[i] += 1

print(min(cnt))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A = str(input())
B = str(input())
C = [0]*len(A)
for i in range(len(A)-len(B)+1):
    for j in range(len(B)):
        if A[i+j]==B[j]:
            C[i]+=1
print(len(B)-max(C))

Submission status: Accepted

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

LT = len(T)
minDiff = LT
for i in range(len(S) - len(T) + 1):
    U = S[i:i+LT]
    diff = 0
    for j in range(LT):
        if U[j] != T[j]:
            diff = diff + 1
    
    if diff <minDiff:
        minDiff = diff

print(minDiff)

Submission status: Accepted

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

out=[]
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
    out.append(cnt)
print(min(out))

Submission status: Accepted

Solution code:
import math
import sys
#####sorting a dictionary by the values#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
##### naive method for testing prime or not#####
def is_prime(n):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
#####swap function#####
def swap(a,b):
    temp=a
    a=b
    b=temp
    return a,b
#####Primes till Nth#####
def seive_primes(n):
    flag=[0]*(n+10)
    flag[1]=flag[0]=1
    i=2
    while i*i<=n+1:
        if flag[i]==0:
            j=i*i
            while j<=n+1:
                flag[j]=1
                j+=i
        i+=1
    return flag
#####function that return all combination of sum(i^n)=x#####
def checkRecursive(x, n, curr_num=1, curr_sum=0): 
    results = 0 
    p = curr_num**n 
    while(p + curr_sum < x):  
        results += checkRecursive(x, n, curr_num + 1, p + curr_sum) 
        curr_num = curr_num + 1
        p = curr_num**n  
    if(p + curr_sum == x): 
        results = results + 1
    return results
#####number of minimum swaps required to sort the array#####
def findMinSwap(arr, n): 
    vec = [] 
    for i in range(n): 
        vec.append([arr[i], i])  
    vec = sorted(vec) 
    ans, c, j = -1, 0, 0
    for i in range(n):  
        if(vec[i][1] == i): 
            continue
        else:  
            vec[i][0], vec[vec[i][1]][1] = swap(vec[i][0],vec[vec[i][1]][1])
            vec[i][1], vec[vec[i][1]][1] = swap(vec[i][1],vec[vec[i][1]][1]) 
        if(i != vec[i][1]): 
            i -= 1
        ans += 1
    return ans
#####greatest common divisor of two numbers#####
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
#####least common multiplyer of two numbers#####
def lcm(a,b):
    return (a*b)//gcd(a,b)
#####function that return all the letters#####
def alphabates():
    return "abcdefghijklmnopqrstuvwxyz"
#####binary search#####
def binary_search(ls,n,flag):
    low=0
    hi=n-1
    while(low<=hi):
        mid=(low+hi)//2
        if ls[mid]==flag:
            return mid
        elif ls[mid]>flag:
            hi=mid-1
        else:
            low=mid+1
    return -1
#####Decimal to Binary(8 bits)#####
def Binary(n):
    if n==0:
        return "00000000"
    binary = "" 
    i = 0
    while n > 0 and i<=8: 
        s1 = str(int(n%2)) 
        binary = binary + s1 
        n /= 2
        i = i+1
        d = binary[::-1] 
    return d
#####quadratic#####
def qdrt(x,a,b,c):
    return a*x*x+b*x+c
#####taking an array/list as input#####
def inp():
    ls=list(map(int,input().split()))
    return ls
#####taking multiple inputs#####
def mult_inp():
    return map(int,input().split())
#####0-1 Knapsack#####
def knapSack(W, wt, val, n): 
    K = [[0 for x in range(W + 1)] for x in range(n + 1)]  
    for i in range(n + 1): 
        for w in range(W + 1): 
            if i == 0 or w == 0: 
                K[i][w] = 0
            elif wt[i-1] <= w: 
                K[i][w] = max(val[i-1]+K[i-1][w-wt[i-1]],  K[i-1][w]) 
            else: 
                K[i][w] = K[i-1][w] 
  
    return K[n][W] 
#####Main function starts from here#####
t=input()
s=input()
ans=[]
for i in range(len(t)-len(s)+1):
    f=len(s)
    a=0
    for j in range(i,i+f):
        if s[j-i]!=t[j]:
            a+=1
    #print(s,t[i:f+i])
    ans.append(a)
print(min(ans))

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s) - len(t) + 1
ans = 1001001001
for i in range(n):
    ans = min(ans, sum(j!=k for j, k in zip(s[i:i+len(t)], t)))
print(ans)

Submission status: Accepted

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

maxsame = 0

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

Submission status: Accepted

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

s_list=list(S)
t_list=list(T)
maxmax=0
for i in range(len(S)-len(T)+1):
    ss=len([j for j in range(len(T)) if s_list[i+j]==t_list[j]])
    if maxmax<ss:
        maxmax=ss
print(str(len(T)-maxmax))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

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

    num = len(S) - len(T)+1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(len(s)-len(t)+1):
    counter = 0
    for i in range(len(t)):
        if(s[i+j] == t[i]):
#            print("i,j=",i,j)
            counter += 1

#    print(counter)
    c.append(counter)

print(len(t)-max(c))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=(input())
t=(input())
n=len(t)
ans=float("inf")
for i in range(len(s)-len(t)+1):
    k=0
    l=s[i:i+n]
    for j in range(n):
        if l[j]!=t[j]:
            k+=1
    ans=min(ans,k)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

count_list = []
for n in range(len(S)-len(T)+1):
    count = 0
    for s, t in zip(S[n:n+len(T)], T):
        if s == t:
            count += 1
    count_list.append(count)

print(len(T)-max(count_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(l_1,l_2):
    result = 0
    for i,j in zip(l_1,l_2):
        if i != j:
            result += 1
    return result

s = input()
t = input()
n_s = len(s)
n_t = len(t)
ans = 10**5

for i in range(0,n_s-n_t+1):
    l = s[i:i+n_t]
    ans = min(ans,solve(t,l))

print(ans)

Submission status: Accepted

Solution code:
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
from itertools import combinations
#map(int,input().split())
#int(x) for x in input().split()
s=input()
x=input()
if x in s:
	print(0)
else:
	ans=10**9
	for i in range(len(s)-len(x)+1):
		c=0
		for j in range(len(x)):
			if s[i+j]!=x[j]:
				c+=1
		ans=min(ans,c)
	print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()
    T = input()

    l = len(T)
    n = len(S) - l
    ans = float("inf")
    for i in range(n + 1):
        d = 0
        s = S[i : i + l]
        for s_, t_ in zip(s, T):
            if s_ != t_:
                d += 1
        ans = min(ans, d)
    print(ans)


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n = int(input())
#a = list(map(int, input().split()))
#d, t, s = map(int, input().split())
s = input()
t = input()
ans = 10000
count = 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 ans > count:
    ans = count
  count = 0
print(ans)

Submission status: Accepted

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

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

ans = 10 ** 5
for i in range(len(S) - (len(T) - 1)):
    c = len(T)
    for j in range(len(T)):
        if T[j] == S[i + j]:
            c -= 1
    ans = min(ans, c)

print(ans)

Submission status: Accepted

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

l_s, l_t=len(S), len(T)
ans=len(T)
for i in range(l_s-l_t+1):
    string=S[i:i+l_t]
    count=0
    for j in range(l_t):
        if T[j]!=string[j]:
            count+=1
    if count<ans:
        ans=count
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

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

max_same = 0
for i in range(s_len-t_len+1):
    tmp_s = S[i:i+t_len]
    count_same = 0
    for j in range(t_len):
        if T[j] == tmp_s[j]:
            count_same += 1
    if count_same > max_same:
        max_same = count_same
print(t_len-max_same)

Submission status: Accepted

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

print(min_lts)

Submission status: Accepted

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

a = 0
ans = len(T)
c = len(T)


for i in range(len(S)-len(T)+1):
    b = 0
    c = len(T)
    for j in T:
        if S[i+b] == j:
            c -= 1
        b += 1
    else:
        if ans > c:
            ans = c
        
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
maxa = 0
answer = 0
for i in range(len(t)):
    if t[i] in s[i:]:
        for j in range(len(s[i:])):
            if t[i] == s[i+j] and j + len(t) <= len(s):
                for k in range(len(t)):
                    if t[k] == s[j+k]:
                        answer += 1
                if answer > maxa:
                    maxa = answer
                answer = 0
print(len(t) - maxa)

Submission status: Accepted

Solution code:
S = input()
T = input()
maxs = 0
for x in range(len(S)-len(T)+1):
    count=0
    for y in range(len(T)):
        if T[y] == S[x+y]:
            count += 1
        maxs = max(count,maxs) 

print(len(T)-maxs)

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
ls = len(s)
lt = len(t)
a = 0
for i in range(ls):
    if i >= lt:
        break
    if s[i] != t[i]:
        a += 1
for i in range(1, ls-lt+1):
    b = 0
    for j in range(i, ls):
        if j - i >= lt:
            break
        if s[j] != t[j-i]:
            b += 1
    if b < a:
        a = b
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

    len_s = len(S)
    len_t = len(T)

    ans = 0
    tmp = 0
    for i in range(len_s-len_t+1):
        A = S[i:i+len_t]
        for j,k in zip(A,T):
            if j == k:
                tmp+=1
        ans = max(ans,tmp)
        tmp = 0
    print(len_t-ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
kari_result = 0
min_result = 10000000000
for i in range(len(s)-len(t)+1):
    for l in range(len(t)):
        if s[i+l] != t[l]:
            kari_result += 1
    if kari_result < min_result:
        min_result = kari_result
    kari_result = 0
print(min_result)

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
L = len(T)

ans = float("inf")
for i in range(N):
    if N-i < L:
        break
    tmp = 0
    for s, t in zip(S[i:i+L], T):
        if s != t:
            tmp += 1
    if ans > tmp:
        ans = tmp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result = len(s)
for i in range(len(s) -len(t) + 1):
  result1 = 0
  k = i
  for j in range(len(t)):
    if s[k] != t[j]:
      result1 += 1
    k += 1
  if result > result1:
    result = result1
    
print(result)

Submission status: Accepted

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

l = []
for i in range(len(s)-len(t)+1) :
    moji = s[i]
    for j in range(len(t)-1) :
        moji += s[i+j+1]
    l.append(moji)
    moji = ""
c = 0
ans = 1000
for i in range(len(l)):
    c = 0
    for j in range(len(t)):
        if l[i][j] != t[j] :
            c += 1
    if ans > c :
        ans = c
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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 = input()
t = input()

b = len(s)
a = len(t)

min_cnt = 100000000

for i in range(b - a + 1):
    cnt = 0
    for j in range(a):
        if s[j+i] != t[j]:
            cnt += 1
    
    if min_cnt > cnt:
        min_cnt = cnt

print(min_cnt)

Submission status: Accepted

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

Submission status: Accepted

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

cost = 10**9+7

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

Submission status: Accepted

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

Submission status: Accepted

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

    # sがtの長さにおいて一致している最大の文字数を特定
    max_counter = 0

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

    answer = len(t) - max_counter
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

t_max = 10000
for i in range(len(s) - len(t) + 1):
    tmp = func(s[i:i+len(t)], t)
    if tmp < t_max:
        t_max = tmp
print(t_max)

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())
a=len(s)-len(t)
A=[]
d=0
if a==0:
    for k in range(len(t)):
        if t[k]!=s[k]:
            d+=1
    print(d)
else:    
    
    for i in range(a):
        b=0
        for j in range(len(t)):
            if t[j]==s[j+i]:
                b+=1
        A.append(b)

    c=max(A)
    print(len(t)-c)

Submission status: Accepted

Solution code:
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


S = _S()
T = _S()
ans = 0

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

print(ans)

Submission status: Accepted

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


def main():
    S = sys.stdin.readline().rstrip()
    T = sys.stdin.readline().rstrip()

    min_cnt = 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
        
        min_cnt = min(min_cnt, cnt)
    
    
    print(min_cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

count = 0
reg = 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 count > reg:
    reg = count
  count = 0

reg = len(t) - reg
print(reg)

Submission status: Accepted

Solution code:
S = input()
T = input()
gap1 = 0
gap2 = len(S) - len(T)
x = 0
ans = 0
while gap1<= gap2:
    itti = 0
    for i in range(len(T)):
        if T[i] == S[gap1+i]:
            itti += 1
    gap1 += 1
    ans = max(ans,itti)
print(len(T)-ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = len_t
for i in  range(len_s - len_t+1):
    s_sub = s[i:len_t + i]
    ans  = min(ans, len([... for i in range(len_t) if t[i] != s_sub[i]]))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    S = input()
    T = input()

    numdic = [0]*(100000)
    for i in range(len(S)+1-len(T)):
        small = S[i:i+len(T)]
        same = 0
        for s in range(len(T)):
            if small[s] == T[s]:
                same += 1
        numdic[i] = same

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




if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(len(T) - cnt)

Submission status: Accepted

Solution code:
A=input()
B=input()
ans=float("inf")
for i in range(len(A)-len(B)+1):
   C=A[i:i+len(B)]
   tmp=0
   for j in range(len(B)):
      if C[j] != B[j]:
         tmp+=1
   ans=min(tmp,ans)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
x = 0
for i in range(0,len(s)-len(t)+1):
    p = s[i:i+len(t)]

    y = 0
    for j in range(0,len(t)):
        if p[j] == t[j]:
            y = y + 1

    if y >= x:
        x = y

print(len(t) - x)

Submission status: Accepted

Solution code:
#Sが長いほう
S = input()
T = input()

mincnt = len(T)
for i in range(len(S)-len(T)+1): #i番目からチェック
  cnt = 0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      cnt += 1
  mincnt = min(mincnt, cnt)
print(mincnt)

Submission status: Accepted

Solution code:
# d, t, s = map(int, input().split())
s = input()
t = input()


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


minc = 1001
for i in range(0, 1 + len(s) - len(t)):
    minc = diff(s[i: i + len(t)], t, minc)
print(minc)

Submission status: Accepted

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

slength = len(s)
tlength = len(t)

minimum = tlength

for i in range(slength - tlength + 1):
    count = 0
    for j in range(tlength):
        if t[j] != s[i + j]:
            count += 1
    if minimum > count:
        minimum = count

print(minimum)

Submission status: Accepted

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

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

print(m)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
X = []

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
    X.append(cnt)

print(len(T)-max(X))

Submission status: Accepted

Solution code:
def diff(s,t):
    assert len(s) == len(t)
    #print(s,t)
    c = 0
    for i,j in zip(s,t):
        if i != j:
            c+=1
        else:
            pass
    return c
s=input()
t=input()
n=len(s)
m=len(t)
min_=10**5
for i in range(n-m+1):
    min_=min(min_,diff(s[i:m+i],t))
print(min_)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


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

    ans = float("inf")

    for i in range(0, len(S1)):

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S=input()
    T=input()
    max_count = 0
    for i in range(len(S)-len(T)+1):
        tmp_count = 0
        for j in range(len(T)):
            if S[i+j] == T[j]:
                tmp_count = tmp_count+1
        if tmp_count > max_count:
            max_count = tmp_count

    print(len(T)-max_count)
    #N = int(input())
    #A = [int(s) for s in input().split()]
    #

main()

Submission status: Accepted

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

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

print(min(cnt))

Submission status: Accepted

Solution code:
s=input()
l=input()
len_s=len(s)
len_l=len(l)
a=len_s-len_l
ans=1001
for i in range(len_s-len_l+1):
    cnt=0
    for j in range(len_l):
        if l[j]!=s[i+j]:
            cnt+=1
    ans=min(ans,cnt)

print(ans)

Submission status: Accepted

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

max_equal = 0

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

Submission status: Accepted

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

min_count = len(S)

for i in range(len(S) - len(T) + 1):
  count = 0
  for j, s in enumerate(T):
    # print(s, S[i+j], s == S[i+j])
    if s != S[i+j]:
      count += 1
  
  if count < min_count:
    min_count = count

print(min_count)

Submission status: Accepted

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

n = len(s)
m = len(t)
ans = float("inf")
for i in range(n-m+1):
  p = 0
  for j in range(m):
    if s[i+j] != t[j]: p += 1
  if p < ans: ans = p
print(ans)

Submission status: Accepted

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

ls, lt = len(s), len(t)
min_diff = 1000

for i in range(0, ls-lt+1):
	subs = s[i:i+lt]
	diff = lambda x, y: sum([1 if char1 != char2 else 0 for char1, char2 in zip(x, y)])
	min_diff = min(min_diff, diff(subs, t))

print(min_diff)

Submission status: Accepted

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

if t in s:
    print(0)
else:
    ans = 10000000
    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=len(S)-len(T)+1
t=len(T)
if S.find(T)!=-1:
    print(0)
else:
    tmp=0
    id=-1
    for i in range(n):
        cnt=0
        for j in range(t):
            if S[i+j]==T[j]:
                cnt+=1
        if cnt>tmp:
            tmp=cnt
            id=i
    print(t-tmp)

Submission status: Accepted

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

match = 0
k = 0
result = 0
for i in range(len(S)-len(T)+1) :
    k = i # start
    match = 0
    for j in range(len(T)) :
        #print(T[j],S[k])
        if T[j] == S[k] :
            match = match + 1
        k += 1
    result = max(result,match)
#print(result)
print(len(T) - result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from sys import exit
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import numpy as np
x = input()
y = input()

a=np.array(list(x))
b=np.array(list(y))
ans=0

for i in range(len(a)-len(b)):    
    tmp=(a[i:len(b)+i]==b).sum()
    if ans<tmp:
        ans=tmp
        
if len(a)==len(b):
    print(len(b)-(a==b).sum())
else:
    print(len(b)-ans)