Problem:


Score : 200 points

Problem Statement

Given are two strings S and T.

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

At least how many characters do we need to change?

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

Constraints

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

The length of T is at most that of S.

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

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

Sample Input 1

cabacc
abc

Sample Output 1

1

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

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

Sample Input 2

codeforces
atcoder

Sample Output 2

6



Sample input:
cabacc
abc


Sample output:
1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())

t = str(input())

n = len(s)
m = len(t)

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

print(c)

Submission status: Accepted

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

cnt = 0
for i in range(1+len(s)- len(t)):
    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()
import sys
a=0
b=[]
c=[]
if len(s)==len(t):
    for i in range(len(s)):
        if s[i]!=t[i]:
            a+=1
    print(a)
    sys.exit()
for i in range(len(s)-len(t)):
    b.append(s[i:len(t)+i])


for i in range(len(b)):
    for j in range(len(b[i])):
        if b[i][j]!=t[j]:
            a+=1
    c.append(a)
    a=0
        
print(min(c))

Submission status: Accepted

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

match_list = [0]*len(S)

for i in range(len(S)-len(T)+1):
  for j in range(len(T)):
    if S[i+j] == T[j]:
      match_list[i] += 1

print(len(T) - max(match_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=input()
num=len(s)-len(t)
res=[]
for n1 in range(0,num+1):
    count=0
    for n2 in range(0,len(t)):
        if(t[n2]!=s[n1+n2]):
            count+=1
    res.append(count)
print(min(res))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys

# 標準入力を取得
S = input()
T = input()

# 求解処理


def get_match_count(s1: str, s2: str) -> int:
    match_count = 0
    for c1, c2 in zip(s1, s2):
        if c1 == c2:
            match_count += 1
    return match_count


N = len(S)
M = len(T)
ans = sys.maxsize
for i in range(N - M + 1):
    ans = min(ans, M - get_match_count(S[i:i + M], T))

# 結果出力
print(ans)

Submission status: Accepted

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

ans=1000

for i in range(len(s)):
    x=0
    if i+len(t)<=len(s):
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                x+=1
        if x<ans:
            ans=x
    else:
        break
print(ans)

Submission status: Accepted

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

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

print(lenT - ansA)

Submission status: Accepted

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

t = T
cnt = len(T)

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

for i in range(N-M+1):
    check = S[i:i+M]
    ck = 0
    for j in range(M):
        if check[j] != T[j]:
            ck += 1
    if ck < cnt:
        cnt = ck

print(cnt)

Submission status: Accepted

Solution code:
a=list(input())
b=list(input())
l=[]
for i in range(len(a)-len(b)+1):
  c=0
  for j in range(len(b)):
    if a[j+i]==b[j]:
      c+=1
  l.append(c)
print(len(b)-max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
min = len(S)
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().strip()
T = input().strip()

l = len(T)

def diff(s):
	return sum([s[i] != T[i] for i in range(l)])

print(min([diff(S[i:i + l]) for i in range(len(S) - l + 1)]))

Submission status: Accepted

Solution code:
# coding: utf-8
from functools import reduce
from queue import Queue
from collections import deque

s = input()
t = input()

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

print(saisho_kyori)

Submission status: Accepted

Solution code:
from itertools import combinations
import math
S = input()
T = input()
#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))
c = 0
for i in range(len(S)-(len(T)-1)):
    cc = 0
    for t in range(i, i+len(T)):
        if S[t] == T[t-i]:
            cc += 1
    if c<cc:
        c=cc
print(len(T)-c)

Submission status: Accepted

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

s = list(s)
s.append("0")
t = list(t)
roop = len(s)-len(t)
cc = []
for i in range(roop):
  c = 0
  tmp = []
  tmp = s[i:len(t)+1+i]
  for i in range(len(t)):
    if tmp[i] == t[i]:
      c += 1
  cc.append(c)

ma = max(cc)
a = cc.index(ma)
tmp = s[a:a+1+len(t)]
ans = 0

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

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
ans = 10**9
for i in range(0,len(S)-len(T)+1):
  cnt = 0
  for j in range(len(T)):
    if T[j] != S[i+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):
    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()

count = 0
ans = 0

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

print(len(t) - ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
import difflib


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    S = ST()
    T = ST()
    m = 0
    for i in range(len(S)-len(T)+1):
        mn = 0
        for j in range(len(T)):
            if S[i+j] == T[j]:
                mn += 1
        m = max(m, mn)
    print(len(T) - m)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

scnt = len(s)
tcnt = len(t)

change = 10**3

for i in range (0, scnt - tcnt + 1):
  cnt = 0
  for j in range(tcnt):
    if s[i+j] != t[j]:
      cnt += 1
  if change > cnt:
    change = cnt

print(change)

Submission status: Accepted

Solution code:
S = input()
T = input()
max = 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 max > count:
    max = count
print(max)

Submission status: Accepted

Solution code:
s= input()
t= input()
len_diff= len(s)- len(t)

top=0
for i in range(len_diff+1):
  test= s[i:]
  count=0
  for j in range(len(t)):
    if test[j]==t[j]:
      count+=1
  if count>top:
    top= count

print(len(t)-top)

Submission status: Accepted

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

change_num_array = []
for j in range(0, len(S)-len(T)+1):
    change_num = 0
    for i in range(len(T)):
        if S[j+i] != T[i]:
            change_num += 1
    change_num_array.append(change_num)
print(min(change_num_array))

Submission status: Accepted

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

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


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

ans = 1001
for i in range(ls - lt + 1):
    cnt = 0
    for j, t in enumerate(T):
        if S[i + j] != t:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
def Substring():
    
    str1 = str(input())
    
    str2 = str(input())

    count_list = []

    for i in range(len(str1) - len(str2) + 1):
        
        count = len(str2)
        
        for j in range(len(str2)):
                        
            if str1[i + j] == str2[j]:
                
                count = count - 1

        count_list.append(count)
        
    print(min(count_list))
        
if __name__ == '__main__':
    Substring()

Submission status: Accepted

Solution code:
def cin():  return list(map(int,input().split()))

S = input()
T = input()

ans = 10 ** 9 + 7
l1 = len(S)
l2 = len(T)
for i in range(l1 - l2 + 1):
    cnt = 0
    for j in range(l2):
        if S[i + j] != T[j]:  cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def solver(S,T):
    search_len = len(T)
    times = len(S) - len(T) + 1
    min = 1000
    for i in range(times):
        diff = diff_counter(S[i:search_len+i],T)
        if diff < min:
            min = diff
    return min
def diff_counter(S,T):
    counter = 0
    for i in range(len(S)):
        Si = S[i]
        Ti = T[i]
        if Si != Ti:
            counter += 1
    return counter
S = input()
T = input()
print(solver(S,T))

Submission status: Accepted

Solution code:
###############################################
#                                             #
#   author: raghav_0901 (Raghav Dalmia)       #
#   updated on: 29-08-2020,  5:45:07 pm IST   #
#                                             #
###############################################

from math import *


def _in():
    arr = input().split(' ')
    return arr[0] if len(arr) == 1 else arr


def numCng(s, t):
    if(len(s) != len(t)):
        return 10**9
    cnt = 0
    for i in range(len(s)):
        if(s[i] != t[i]):
            cnt = cnt + 1
    # print(s, t, cnt)
    return cnt


if __name__ == "__main__":
    s = input()
    t = input()
    n, m = len(s), len(t)
    ans = m
    for i in range(n - m + 1):
        ans = min(ans, numCng(s[i:i + m], t))
    print(ans)

Submission status: Accepted

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

l = len(S) - len(T)
f = len(T)

for i in range(l+1):
    temp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            temp += 1
    if f > temp:
        f = temp

print(f)

Submission status: Accepted

Solution code:
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 1000
count = 0

for i in range(ls-lt+1):
    ss = s[i:i+lt]
    count = 0
    for i in range(lt):
        if ss[i] == t[i]:
            count += 1
    if ans > lt-count:
        ans = lt-count

print(ans)

Submission status: Accepted

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

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

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

print(lt - res)

Submission status: Accepted

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

for i in range(0,ls-lt+1):
  cnt=0
  for ss,tt in zip(S[i:],T):
    if ss!=tt:
      cnt+=1
  
  if cnt<cnt2:
    cnt2=cnt

print(cnt2)

Submission status: Accepted

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

nS=len(S)
nT=len(T)

N=nS-nT+1
dfmin=1000
for i in range(N):
    df=0
    for j in range(nT):
        if S[i+j]!=T[j]:
            df+=1
    if df < dfmin:
        dfmin=df
print(dfmin)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    s = input()
    t = input()
    ans = 1001
    for i in range(len(s) - len(t) + 1):
        short_s = s[i:i + len(t)]
        icchi = 0
        for j in range(len(t)):
            if short_s[j] != t[j]:
                icchi += 1
        if icchi < ans:
            ans = icchi
    print(ans)


   

    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(len(s) - len(t) + 1):
    count = 0
    x = s[i:i+len(t)]
    # print(x)
    if x == t:
        print(0)
        exit()
    else:
        for j in range(len(x)):
            if x[j] != t[j]:
                count += 1
        count_list.append(count)

# print(count_list)
print(min(count_list))

Submission status: Accepted

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

c = len(S) - len(T)

m = 1000
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()

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

print(res)

Submission status: Accepted

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc177/abc177_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    T = i2s()
    n = len(S)
    m = len(T)
    ans = m
    for i in range(n - m + 1):
        cnt = 0
        for j in range(m):
            cnt += S[i+j] != T[j]
            if cnt >= ans:
                break
        else:
            ans = cnt
        if ans == 0:
            break
    print(ans)
    return

main()

Submission status: Accepted

Solution code:
# = map(int, input().split())
# = int(input())
S = input()
T = input()
N = len(S)
M= len(T)
ans = N


for j in range(N- M+1):
  change = 0
  for l in range(M):
    if S[j+l] != T[l]:
      change += 1
  ans = min(ans, change)

print(ans)

Submission status: Accepted

Solution code:
def get_num(s, t):
    cnt = len(s)
    for i in range(len(s)):
        if s[i] == t[i]:
            cnt -= 1
    return cnt


def main():

    s = input()
    t = input()
    len_s, len_t = len(s), len(t)
    ans = len_t
    for i in range(len_s - len_t + 1):
        new_s = s[i:len(t) + i]
        tmp = get_num(new_s, t)
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
print(min([sum(map(lambda x:x[0]!=x[1], zip(S[i:i+len(T)],T))) for i in range(1+len(S)-len(T))]))

Submission status: Accepted

Solution code:
s=input()
t=input()
s=list(s)
t=list(t)
c=0
for i in range(0,len(s)-len(t)+1):
    aa=0
    pp=0
    #print()
    for j in range(i,i+len(t)):
        #print(s[j],t[pp],"compare")
        if(s[j]==t[pp]):
            aa+=1
        pp+=1
    c=max(c,aa)
print(len(t)-c)

Submission status: Accepted

Solution code:
def ch(s,t):
    list1=[]
    for i in range(len(s)-len(t)+1):
        w=s[i:i+len(t)]
        ct=0
        for j in range(len(t)):
            if w[j]==t[j]:
                ct+=1
        list1.append(ct)
    return(max(list1))
s=input()
t=input()
flag=0
ans=ch(s,t)
print(len(t)-ans)

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

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


    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S=list(str(input()))
T=list(str(input()))
ans=10000
for i in range(len(S)-len(T)+1):
    s=0
    for u in range(len(T)):
        if S[i+u]==T[u]:
            s+=1
            #print(s)
    s=len(T)-s
    ans=min(ans,s)
print(ans)

Submission status: Accepted

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

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

for i in range(slen - tlen + 1):
    count = 0
    for j in range(tlen):
        if s[i + j] != t[j]:
            count += 1
    if count < min:
        min = count

print(min)

Submission status: Accepted

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

result = 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
    result = min(count, result)

print(result)

Submission status: Accepted

Solution code:
#[int(i) for i in input().split()]
def diff(x,y):
	ret = 0
	for i in range(len(x)):
		if x[i]!=y[i]:
			ret+=1
	return ret
s=input()
t=input()

l = len(t)
ans = float('inf')
for i in range(len(s)):
	if i+l<len(s)+1:
		tmp = diff(s[i:i+l], t)
		ans = min(ans, tmp)
		
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
t = len(T)
min = 10**3+1
for i in range(len(S)-t+1) :
    count = 0
    Si = S[i:t+i]
    for j in range(t) :
        if Si[j] != T[j] :
            count += 1
    if count < min :
        min = count


print(min)

Submission status: Accepted

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

ans=10**10

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

print(ans)

Submission status: Accepted

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

def count_common(a,b):
    cnt = 0
    for i in range(len(a)):
        if a[i] == b[i]:
            cnt += 1
    return cnt

cnt = 0

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

print(len(T)-cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
len_s = len(s)
len_t = len(t)
min = len_t
for i in range(len_s-len_t+1):
    text = s[i:i+len_t]
    kaisu = 0
    for j in range(len(text)):
        if text[j] != t[j]:
            kaisu += 1
    if kaisu < min:
        min = kaisu
print(min)

Submission status: Accepted

Solution code:
# abc177_b.py
# https://atcoder.jp/contests/abc177_b


# [開発時用] ログ関数
def lg(value):
    flag = False
    flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 2
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    S = lines[0]
    T = lines[1]
    # X = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

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

    return [result]


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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


m = len(S)
for i in range(0,len(S)-len(T)+1):
    tgt = S[i:i+len(T)]
    if tgt != T:
        cnt = 0
        for j in range(len(tgt)):
            if tgt[j] != T[j]:
                cnt += 1
        m = min(cnt,m)
    else:
        m = 0
        break

print(m)

Submission status: Accepted

Solution code:
a=input()
b=input()
mincount=1000000
for i in range(len(a)-len(b)+1) :
  count=0
  for j in range(len(b)) :
    if a[i+j]!=b[j] :
      count+=1
  mincount=min(count,mincount)
print(mincount)

Submission status: Accepted

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

	if n < mn:
		mn = n

print(mn)

Submission status: Accepted

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

ans = float("INF")
for i in range(len(S)-len(T)+1):
    cnt = len(T)
    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()
max_count = 0

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
            
    if count > max_count :
        max_count = count
        
print(len(t) - max_count)

Submission status: Accepted

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

ans = 100000

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

def calc_length(str1, str2):
    length = 0
    for i in range(len(str1)):
        if str1[i] != str2[i]:
            length += 1
    return length

min_length = len(t)
for i in range(len(s)- len(t) + 1):
    l = calc_length(s[i:i+len(t)], t)
    if l < min_length:
        min_length = l

print(min_length)

Submission status: Accepted

Solution code:
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))


def f(s, t):
	# print(s, t)
	ans = 0
	for i in range(len(t)):
		ans += (s[i] != t[i])
	return(ans)

def main():
	s = input().strip(); t = input().strip()
	ans = f(s, t)

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


if __name__ == "__main__":
	main()

Submission status: Accepted

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
for i in range(len(s) - len(t) + 1):
    c = 0
    for m in range(len(t)):
        if t[m] == s[m+i]:
            c+=1
    if c > result:
        result = c
print(len(t) - result)

Submission status: Accepted

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

    ans = 10**9

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


main()

Submission status: Accepted

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

diff = len(S) - len(T)
min_cnt = 1000
for i in range(0,diff+1):
  cnt = 0
  for j in range(len(T)):
    if T[j] != S[i+j]:
      cnt += 1
  if cnt < min_cnt:
    min_cnt = cnt
    if cnt == 0:
      break
    
print(min_cnt)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

ans = []

for i in range(N-M+1):
    cnt = 0
    for j in range(M):
        if S[i+j] != T[j]:
            cnt += 1
    ans.append(cnt)

print(min(ans))

Submission status: Accepted

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

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

ans = m

for i in range(n-m+1):
    xs = S[i:i+m]
    cnt = 0
    for j in range(m):
        if xs[j] != T[j] :
            cnt += 1
    ans = min(ans, cnt)
    
print(ans)

Submission status: Accepted

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

def check(a,b):
    s = 0
    for i,j in zip(a,b):
        s += i!=j
    return s
ans = 10**6
for i in range(len(s)):
    a = s[i:]
    if len(a) >= len(t):
        ans = min(ans,check(t,a[:len(t)]))
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
total = 0
for i in range(len(s)-len(t)+1):
  u = s[i:i+len(t)]
  sum = 0
  for j in range(len(t)):
    if u[j] == t[j]:
      sum += 1
  total = max(sum,total)

print(len(t)-total)

Submission status: Accepted

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

min_count = 1000
for idx in range(len(S) - len(T) + 1):
    s = S[idx:idx+len(T)]
    count = sum([1 if tc!=sc else 0 for tc, sc in zip(T, s)])
    min_count = min(min_count, count)

print(min_count)

Submission status: Accepted

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

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

if len(S) == len(T):
  tmp = 0
  for j in range(len(T)):
    if S[j] == T[j]:
      tmp += 1
  if tmp > max_count:
    max_count = tmp

print(len(T) - max_count)

Submission status: Accepted

Solution code:
s = input()
t = input()
lens, lent = len(s), len(t)
minimum = float('inf')
for i in range(lens - lent + 1):
  diff = 0
  for j in range(lent):
    if s[i + j] != t[j]:
      diff += 1
  minimum = min(minimum, diff)
  if minimum == 0:
    break
print(minimum)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

    if max_cnt < cnt:
        max_cnt = cnt

print(len(T) - max_cnt)

Submission status: Accepted

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

Min = 10000
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
    Min = min(Min, temp)

print(Min)

Submission status: Accepted

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