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

max_match = 0

n = len(T)
m = len(S)

for i in range(m-n+1):
    tmp = 0
    for j in range(i,i+n):
        if S[j] == T[j-i]:
            tmp += 1
    if tmp > max_match:
        max_match = tmp

ans = n - max_match



print(ans)

Submission status: Accepted

Solution code:
def solve(string):
    s, t = map(list, string.split())
    ans = min(
        sum(1 if s[i + j] != t[j] else 0
            for j, _ in enumerate(t))
        for i in range(len(s) - len(t) + 1))
    return str(ans)

    pass


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
def solve(string):
    s, t = map(list, string.split())
    ans = len(t)
    for i in range(len(s)-len(t)+1):
        c = 0
        for j, _ in enumerate(t):
            c += 1 if s[i + j] != t[j] else 0
        ans = min(ans, c)
    return str(ans)

    pass


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
string1 = input()
string2 = input()

n, m = len(string1), len(string2)
best = float("inf")
for i in range(n - m + 1):
  current = string1[i:i+m]
  differences = 0
  for i in range(m):
    if current[i] != string2[i]:
      differences += 1
  best = min(differences, best)

if best == float("inf"):
  print(0)
else:
  print(best)

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline

s = input().strip()
t = input().strip()

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

def cnt(a,b):
    return sum(1 for aa,bb in zip(a,b) if aa != bb)

res = nt
for i in range(ns - nt + 1):
    res = min(res,cnt(s[i:i+nt],t))

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s, t = input(), input()
a = len(s)
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:
S = input()
T = input()
lens = len(S)
lent = len(T)
ans = []
for i in range(lens - lent + 1):
	ss = S[i:i+lent]
	count = 0
	for j in range(len(ss)):
		if(ss[j] != T[j]):
			count += 1
	ans.append(count)
print(min(ans))

Submission status: Accepted

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

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

if T in S:
    ans = 0
else:
    minimum = len(T)
    for i in range(iteration):
#         print('---------------')
        s = S[i:len(T)+i]
#         print(s)
#         print(T)
        count = 0
        for j in range(len(T)):
            if s[j] != T[j]:
                count += 1
#             print(count)
        minimum = min(minimum, count)
    ans = minimum
    
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ls = len(s)
lt = len(t)
min_count = 1000
for i in range(ls-lt+1):
  count = 0
  for j in range(lt):
    if s[i:i+lt][j] != t[j]:
      count += 1
  if min_count > count:
    min_count = count
print(min_count)

Submission status: Accepted

Solution code:
s = input()
t = input()
l = len(s)
m = len(t)
maxi = 0
for i in range(l-m+1):
    t1 = s[i:i+m]
    x = 0
    for j in range(m):
        if t1[j] == t[j]:
            x = x + 1
    if maxi < x:
        maxi = x

mini = m - maxi

print(mini)

Submission status: Accepted

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

Submission status: Accepted

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

res = len(T)

for i in range(len(S) - len(T) + 1):
    cnt = 0
    smallS = S[i:i+len(T)]
    for s, t in zip(smallS, T):
        if s == t:
            cnt += 1
    if (len(T) - cnt) < res:
        res = len(T) - cnt

print(res)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
lens = len(S)
lent = len(T)
ans = []

for i in range(lens-lent + 1):
      count = 0
      U = S[i: i+lent]
      for j in range(lent):
            if U[j] != T[j]:
                count += 1
      ans.append(count)
print(min(ans))

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
s = len(S)
t = len(T)
ans = []
for i in range(s-t+1):
    count = 0
    U = S[i:i+t]
    for j in range(t):
        if U[j] != T[j]:
            count += 1
    ans.append(count)
print(min(ans))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    S = input()
    T = input()

    #TがSの部分文字列になるようにSを書き換える

    N = len(S)
    M = len(T)
    L = N - M #Sを調べるループの回数
    #二重ループが許される
    ans = M
    for i in range(L+1): 
        #最大M個一致していない。
        cnt = M
        for j in range(M):
            if S[i+j] == T[j]: 
                cnt -= 1
        #最小を取る
        ans = min(ans, cnt)
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 1000
sub = 0
flag = False
for i in range(len(s)):
    if s[i] != t[sub]:
        sub = 0
        continue
    else:
        if sub == len(t) - 1:
            print(0)
            flag = True
            break
        sub += 1

if not flag:
    for i in range(len(s) - len(t) + 1):
        sub = 0
        an = 0
        for j in range(len(t)):
            if s[i + j] != t[sub]:
                an += 1
            sub += 1 
        ans = min(an, ans)

    print(ans)

Submission status: Accepted

Solution code:
def main():
    s = str(input())
    t = str(input())
    s_num = len(s)
    t_num = len(t)
    ans = []
    for i in range(s_num - t_num + 1):
        count = 0
        U = s[i:i + t_num]
        for j in range(t_num):
            if U[j] != t[j]:
                count += 1
        ans.append(count)
    print(min(ans))

main()

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
diff = len(S)-len(T)

count, best = 0, 0

for i in range(diff+1):
  
  s = S[i:]
  
  #print('s')
  #print(s)
  
  count = 0
  for j,k in zip(s,T):
    if j == k:
      count += 1
    if count > best:
      best = count

print(len(T)-best)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
s = len(S)
t = len(T)
ans = []
for i in range(s-t+1):
    count = 0
    U = S[i:i+t]
    for j in range(t):
        if U[j] != T[j]:
            count += 1
    ans.append(count)

print (min(ans))

Submission status: Accepted

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

n = len(s)
m = len(t)
ans = 10**9

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

print(ans)

Submission status: Accepted

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

S = str(input())
T = str(input())
mn = 100000

for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    x = count_diff(s,T)
    mn = min(mn,x)

print(mn)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

#検索される文字列
S = input()
#検索する文字列
T = input()
min = len(T)


for Snum in range(len(S)- len(T) + 1):
    count = 0
    for i in range(len(T)):
        if S[Snum + i] != T[i]:
            count += 1
    if count < min:
        min = count
print(min)

Submission status: Accepted

Solution code:

st1 = input()
st2 = input()
li = []
count = 0

k = 0

for i in range(len(st1)-len(st2)+1):
    for s2 in st2:
        if s2 in st1[i+k]:
            count += 1
        k += 1
    li.append(count)
    count = 0
    k = 0

print(len(st2) - max(li))

Submission status: Accepted

Solution code:
S=input()
T=input()
lenS=len(S)
lenT=len(T)
count=[]

for i in range(lenS-lenT+1):
    c=0
    for j in range(lenT):
        if T[j]!=S[i+j]:
            c=c+1
        j=j+1
    count.append(c)
    i=i+1
print(min(count))

Submission status: Accepted

Solution code:
def main(S, T):
    ans = len(T)
    for w in range(len(S)-len(T)+1):
        tmp = len(T)
        for s, t in zip(S[w:w+len(T)], T):
            if s == t:
                tmp -= 1
        if tmp < ans:
            ans = tmp
    return ans

if __name__ == '__main__':
    S = input()
    T = input()
    ans = main(S, T)
    print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
T = list(t)
sl = len(s)
tl = len(t)
ans = 10**18

for i in range((sl-tl)+1):
  cnt = 0
  S = list(s[i:i+tl])
  for a,b in zip(S,T):
    if a != b:
      cnt += 1
  if ans > cnt:
    ans = cnt
print(ans)

Submission status: Accepted

Solution code:
# abc177_b
s, t, match = input(), input(), 0
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
	if match < temp:
		match = temp
print(len(t) - match)

Submission status: Accepted

Solution code:
S=input()
T=input()
N=len(S)
n=len(T)
ans=n
for i in range(N-n+1):
    ans=min(ans,sum(S[i+j]!=T[j] for j in range(n)))
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
def i():
    return stdin.readline().rstrip()
def mi():
    return map(int(),stdin.readline().rstrip().split())
def li():
    return list(map(int,stdin.readline().rstrip()))
ans=10000
s=i()
t=i()
ls=len(s)
lt=len(t)
l=ls-lt
for i in range(l+1):
    cnt=0
    for j in range(lt):
        if s[i+j]!=t[j]:
            cnt+=1
    if cnt<ans:
        ans=cnt

print(ans)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
m=len(t)
for i in range(len(s)-len(t)+1):
    ma=len(t)
    for j in range(len(t)):
        if s[i+j]==t[j]:
            ma-=1
    if ma <m:
        m=ma
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import itertools


# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


s = input()
t = input()

answer = len(t)
for index in range(len(s) - (len(t) - 1)):
    d = s[index:index+len(t)]
    match = 0
    for idx in range(len(t)):
        if t[idx] == d[idx]:
            match += 1

    answer = min(answer, len(t) - match)

print(answer)

Submission status: Accepted

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

import math


def calculate(s, t):
    lenS = len(s)
    lenT = len(t)

    count = math.inf

    for i in range(lenS - lenT + 1):
        value = s[i:i + lenT]

        tmp = 0
        isOk = True
        for j in range(len(value)):
            if value[j] != t[j]:
               tmp += 1
               if tmp > count:
                   isOk = False
                   break

        if isOk:
            count = min(count, tmp)

    print(count)
calculate(S, T)

Submission status: Accepted

Solution code:
S = input()
T = input()
N, M = len(S), len(T)
ans = 1000
for i in range(N - M + 1):
	sub = S[i:i + N]
	temp = 0
	for j in range(M):
		if sub[j] != T[j]:
			temp += 1
	if (temp < ans):
		ans = temp
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):
    tmp_cnt = 0
    tmp_s = s[i:i + len_t]
    for c1, c2 in zip(tmp_s, t):
        if c1 != c2:
            tmp_cnt += 1
    ans = min(ans, tmp_cnt)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
s_l = len(s)
t_l = len(t)
s_l -= (t_l-1)
if(t in s):
    print(0)
    exit()

ma = 0
for si in range(s_l):
    cnt = 0
    for ti in range(t_l):
        if(s[si+ti]==t[ti]):
            cnt += 1
    ma = max(ma,cnt)

print(t_l - ma)

Submission status: Accepted

Solution code:
s=input()
t=input()
scorelist=[]
for i in range(len(s)-len(t)+1):
  S=s[i:i+len(t)]
  score=0
  for j in range(len(t)):
    if S[j]!=t[j]:
      score+=1
  scorelist.append(str(score))
point=min(scorelist)
print(point)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 1000000
for i in range(len(S)-len(T)+1):
    U = S[i:i + len(T)]
    score = 0
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Submission status: Accepted

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

# N = int(input())
S = input()
T = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# 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

ma = 0
s = len(S)
t = len(T)
for i in range(s - t + 1):
    cnt = 0
    for j in range(t):
        if S[i + j] == T[j]:
            cnt += 1
    if cnt > ma:
        ma = cnt
print(t - ma)

Submission status: Accepted

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

s_l = len(s)
t_l = len(t)

ans = len(t)

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


print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    l_s = len(S)
    l_t = len(T)

    cnt_list = []
    for i in range(l_s - l_t + 1):
        cnt = 0
        S_ = S[i: i+l_t]
        for j in range(l_t):
            if S_[j] != T[j]:
                cnt += 1
        cnt_list.append(cnt)

    ans = min(cnt_list)
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding:UTF-8
import sys


def resultSur97(x):
    return x % (10 ** 9 + 7)


if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    s = input()    # 数字
    t = input()    # 数字

    # ------ 処理 ------#
    sMin = len(t)
    for i in range(len(s)-len(t)+1):
        str1 = s[i:i+len(t)]
        count = 0
        for j in range(len(str1)):
            if str1[j] != t[j]:
                count += 1
        if sMin > count:
            sMin = count

    # ------ 出力 ------#
    print("{}".format(sMin))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

lt = len(t)
ans = lt

for i in range(len(s) - lt + 1):
    s_ = s[i: i + lt]
    diff = 0
    for x, y in zip(s_, t):
        if x != y:
            diff += 1
    ans = min(ans, diff)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
ls = len(S)
lt = len(T)
ans = lt
for i in range(ls):
    temp = 0
    if i+lt > ls:
        break
    subS = S[i:i+lt]
    for ss, st in zip(subS, T):
        if ss != st:
            temp += 1
    ans = min(ans, temp)
print(ans)

Submission status: Accepted

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

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

def f(k):
    c = 0
    for i in range(len(t)):
        if s[k + i] == t[i]:
            c += 1
    return c

maxi = f(0)
for i in range(len(s) - len(t) + 1):
    if f(i) > maxi:
        maxi = f(i)

print(len(t) - maxi)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 99999999
for i in range(len(S)-len(T)+1):
    word = S[i:i+len(T)]
    cnt = 0
    for j in range(len(word)):

        if word[j]!=T[j]:
            cnt+=1
    ans = min(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
#B問題

#文字列のSの先頭から、順にT文字ずつ照合して行って、一番取り替える文字数が少ないものを出力
#計算量は|S||T| (あるT文字に対し、|S|-|T|-1回作業が必要)

# 入力
S = input()
T = input()

#最初に巨大な値を用意することで、最小値をどんどん更新して行く。

ans = 1000000

for i in range(len(S) - len(T) + 1):
    #取り換え文字数の格納
    score = 0
    # Sのi文字目から連続するlen(T)文字を、Uとします
    # : は「スライス」と呼ばれる記法。始点:終点　と表記し、始点から終点までのインデックス番号の文字列を抽出。
    U = S[i:i + len(T)]
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)
    
print(ans)

Submission status: Accepted

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

    mn = 10**5
    for i in range(len(s)-len(t)+1):
        result = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                result += 1
        mn = min(result, mn)

    print(mn)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
if T in S:
  print(0)
  exit()
ans, substr = 0, ""
for i in range(len(S) - len(T) + 1):
  substr = S[i: i + len(T)]
  cnt = 0
  for s, t in zip(substr, T):
    if s == t:
      cnt += 1
  ans = max(ans, cnt)
  if ans == len(T) - 1:
    break
print(len(T) - ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 1000000  # 
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)] 
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Submission status: Accepted

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


def solve(S: str, T: str):
    min_change = 100000000

    S = [s for s in S]
    T = [t for t in T]

    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if j == 0:
                c = 0
            if len(S) <= i + j:
                break
            if S[i+j] != t:
                c += 1
            if len(T) == j + 1:
                min_change = min(min_change, c)

    print(min_change)
    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()
lent=len(t)
num=lent
ls=[]
count=0

for i in range(len(s)-lent+1):
  st=s[i:i+num]
  num+=1
  
  for j in range(lent):
    if st[j]!=t[j]:
      count+=1
      
  ls.append(count)
  count=0
  
print(min(ls))

Submission status: Accepted

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

ls = len(s)
lt = len(t)
ret = lt
for i in range(ls+1 - lt):
  diff = 0
  for j in range(lt):
    diff += (t[j] != s[i+j])
  if diff == 0:
    ret = diff
    break
  if diff < ret:
    ret = diff
print(ret)

Submission status: Accepted

Solution code:
s = input()
t = input()
a = len(s) - len(t) + 1
c1= 0

for i in range(a):
    c2 = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            c2 += 1
        else:
            continue
    c1 = max(c1,c2)


print(len(t)-c1)

Submission status: Accepted

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

print(cm)

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    s = str(stdin.readline().rstrip())
    t = str(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = len(t)
    for i in range(len(s)-len(t) + 1):
        test = s[i:i+len(t)]
        a = len(t)
        for j in range(len(t)):
            if test[j] == t[j]:
                a -= 1
        ans = min(ans,a)
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
S,T = open(0).read().split()
ls = len(S)
lt = len(T)
ans = float('inf')
for i in range(ls-lt+1):
    temp = S[i:i+lt]
    t2 = 0
    for j in range(lt):
        if temp[j] != T[j]:
            t2 += 1
    ans = min(ans,t2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline



S = input()
T = input()

S = S.replace('\n','')
T = T.replace('\n','')

s_list = list(S)
t_list = list(T)

itti = 0
min_count = 10**5
for i in range(len(s_list)):
    if i + len(t_list) > len(s_list):
        break
    count = 0
    for j in range(len(t_list)):
        if not s_list[i+j] == t_list[j]:
            count += 1
    min_count = min(count,min_count)

print(min_count)

Submission status: Accepted

Solution code:
# coding: utf-8

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

    ans = len(t)
    
    for i in range(len(s) - len(t) + 1):
        a = s[i:i+len(t)]
        # print(a, t)
        ans_list = [1 for x, y in zip(a, t) if x!=y]
        tmp_ans = sum(ans_list)
        ans = min(ans, tmp_ans)
        
        if ans == 0:
            break
        
    print(ans)
    
        

main()

Submission status: Accepted

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

Submission status: Accepted

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

lens = len(S)
lent = len(T)

cur_ans = 999999999999

for i in range(lens - lent + 1):
    local_ans = 0
    for j in range(lent):
        if T[j] != S[i+j]:
            local_ans += 1
    
    cur_ans = min(cur_ans, local_ans)

print(cur_ans)

Submission status: Accepted

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

ans=0

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

print(len(T)-ans)

Submission status: Accepted

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

min = 10000000

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

S = input()
T = input()

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

print(ans)

Submission status: Accepted

Solution code:
S=input()
T=input()
A=[]
for i in range(len(S)-len(T)+1):
    ans = 0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            ans += 1
    A.append(ans)

print(min(A))

Submission status: Accepted

Solution code:
S, T = [input() for i in range(2)]
ans = float("inf")
for start in range(len(S) - len(T) + 1):
    diff = 0
    for t, s in zip(T, S[start:]):
        if t != s:
            diff += 1
    ans = min(ans, diff)
print(ans)

Submission status: Accepted

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

def d(s,t):
  return sum([1 if i!=j else 0 for i,j in zip(s,t)])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

lens = len(S)
lent = len(T)

ans = lent

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

  if count < ans:
    ans = count
    
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
a = []
for i in list(s):
    a.append(i)
b = []
for j in list(t):
    b.append(j)
c = len(a)
d = len(b)
w = 1000
for k in range(c-d+1):
    e = a[k:k+d]
    f = 0
    for l in range(d):
        if e[l] != b[l]:
            f= f+1
    if w > f:
         w= f
print(w)

Submission status: Accepted

Solution code:
s = input()
t = input()
cnt = 0
ans = 0
while cnt < len(s) - len(t) + 1:
    chk = 0
    for i, j in zip(range(cnt,cnt+len(t)),range(len(t))):
        if s[i] == t[j]:
            chk += 1
    ans = max(ans,chk)
    cnt += 1

print(len(t) - ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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(min(C))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
lens = len(S)
lent = len(T)

ans = -1
for i in range(lens-lent+1):
    S2 = S[i:i+lent]
    diff = 0
    for j in range(lent):
        if S2[j] != T[j]:
            diff += 1
    if ans == -1:
        ans = diff
    else:
        if ans > diff:
            ans = diff
print(ans)

Submission status: Accepted

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

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

minc = 1000

for i in range(sl):
    if i+tl-1 >= sl:
        break
    else:
        str1 = S[i:i+tl]
        count=0
        for j in range(tl):
            if str1[j] != T[j]:
                count+=1
        if count < minc:
            minc = count

print(minc)