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


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    s = ns()
    t = ns()
    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, len(t) - tmp)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = len(S) - len(T)

m = 10000
for i in range(c + 1):
    count = 0
    for s, t in zip(S[i:], T):
        if s != t:
            count += 1
    m = min(m, count)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    s = input()
    t = input()

    num = len(t)
    ans = 1000

    for i in range(0, len(s) - num + 1):
        tmp = 0
        for a, b in zip(s[i:(i + num)], t):
            if a != b:
                tmp += 1

        if tmp < ans:
            ans = tmp

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """cabacc
abc"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """codeforces
atcoder"""
        output = """6"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    s_s = input()
    t_s = input()

    ans = 0

    for i in range(len(s_s) - len(t_s) + 1):
        work = 0

        for j in range(len(t_s)):
            if s_s[i + j] == t_s[j]:
                work += 1
        ans = max(ans, work)

    print(len(t_s) - ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """cabacc
abc"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """codeforces
atcoder"""
        output = """6"""
        self.assertIO(test_input, output)

    # 自作テストパターン
    def test_original(self):
        pass


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

r = []
n = len(s) - len(t) + 1
# print(n)
for i in range(n):
    w_w = len(t)
    for j in range(len(t)):
        # print(s[i+j], t[j])
        if s[i+j] == t[j]:
            w_w -= 1
    # print(w_w)
    r.append(w_w)
print(min(r))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    t = input()
    ans = 10**18
    for i in range(len(s) - len(t) + 1):
        a = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                a += 1
        if ans > a:
            ans = a

    print(ans)

resolve()

Submission status: Accepted

Solution code:
s=input()
t=input()
u=[0]*(len(s)-len(t)+1)

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

Submission status: Accepted

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

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

ans = 1000

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

print(ans)

Submission status: Accepted

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

l=[False]*len(s)
c=0
m=0
for x in range(len(s)-len(t)+1):
     c=0
     for y in range(len(t)):
          w=s[x:x+len(t)]
          if w[y]==t[y]:c+=1
     m=max(m,c)
print(len(t)-m)

Submission status: Accepted

Solution code:
s,t=open(0).read().split()
res=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
  res=min(len(t)-cnt,res)
print(res)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
u = len(s) - len(t) + 1

ans = 1000

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = np.array(list(readline().rstrip()), np.int32)
T = np.array(list(readline().rstrip()), np.int32)

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

x = 0
for s in range(LS - LT + 1):
    same = np.sum(S[s:s + LT] == T)
    x = max(x, same)

print(len(T) - x)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()
T=input()
cnt_min=1001
for i in range(len(S)-len(T)+1):
  #部分文字列を切り出す
  s=S[i:i+len(T)]
  cnt=0
  for i,s_ in enumerate(s):
    if T[i] != s_:
      cnt+=1
  if cnt_min > cnt:
    cnt_min = cnt

print(cnt_min)

Submission status: Accepted

Solution code:
s = input()
t = input()
lent = len(t)
ans = []
if len(s) == lent:
    ans1 = 0
    for s1, t1 in zip(s, t):
        ans1 += (s1==t1)
    ans.append(ans1)
else:
    for i in range(len(s) - lent):
        ss = s[i:i+lent]
        ans1 = 0
        for s1, t1 in zip(ss, t):
            ans1 += (s1==t1)
        ans.append(ans1)
print(lent-max(ans))

Submission status: Accepted

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

min = 10000
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
  
  if min > count:
    min = count

print(min)

Submission status: Accepted

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

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

print(min_score)

Submission status: Accepted

Solution code:
s = input()
t = input()
times = len(s) - len(t) + 1
ans = len(t)
if t in s:
  ans = 0
else:
  for i in range(times):
    ans_tmp = 0
    for j in range(len(t)):
      if t[j] != s[i+j]:
        ans_tmp += 1
    if ans_tmp <= ans:
      ans = ans_tmp
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
cnt=0
newT=[]
ans=[]
for i in range(len(s)):
    try:
        cnt=0
        for j in range(len(t)):
            if s[j+i]==t[j]:
                cnt+=1
        
        ans.append(len(t)-cnt)
    except:
        break

print(min(ans))

Submission status: Accepted

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

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

change = l_t
for i in range(l_s - l_t + 1):
    change_temp = 0
    for j in range(l_t):
        if s[i+j] != t[j]:
            change_temp += 1

    change = min(change, change_temp)

print(change)

Submission status: Accepted

Solution code:
def itti(S, T):
    ans = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            ans += 1
    return ans

# print('input >>')
S = input()
T = input()

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

# print('-----output-----')
print(len(T)-ans)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
# print(s,t)

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

print(len(t)-m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S= list(input())
T= list(input())

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

print(len(T) - ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
n, m =  len(S), len(T)
ans = n
for i in range(n - m + 1):
    cnt = 0
    subS = S[i: i + m]
    for s, t in zip(subS, T):
        if s != t:
            cnt += 1
    if ans > cnt:
        ans = cnt
print(ans)

Submission status: Accepted

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

l_st = len(s) - len(t) + 1
l_t = len(t)

ans = l_t
for _ in range(l_st):
    mx = l_t
    for i in range(l_t):
        if s[_+i] == t[i]:
            mx -= 1
        ans = min(ans, mx)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
def count(x, y):
    cnt = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            cnt += 1
    return cnt

ans = 0
l_T = len(T)
l_S = len(S)
for i in range(l_S - l_T + 1):
    tmp_str = S[i:i+l_T]
    tmp_ans = count(T, tmp_str)
    ans = max(ans, tmp_ans)
ans = l_T - ans
print(ans)

Submission status: Accepted

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

S = readline().strip()
T = readline().strip()

s = len(S)
t = len(T)
ans = t
for i in range(0, s-t+1):
  n = t
  for j in range(t):
    if S[i+j] == T[j]:
      n -= 1
  if n < ans:
    ans = n
  if ans == 0:
    break
print(ans)

Submission status: Accepted

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

ans = len(T)

for i in range(len(S)-len(T)+1):
    tmp = ans
    tmp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp
    if ans == 0:
        break
print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
  count = 1001
  s = input()
  t = input()
  if(len(s) == len(t)):
    count = min(count,diff(s,t))
  for i in range(len(s)-len(t)):
    count = min(count,diff(s[i:i+len(t)],t))
  print(count)

Submission status: Accepted

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

ans=len(S)
for i in range(len(S)):
    if len(S)-i<len(T):
        break
    tmp = 0
    for j in range(len(T)):
        tmp += not T[j]==S[i+j]
    ans = min(ans,tmp)

print(ans)

Submission status: Accepted

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

l=len(s)-len(t)
mindiff=float("inf")
for i in range(l+1):
  ss=s[i:i+len(t)]
  cnt=0
  for j,c in enumerate(t):
    if ss[j]!=c:
      cnt+=1
  mindiff=min(mindiff,cnt)
print(mindiff)

Submission status: Accepted

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

def judge(s0, s1):
    ret = 0
    for i in range(len(s0)):
        if s0[i] != s1[i]:
            ret += 1
    return ret

for i in range(len(s) - len(t) + 1):
    ans = min(ans, judge(s[i:i + len(t)], t))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
slen = len(s)
tlen = len(t)
min_diff = tlen

for si in range(slen - tlen + 1):
    diff = 0
    for ti in range(tlen):
        if s[si+ti] != t[ti]:
            diff += 1
    if diff < min_diff:
        min_diff = diff

print(min_diff)

Submission status: Accepted

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


ans = 1000

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

Submission status: Accepted

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

    res=len(T)
    for i in range(len(S)-len(T)+1):
        res_=0
        for j in range(len(T)):
            if T[j]!=S[j+i]:
                res_+=1
        if res_<=res:
            res=res_

    print(res)

if __name__=="__main__":
    main()

Submission status: Accepted

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

ans = n
for i in range(n-m+1):
    ts = s[i:i+m]
    tmp = 0
    for tss,tt in zip(ts,t):
        if tss != tt:
            tmp += 1
    ans = min(ans,tmp)

print(ans)

Submission status: Accepted

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

ls=len(S)
lt=len(T)
commons=[]

for i in range(ls-lt+1):
    x=S[i:i+lt]
    count=0
    for j in range(lt):
        if x[j]==T[j]:
            count+=1
    commons.append(lt-count)
    
print(min(commons))

Submission status: Accepted

Solution code:
import numpy as np

s = input()
t = input()

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

ma = 0
for i in range(len_s - len_t + 1):
    ma = max(ma, np.sum(np.array(list(s[i: i + len_t])) == np.array(list(t))))

ans = len_t - ma

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
t = len(T)
def check(a,b):
    temp = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            temp += 1
    return temp

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import inf


def main():
    s = input()
    t = input()
    tlen = len(t)
    min = inf
    for i in range(len(s) - tlen + 1):
        count = 0
        for j, c in enumerate(s[i:i + tlen]):
            if not t[j] == c:
                count += 1
        if count < min:
            min = count
    print(min)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
T = input()
L,l = len(S),len(T)
ans = 1000
for i in range(l,L+1):
    s = S[i-l:i]
    cnt = 0
    for j in range(l):
        if s[j] != T[j]:
            cnt += 1
    if ans > cnt:
        ans = cnt
print(ans)

Submission status: Accepted

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

diff = len(S) - len(T)
ans = 99999

for i in range(diff + 1):
  t_s = len(T)
  moto = S[i:i+t_s]
  saki = T

  num = 0
  for j in range(len(T)):
    if moto[j] != saki[j]:
      num = num + 1

  if num <= ans:
    ans = num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

min_cnt=1000
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)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
slist=list(input())
tlist=list(input())
s=len(slist)
t=len(tlist)
kazu=s-t+1
ans=10000000000

for i in range(kazu):
    kari=[]
    an=0
    for j in range(i,i+t):
        kari.append(slist[j])
    for k in range(t):
        if tlist[k]!=kari[k]:
            an+=1
    if ans>an:
        ans=an

print(ans)

Submission status: Accepted

Solution code:
s = input()
lens = len(s)
t = input()
lent = len(t)
ss = set()
for i in range(lens - lent + 1):
    ss.add(s[i:i+len(t)])
ans = float('inf')

for text in ss:
    tmp = 0
    for i in range(lent):
        if text[i] != t[i]:
            tmp += 1
    ans = min(ans,tmp)

print(ans)

Submission status: Accepted

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

    minCount = l

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

    print(minCount); 
    


if __name__ == '__main__':
    main();

Submission status: Accepted

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

def main():
    s = input() + "#"
    t = input()
    m = len(s)
    n = len(t)

    c_max = 0
    for i in range(m-n):
        cnt = 0
        for j in range(n):
            if s[i+j] == t[j]:
                cnt += 1
        if cnt > c_max:
            c_max = cnt

    print(n - c_max)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

answer = 100000
for i in range(len(S) - len(T) + 1):
    distance = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            distance += 1
    if answer > distance:
        answer = distance
print(answer)

Submission status: Accepted

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


patan = len(S)-len(T)+1
min_change = 1000
for p in range(patan):
  S_sub = S[p:p+len(T)]
  not_match = len([1 for s,t in zip(S_sub, T) if s!=t])
  if not_match < min_change:
    min_change = not_match

print(min_change)

Submission status: Accepted

Solution code:
S=input()
T=input()
C=[]
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
    C.append(cnt)
print(len(T)-max(C))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
s = input()
t = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

s = [ch for ch in s]
t = [ch for ch in t]

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

Submission status: Accepted

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

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

match = 0
for i in range(lenS - lenT + 1):
    cnt = 0
    for j in range(lenT):
        if S[i + j] == T[j]:
            cnt += 1
    match = max(match, cnt)

print(lenT - match)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
k=0
for i in range(len(s)-len(t)+1):
  a=s[i:len(t)+i]
  kari=0
  for j in range(len(t)):
    if a[j]==t[j]:
      kari+=1
  k=max(kari,k)
print(len(t)-k)

Submission status: Accepted

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

s_len =	len(s)
max=10000
for i in range(s_len-t_len+1):
  c=0
  for j in range(t_len):
    if s[i+j]!=t[j]:
      c+=1
  if c < max:
    max=c

print(max)

Submission status: Accepted

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

    slen = len(s)
    tlen = len(t)
    
    ans = 10 ** 10

    for i in range(slen - tlen+1):
        tmp = 0
        for j in range(tlen):
            if s[i+j] != t[j]:
                tmp += 1
        if ans > tmp:
            ans = tmp
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

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

res = []

x, y = len(s), len(t)
for i in range(0, x):
	c = 0
	sub = s[i:i+y]
	if len(sub) == y:
		for a, b in zip(sub, t):
			if a != b:c+=1
		res += [c]
	else:
		break
print(min(res))

Submission status: Accepted

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

min_count = 10000
for i in range(len(S)):
    count = 0
    check = False
    for j in range(len(T)):
        if i + j == len(S):
            check = True
            break
        if S[i + j] == T[j]:
            continue
        else:
            count += 1
    # print(count)
    if check:
        break

    min_count = min(count, min_count)
print(min_count)

Submission status: Accepted

Solution code:
S=input()
T=input()
ans=float("inf")
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) if ans<float("inf") else print(len(T))

Submission status: Accepted

Solution code:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


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

    res = len(T)
    for i in range(len(S) - len(T) + 1):
        res = min(res, sum(1 if s != t else 0 for s, t in zip(S[i:], T)))

    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a=input()
b=input()
al=len(a)
bl=len(b)
mn=1000
cnt=0
for i in range(0,al-bl+1):
    cnt=0
    for j in range(0,bl):
        if a[i+j]!=b[j]:
            cnt=cnt+1
    if mn>cnt:
        mn=cnt
print(mn)

Submission status: Accepted

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

min=1000

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

print(min)

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

print(len(t)-cnt)

Submission status: Accepted

Solution code:
S=list(map(str,input()))
T=list(map(str,input()))

#print(S)
#print(T)

s=len(S)
t=len(T)
m=1001;e=0
for i in range(s-t+1):
  #print(s,t,i)
  for j in range(t):
    if S[i+j]!=T[j]:
      e=e+1
  if e<m:
    m=e
  e=0
print(m)

Submission status: Accepted

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

count = len(s) - len(t) + 1
ans = 10**6
for i in range(count):
    a = 0
    for j in range(len(t)):
        #print(s[j+i], t[j])
        if s[j+i] != t[j]:
            a += 1
    if a < ans:
        ans = a
print(ans)

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]
    t = lines[1]

    return (s, t)


def solve(s, t):


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

        if cnt < count:
            count = cnt 


    return count


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s = input()
t = input()
if t in s:
    print(0)
    sys.exit()

lenS = len(s)
lenT = len(t)

ans = lenT

for i in range(lenS-lenT+1):
    ss = s[i:i+lenT]
    num = 0
    for j in range(lenT):
        if ss[j] != t[j]:
            num += 1
    # print(ss, num)
    ans = min(num, ans)

print(ans)

Submission status: Accepted

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

    c = 0
    ans = len(t)
    for i in range(len(s)-len(t)+1):
        c = 0
        now = i
        for tt in t:
            if s[now] != tt:
                c += 1
            now += 1
        ans = min(ans,c)
    print(ans)
if __name__=='__main__':
    main()

Submission status: Accepted

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

ans = len(T)
num = len(S)-len(T)+1
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)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

# 2darray [[0] * 4 for i in range(3)]
# import itertools

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
s = np.array(list(input()))
t = np.array(list(input()))

t_len = len(t)
chk_num = len(s) - t_len

change_num = t_len
for i in range(chk_num + 1):
    tmp = t_len - np.count_nonzero(s[i: t_len + i] == t)
    change_num = min(tmp, change_num)

print(change_num)