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:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    s=input()
    t=input()
    count=len(t)
    temp=0
    for i in range(len(s)-len(t)+1):
        temp=0
        for j in range(len(t)):
            a=s[i+j]
            b=t[j]
            if s[i+j]!=t[j]:
                temp+=1
        count=min(temp,count)
    print(count)



if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
def compare(a, b):
    result = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            result += 1
    return result

s = input()
t = input()

ls = len(s)
lt = len(t)

diff = []
for i in range(ls-lt+1):
    diff.append(compare(s[i:i+lt], t))
print(min(diff))

Submission status: Accepted

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

    ans = len(t)
    for i in range(len(s) - len(t) + 1):
        match_count = 0
        for ti, c in enumerate(t):
            if s[i + ti] == c:
                match_count += 1
                ans = min(len(t) - match_count, ans)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

s = 10**5
for i in range (len(S) - len(T) +1):
    wrong = 0
    for j in range (len(T)):
        if S[i+j] != T[j]:
            wrong+=1
    if wrong < s:
        s = wrong

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(S: str, T: str):
    ans = -1
    for i in range(len(S)-len(T)+1):
        sub = S[i:i+len(T)]
        m = 0
        for j in range(len(T)):
            if sub[j]==T[j]:
                m += 1
        ans = max(ans, m)
    print(len(T)-ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 100000000
for i in range(len(S)-len(T)+1):
    ans = min(ans, sum(s != t for s, t in zip(T, S[i:i+len(T)])))
print(ans)

Submission status: Accepted

Solution code:
s_line = input()
s_list = list(s_line)

t_line = input()
t_list = list(t_line)

result = len(t_list)

for i in range(len(s_list) - len(t_list) + 1):
    temp = len(t_list)
    for j in range(len(t_list)):
        if(s_list[i+j] == t_list[j]):
            temp -= 1
            
    if(temp < result):
        result = temp
        
print(result)

Submission status: Accepted

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

  min_count = len(T)
  for i in range(len(S) - len(T) + 1):
    temp_counter = 0
    for t in range(len(T)):
      if T[t] != S[i + t]:
        temp_counter += 1
    if temp_counter < min_count:
      min_count = temp_counter

  print(min_count)

if __name__ == "__main__":
  resolve()

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
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = float('inf')
for i in range(len(S)-len(T)+1):
    st = S[i:len(T)+i]
    count = 0
    for j in range(len(T)):
        if st[j]!=T[j]:
            count+=1
    ans = min(ans,count)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 10**6
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:
# B

S=input()
T=input()

def check(i,T):
    ns=S[i:i+len(T)]
    res=0
    for i in range(len(T)):
        if ns[i]!=T[i]:
            res+=1
    return res

print(min([check(i,T) for i in range(len(S)-len(T)+1)]))

Submission status: Accepted

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

# In[15]:


S = input()
T = input()


# In[16]:


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


# In[ ]:

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import os
from sys import stdin, stdout
    
    
def solve(tc):
    s = stdin.readline().strip()
    t = stdin.readline().strip()

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

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



    
tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Submission status: Accepted

Solution code:
import sys

s = input()
t = input()
difl = []

for i in range(len(s)-len(t)+1):
    if s[i:i+len(t)] == t:
        print(0)
        sys.exit()
    else:
        dif = 0
        for j in range(len(t)):
            if s[j+i] != t[j]:
                dif += 1
    difl.append(dif)

print(min(difl))

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 10**9 + 7
for i in range(len(s) - len(t) + 1):
    trystr = s[i:i+len(s)+1]
    tryans = 0
    for j in range(len(t)):
        if trystr[j] != t[j]:
            tryans += 1
    if tryans <= ans:
        ans = tryans
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):
    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:
# -*- coding: utf-8 -*-
S = input()
T = input()
max = len(S)
for i in range(len(S)-len(T)+1):
    ans = len(T)
    for i,v in zip(T,S[i:i+len(T)]):
        if i == v:
            ans-=1
    if ans < max:
        max = ans
print(max)

Submission status: Accepted

Solution code:
#B
S=input()
T=input()
a=len(S)
b=len(T)
ans=float("inf")
for i in range(0,len(S)-len(T)+1):
    K=S[i:i+len(T)]
    cnt=0
    for j in range(len(K)):
        if K[j]!=T[j]:
            cnt+=1
    ans=min(ans,cnt)
        
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    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 count <= ans:
            ans = count
    
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
readline = stdin.buffer.readline
read = stdin.buffer.read

# import numpy as np
# from numba import jit
# stdin = open('sample.txt')

def main():
    S = readline().rstrip()  
    T = readline().rstrip()
    ls = len(S)
    lt = len(T)
    ans = lt
    for i in range(ls - lt + 1):
        cnt = lt
        for j in range(lt):
            if S[j + i] == T[j]:
                cnt -= 1
        ans = min(ans, cnt)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

minimum = len(T)
for i in range(len(S)):
    count = len(T)
    for j in range(len(T)):
        if i+j >= len(S):
            count = len(T)
            break
        if S[i+j] == T[j]:
            count -= 1
    minimum = min(minimum, count)

print(minimum)

Submission status: Accepted

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

if S in T:
    print('0')
else:
    count = 0
    for i in range(len(S) - len(T) + 1):
        tmp = 0
        for p in range(len(T)):
            if S[i + p] == T[p]:
                tmp += 1
        
        if count < tmp:
            count = tmp
    
    print(len(T) - count)

Submission status: Accepted

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

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

print(len(t)-count_max)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 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
    if ans > tmp:
        ans = tmp

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
def diff_count(A,B):
    diff = 0
    for a,b in zip(A,B):
        if a!=b:
            diff += 1
    return diff
ans = len(T)
for i in range(len(S) - len(T)+1):
    temp = S[i:i+len(T)]
    diff_num = diff_count(T,temp)
    ans = min(diff_num,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T=input()
NS=len(S)
NT=len(T)
ans=pow(10,9)
for n in range(NS-NT):
    suuji=0
    for m in range(NT):
        if S[n+m]!=T[m]:
            suuji+=1
    ans=min(ans,suuji)
if NS==NT:
    suuji=0
    for n in range(NS):
        if S[n]!=T[n]:
            suuji+=1
    ans=min(suuji,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

    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)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
l0 = len(s)
l1 = len(t)
ans = 10**9
for i in range(l0 - l1 + 1):
  x = 0
  for j in range(l1):
    if s[i + j] != t[j]:
      x += 1
  ans = min(ans, x)
print(ans)

Submission status: Accepted

Solution code:
def abc177b():
    s = input()
    t = input()
    min_val = 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
        min_val = min(cnt, min_val)
    print(min_val)


abc177b()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__=='__main__':
    s,t=readinput()
    ans=main(s,t)
    print(ans)

Submission status: Accepted

Solution code:
import sys


def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = float('inf')
    for i in range(N - M + 1):
        cnt = 0
        for j in range(M):
            if T[j] != S[i:(i + M)][j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 1000
if len(s) == len(t):
  cnt = 0
  for j in range(len(t)):
    if s[j] != t[j]:
      cnt += 1
  ans = cnt
for i in range(len(s)-len(t)):
  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()

lens=len(s)
lent=len(t)

imin=lent
for i in range(lens-lent+1):
    icnt=0
    for j in range(lent):
        if s[i+j]!=t[j]:
            icnt+=1
    imin=min(imin,icnt)   
print(imin)

Submission status: Accepted

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

ans = len(T)

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

    ans = min(ans, ans_offset)

print(ans)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s = input()
t = input()

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

print(ans)

Submission status: Accepted

Solution code:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
import time
# stdin = open("sample.txt")


MOD = int(1e9+7)
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    S = stdin.readline().rstrip()
    T = stdin.readline().rstrip()
    now = 0
    ans = INF
    for i in range(len(S)-len(T)+1):
        S2 = S[i:i+len(T)]
        now = 0
        for j in range(len(T)):
            if T[j] != S2[j]:
                now += 1
        ans = min(now,ans)
    print(ans)
main()

Submission status: Accepted

Solution code:
s = input()
t = input()
if t in s:
  print("0")
else:
  mindif = 1000
  for i in range(len(s)-len(t)+1):
    ss = s[i:i+len(t)]
    difs = 0
    for j in range(len(t)):
      if ss[j] != t[j]:
        difs += 1
    mindif = min(mindif,difs)
  print(mindif)

Submission status: Accepted

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

diff_min = len(t)
while len(s) >= len(t):
    diff = 0
    for i in range(len(t)):
        if s[i] != t[i]:
            diff += 1
    diff_min = min(diff_min, diff)
    s = s[1:]
print(diff_min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=input()
m=float("infinity")
for i in range(len(s)):
	count=0
	if i+len(t)<=len(s):
		for j in range(len(t)):
			if t[j]!=s[i+j]:
				count+=1
		m=min(m,count)
if t in s:
	m=0
print(m)

Submission status: Accepted

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

min_diff = len(t)

for i in range(len(s) - len(t) + 1):
    sub_s = s[i:i+len(t)]
    num_diff = 0
    for i in range(len(t)):
        num_diff += 0 if sub_s[i] == t[i] else 1

    min_diff = min(min_diff, num_diff)
    
print(min_diff)

Submission status: Accepted

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

ans = 10000

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

print(ans)

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
#print(S)
#print(T)
con=[0]*len(S)
for i in range(len(S)-len(T)+1):
    #print(i)
    for j in range(len(T)):
        if(S[i+j]==T[j]):
            con[i]=con[i]+1
print(len(T)-max(con))

Submission status: Accepted

Solution code:
from math import inf

S = input()
T = input()

best = inf
for i in range(len(S)):
    if i + len(T) <= len(S):
        diff = sum(1 for x, y in zip(S[i : i + len(T)], T) if x != y)
        best = min(diff, best)
print(best)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
from collections import defaultdict
import math
from bisect import bisect
input=stdin.readline
#def print(x):stdout.write(str(x)+'\n')
s=input().strip()
t=input().strip()
n=len(s)
m=len(t)
ans=m
for i in range(n-m+1):
    c=0
    for j in range(min(m,n)):
        if s[i+j]!=t[j]:
            c+=1
    ans=min(c,ans)
print(ans)

Submission status: Accepted

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

N = 10000
for i in range(len(S) - len(T)+ 1):
  s =S[i:(i+len(T))]
  n =0
  for k in range(len(T)):
    if s[k] !=  T[k]:
      n+= 1
  N  = min(N, n)
  
print(N)

Submission status: Accepted

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

ans = 1001

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

Submission status: Accepted

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

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

ans = len_t

for i in range(len_s - len_t + 1):
  u = s[i: i+len_t]
  d = sum(0 if c1 == c2 else 1 for c1, c2 in zip(t, u))
  ans = min(d, ans)

print(ans)

Submission status: Accepted

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

M= len(S)
N = len(T)
ans=0

for i in range(M-N+1):
    tmp=S[i:i+N]
    #print(tmp)
    cnt=0
    for j in range(N):
        if tmp[j]==T[j]:
            cnt +=1
    ans = max(ans,cnt)

print(N-ans)

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
    if ans>tmp:
        ans=tmp
print(ans)

Submission status: Accepted

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

cnt_min = len(T)
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
    cnt_min = min(cnt_min, cnt)

print(cnt_min)

Submission status: Accepted

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

min = len(t)
for i in range(len(s)-len(t)+1):
    dif = 0
    for j in range(len(t)):
        if t[j] != s[i+j]:
            dif += 1
    if dif < min:
        min = dif
    # print(dif)
# print()
print(min)

Submission status: Accepted

Solution code:
S = input()
T = input()
lenT = len(T)
lenS = len(S)
lsS = []
for i in range(lenS-lenT+1):
    lsS.append(S[i:i+lenT])
ans = 1000
for st in lsS:
    ii = 0
    for i in range(lenT):
        if st[i] != T[i]:
            ii += 1
    ans = min(ans,ii)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = input()
t = input()
min_count = 1000
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)
    if min_count == 0:
        break
print(min_count)

Submission status: Accepted

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

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

Submission status: Accepted

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

def c(s, t):
  #print(s)
  r = 0
  for i in range(n):
    if s[i] == t[i]:
      r += 1
  return n - r

ans = n
for i in range( len(S) - n + 1):
  temp = c(S[i:i+n],T)
  ans = min( ans, temp)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    T = input().rstrip()
    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)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 10000
if t in s:
    print(0)
    exit()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

S=input()
T=input()

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

ans=lt

for i in range(ls-lt+1):
    ss=S[i:i+lt]
    c=0
    for j in range(lt):
        if ss[j]!=T[j]: c+=1

    if c<ans: ans=c

print(ans)

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
c = list()
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            cnt = cnt + 1
        else:
            continue
    c.append(cnt)
print(len(t)-max(c))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
t = readline().rstrip().decode('utf-8')
ls = len(s)
lt = len(t)
ans = 10**18
for i in range(ls-lt+1):
    res = 0
    for j in range(lt):
        if s[i+j] != t[j]:
            res += 1
    ans = min(ans,res)

print(ans)

Submission status: Accepted

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

ans = 10000
for i in range(len(S)-len(T)+1):
    count = 0
    for elts, eltt in zip(S[i:i+len(T)], T):
        if elts != eltt:
            count += 1
    ans = min(ans, count)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

    min = len(t)

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

Submission status: Accepted

Solution code:
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
 
#maincode-------------------------------------------------

s = input()
t = input()
ans = 0

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

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

Submission status: Accepted

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

s = len(S)
t = len(T)

ans = 0

for i in range(s - t + 1):
    c = 0
    for j in range(t):
        if S[i + j] == T[j]:
            c += 1
    ans = max(ans, c)

print(t - ans)

Submission status: Accepted

Solution code:
I=lambda:list(map(int,input().split()))
s=list(input())
t=list(input())
ans=len(t)
for i in range(len(s)-len(t)+1):
	temp=s[i:i+len(t)]
	te=0
	for j in range(len(t)):
		if temp[j]!=t[j]:
			te+=1
	ans=min(te,ans)
print(ans)

Submission status: Accepted

Solution code:
s = input().strip()
t = input().strip()
R = 10**18
for i in range(len(s)-len(t)+1):
    r = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            r += 1
    R = min(r, R)
print(R)

Submission status: Accepted

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

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