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:
def main():
    s = input()
    t = input()
    n,m = len(s),len(t)
    c = 0
    for i in range(n-m+1):
        cnt = 0
        for j in range(m):
            if s[i+j] == t[j]:
                cnt += 1
        if cnt > c:
            c = cnt
    print(m-c)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = list(input())
t = list(input())

ans = float("inf")

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
T = input().strip()
k = len(T)
dmin = len(S)
for i in range(len(S)-k+1):
    cnt = 0
    for j in range(k):
        if S[i+j]!=T[j]:
            cnt += 1
    dmin = min(dmin,cnt)
print(dmin)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
t = ns()

ss = len(s)
tt = len(t)
ans = 0

for i in range(ss-tt+1):
    a = 0
    for j in range(tt):
        if s[i+j] == t[j]:
            a += 1
    ans = max(a,ans)

print(tt-ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


S = input()
T = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
len_S, len_T = len(S), len(T)
result = 10**8
for i in range(len_S-len_T+1):
  R = 0
  for j in range(len_T):
    if S[i+j] != T[j]:
      R += 1
  result = min(result, R)
print(result)

Submission status: Accepted

Solution code:
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

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

Submission status: Accepted

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

ans = 10 ** 19
for i in range(len(s) - len(t) + 1):
  num = 0
  for a, b in zip(s[i:], t):
    if a != b:
      num += 1
  ans = min(ans, num)
  
print(ans)

Submission status: Accepted

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

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

ans = float('inf')
for i in range(LS - LT + 1):
    cnt = 0
    for k in range(LT):
        if S[i+k] != T[k]:
            cnt += 1
    ans = ans if ans < cnt else cnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
ans = 10000
for i in range(len(s)-len(t)+1):
  num = 0
  for j in range(len(t)):

    if s[i+j] != t[j]:
      num += 1
  ans = min(ans,num)
print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    l = len(T)
    m = l
    for i in range(len(S)-l+1):
        r = 0
        for j in range(l):
            if S[i+j] != T[j]:
                r += 1
        if r < m:
            m = r
    return m
print(main())

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    p = 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 p < tmp:
            p = tmp
    print(len(t)-p)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

s = input()
t = input()

vmin = 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
    # print(count)
    vmin = min(vmin, count)

print(vmin)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examA():
    D,T,S = LI()
    if (D-1)//S<T:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

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

    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 1<<60
for i in range(len(S)-len(T)+1):
    s_ = S[i:i+len(T)]
    a = 0
    for s, t in zip(s_, T):
        a += s!=t
    if ans > a:
        ans = a
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s, t = rr(), rr()
lent = len(t)
ans = inf
for i in range(len(s)-lent+1):
    cnt = 0
    for a, b in zip(s[i:i+lent], t):
        if a!=b:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


ans = INF
s = str_inp()
t = str_inp()

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()
len_s = len(s)
len_t = len(t)

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
    nya = s[i:i+len(t)]
    #print(nya)
    p = 0
    for j in range(len(nya)):
        if t[j] == nya[j]:
            pass
        else:
            p += 1
    ans = min(ans,p)
print(ans)

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

ans = len(T)
for b in range(len(S)):
    e = b + len(T)
    if e > len(S):
        break
    ans = min(ans, sum(0 if s == t else 1 for s, t in zip(S[b:e], T)))
    
print(ans)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    T = input()
    ans = len(T)
    for i in range(len(S)- len(T) + 1):
        count = S[i:i+len(T)]
        no = 0
        for j in range(len(count)):
            if count[j] != T[j]:
                no += 1
        if ans > no:
            ans = no
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
S = list(input())[:-1]
T = list(input())[:-1]
N = len(S)
n = len(T)
MIN = 10000
for i in range(N-n+1):
    c = 0
    for j in range(n):
        if S[i+j] != T[j]:
            c += 1
    MIN = min(MIN,c)
print(MIN)

Submission status: Accepted

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

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

res = m

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

print(res)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

    ret = INF
    for i in range(s_len - t_len + 1):
        tmp = S[i:i + t_len]
        l = 0
        for j in range(t_len):
            if tmp[j] != T[j]: l += 1
        ret = min(ret, l)
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
#n = int(input())
#d, t, s = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

t = input()
ans = 10000
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 < ans:
        ans = cnt

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

s = input().strip()
t = input().strip()
n = len(s)
m = len(t)
ans = float('inf')
for i in range(n-m+1):
    ct = 0
    for j in range(m):
        if s[i+j] != t[j]:
            ct += 1
    ans = min(ans,ct)
print(ans)

Submission status: Accepted

Solution code:
def diff(a, b):
  res = 0
  for (ca, cb) in zip(a, b):
    if ca != cb:
      res += 1
  return res

def solve(s, t):
  res = len(t)
  for i in range(0, len(s) - len(t) + 1):
    res = min(res, diff(s[i : i + len(t)], t))
  return res

s = input()
t = input()
print(solve(s, t))

Submission status: Accepted

Solution code:
import math
import fractions
import collections
import itertools
S=list(input())
T=list(input())
ans=float("inf")
num=0
for i in range(0,len(S)-len(T)+1):
    num=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            num=num+1
    ans=min(ans,num)
    #print(num)
print(ans)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    s=STR()
    t=STR()
    ls=len(s)
    lt=len(t)
    ans=10**9
    for i in range(ls-(lt-1)):
        temp=0
        for k in range(lt):
            if s[i+k]!=t[k]:
                temp+=1
        ans=min(temp,ans)
    print(ans)
        

if __name__=='__main__':
    do()

Submission status: Accepted

Solution code:
S=input()
T=input()
ans=float("INF")
for i in range(0,len(S)-len(T)+1):
    now=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            now+=1
    ans=min(now, ans)

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
L = len(T)
res = 10000
for i in range(len(S)-L+1):
    tmp = 0
    for a, b in zip(list(S[i:i+L]), list(T)):
        tmp += 1 if a != b else 0
    res = min(tmp, res)
print(res)

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

s = input()
t = input()

ans = 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)

Submission status: Accepted

Solution code:
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    best = 2000
    ls = len(s)
    lt = len(t)
    for i in range(ls - lt + 1):
        diff = 0
        for j in range(lt):
            if t[j] != s[j + i]:
                diff += 1
        best = min(best, diff)
    print(best)
    return




s = RS()
t = RS()
solve()

Submission status: Accepted

Solution code:
import sys

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

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

    res = tl
    for i in range(sl-tl+1):
        count = 0
        s = S[i:i+tl]
        for ti, si in zip(T, s):
            if ti != si:
                count += 1
        if count < res:
            res = count

    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

S = input()
T = input()
ret = 10**9
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    c = 0
    for j in range(len(s)):
        if s[j] != T[j]:
            c += 1
    ret = min(c, ret)

print(ret)

Submission status: Accepted

Solution code:
s=input()
t=input()
ans = 10**9
for i in range(len(s)):
    # print('---',i)
    val = 0
    for j in range(len(t)):
        if i+j >= len(s):
            break
        si = s[i+j]
        ti = t[j]
        # print(si,ti)
        if si != ti:  val += 1
    else:
        ans = min(ans,val)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    t=input()
    ls=len(s)
    lt=len(t)
    tc=100000
    for i in range(ls-lt+1):
        cnt=0
        for j in range(lt):
            if t[j]!=s[j+i]:
                cnt+=1
        tc=min(cnt,tc)
    print(tc)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s)
n1=len(t)
tot=n
for i in range(n):
    ans=0
    f=0
    for j in range(n1):
        if i+j>=n:
            f=1
            break
        if s[i+j]==t[j]:
            continue
        else:
            ans+=1
    if f==0:
        tot=min(tot,ans)
print(tot)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():return int(stdin.readline().strip())
def get_tuple():return map(int, stdin.readline().split())
def get_list():return list(map(int, stdin.readline().split()))

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

Submission status: Accepted

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

diff = len(s) - len(sub)
ans = 10000
for i in range(diff + 1):
    temp = 0
    for idx in range(len(sub)):
        if s[idx+i] != sub[idx]:
            temp += 1
    ans = min(ans, temp)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = len(T)
res = n
for i in range(len(S) - n + 1):
    count = 0
    for c1, c2 in zip(S[i: i + n], T):
        if c1 != c2:
            count += 1
    res = min(count, res)
print(res)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)

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

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

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

ans = LT
for i in range(LS - LT + 1):
    t = 0
    for j in range(LT):
        if S[i + j] != T[j]:
            t += 1

    ans = min(ans, t)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()
ns = len(s)
nt = len(t)

ans = 10**5 
for i in range(ns - nt + 1):
    ret = 0
    for cs, ct in zip(s[i:i+nt], t):
        if cs != ct:
            ret += 1
    ans = min(ans, ret)
print(ans)

Submission status: Accepted

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = 10**9
for i in range(len(S)-len(T)+1):
    d = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            d += 1
    result = min(result, d)

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
T = input()

ans = INF
for i in range(len(S)):
    cnt = 0
    if i + len(T) > len(S):
        break
    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()
ans=len(t)
def f(s,t):
    a=0
    for i,j in zip(s,t):
        a+=i!=j
    return a

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

Submission status: Accepted

Solution code:
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

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

yes = "Yes"
no = "No"


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

    print(ans)


main()