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 = list(input())
T = list(input())

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

ans = float('inf')

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


def _s(): return sys.stdin.readline().strip()


def main():
    s = _s()
    t = _s()
    tn = len(t)
    mn = tn
    for i in range(0, len(s)-tn+1):
        tmp = 0
        for c1, c2 in zip(s[i:i+tn], t):
            if c1 != c2:
                tmp += 1
        mn = min(mn, tmp)
    return mn


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
def count(x,y):
	c = 0
	for i in range(len(x)):
		c += (x[i]!=y[i])
	return c
s = input()
t = input()
mx = len(s)
for i in range(0, len(s) - len(t) + 1):
	c = count(s[i:i+len(t)], t)
	mx = min(mx,c)
print(mx)

Submission status: Accepted

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

max=len(t)

for i in range(len(s)-len(t)+1):
    tmp_max=0
    for j in range(len(t)):
        if t[j]==s[i+j]:
            pass
        else:
            tmp_max+=1
    if max>tmp_max:
        max=tmp_max


print(max)

Submission status: Accepted

Solution code:
S=input()
T=input()
n = 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
  n=max(tmp,n)
print(len(T)-n)

Submission status: Accepted

Solution code:

S = input()
T = input()

ans = float("inf")

for i in range(len(S)-len(T)+1):

    now = 0
    for j in range(len(T)):

        if S[i+j] != T[j]:
            now += 1

    ans = min(ans , now)

print (ans)

Submission status: Accepted

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

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)):
        # print(i, j, S[i+j], T[j])
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
import sys

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

Max = 0

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ns = len(s)
nt = len(t)
mn = nt
for i in range(ns-nt+1):
    cnt = 0
    for j in range(nt):
        if(s[i+j] == t[j]):
            cnt += 1

    mn = min(mn,nt-cnt)
print(mn)

Submission status: Accepted

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

nt = len(T)
ns = len(S)
ans = 1000

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

Submission status: Accepted

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

def count(i):
	c = 0
	for j in range(len(T)):
		if i + j >= len(S):
			return len(T)
		if T[j] != S[i + j]:
			c += 1
	return c

topvalue = len(T)
for i in range(len(S)):
	c = count(i)
	if topvalue > c:
		topvalue = c
print(topvalue)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

s = readline().rstrip()
t = readline().rstrip()

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

Submission status: Accepted

Solution code:
def main():
    S = list(input())
    T = list(input())
    ans = float('inf')
    for i in range(len(S)):
        cnt = 0
        flag = True
        for j in range(len(T)):
            if i + j >= len(S):
                flag = False
                break
            if S[i+j] != T[j]:
                cnt += 1
        if flag:
            ans = min(ans, cnt)

    print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()
T=input()
temp=0
ans=100000000000000
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 temp<ans:
        ans=temp
print(ans)

Submission status: Accepted

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

minimum = math.inf
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    minimum = min(minimum,cnt)
print(minimum)

Submission status: Accepted

Solution code:
s =input()
t = input()
len_s = len(s)
len_t = len(t)
ans = 10**10
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(cnt,ans)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
cnt = []
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
    cnt.append(c)
ans = len(t) - max(cnt)
print(ans)

Submission status: Accepted

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

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

print(len(t)-ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
ilelec = lambda: map(int1,input().split())
alelec = lambda: list(map(int1, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
#MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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


minChange = 1001
for start in range(0, len(s)-len(t)+1):
	currChange = 0
	for i, val in enumerate(t):
		if s[start+i] != val:
			currChange += 1
	minChange = min(currChange, minChange)
print(minChange)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = list(str(input()))
t = list(str(input()))
ls = len(s)
lt = len(t)
m0  = lt
for i in range(ls - lt + 1):
  stemp = s[i:i +lt]
  k = 0
  for j in range(lt):
    if t[j] != stemp[j]:
      k += 1
  if k < m0:
    m0 = k
print(m0)

Submission status: Accepted

Solution code:
s = input()
t = input()
s_length = len(s)
t_length = len(t)

count = []
for idx in range(s_length - t_length + 1):
    cnt = 0
    substr = s[idx: idx + t_length]
    for j in range(t_length):
        if substr[j] != t[j]:
            cnt += 1
    count.append(cnt)

print(min(count))

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
ans = 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
    ans = max(ans, count)

print(len(t)-ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
anss = []
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
  anss.append(ans)
print(len(t) -max(anss))

Submission status: Accepted

Solution code:
s = input()
t = input()
ls = len(s)
lt = len(t)
mi = 10**6
for i in range(ls-lt+1):
    s1 = s[i:i+lt]
    count = 0
    for j in range(lt):
        if s1[j]!=t[j]:
            count += 1
    mi = min(mi,count)
print(mi)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()


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

ans = 10**10
for i in range(N-M+1):
    subS = S[i:i+M]
    temp = 0
    for s,t in zip(subS, T):
        if s != t:
            temp += 1
    ans = min(temp,ans)

print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 10**18

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

countlist = []
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
  countlist.append(count)
print(len(T) - max(countlist))

Submission status: Accepted

Solution code:
s=input()
t=input()
l=len(s)
l2=len(t)
ans=1000000
for i in range(l-l2+1):
	curr=0
	for j in range(i,i+l2):
		if(s[j]!=t[j-i]):
			curr+=1
	if(curr<ans):
		ans=curr
print(ans)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    T = input().rstrip('\n')
    NS = len(S)
    NT = len(T)
    ans = 10000000
    for i in range(NS - NT + 1):
        tmp = 0
        for j in range(NT):
            if S[i+j] != T[j]:
                tmp += 1
        ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

S = input()
T = input()

result = sys.maxsize

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

Submission status: Accepted

Solution code:
S = list(input())

T = list(input())

ans = 0

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

print(len(T)-ans)

Submission status: Accepted

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


ans = len(t)
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()

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

ans = float('inf')
for i in range(len(s) - len(t) + 1):
    num = compare(s[i:(i+len(t))], t)
    if num < ans:
        ans = num

print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    t=SI()
    a=len(s)
    b=len(t)
    ans=b
    for i in range(a-b+1):
        res=b
        for j in range(b):
            if s[i+j]==t[j]:
                res-=1
        ans=min(ans,res)
    print(ans)
            
        
if __name__=="__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

min_c = 10000000

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

    min_c = min(c,min_c)
print(min_c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
xs=len(s)
xt=len(t)
count=1000
for i in range(xs-xt+1):
    temp=0
    for j in range(xt):
        if s[i+j]!=t[j]:
            temp+=1
    count=min(temp,count)
print(count)

Submission status: Accepted

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

ls = len(S)
lt = len(T)
ans = lt
for i in range(ls):
    dif = 0
    for j in range(lt):
        if ls <= i+j:
            break
        if S[i+j] != T[j]:
            dif += 1
    else:
        ans = min(ans,dif)

print(ans)

Submission status: Accepted

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

res = float('inf')
nt = len(T)
ns = len(S)
for i in range(ns-nt+1):
    count = 0
    for j in range(nt):
        if T[j] != S[i+j]:
            count +=1 
    res = min(res, count)
print(res)

Submission status: Accepted

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

result = 10 ** 9
for i in range(len(s) - len(t) + 1):
  tmp = 0
  for i, c in enumerate(s[i:i+len(t)]):
    if c != t[i]:
      tmp += 1
  result = min(result, tmp)

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve(a,b):

	count=0
	for g in range(len(a)):
		if(a[g]!=b[g]):
			count+=1
	return count

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

l=len(T)

ans=100000

for a in range(len(S)-len(T)+1):
	ans=min(ans,solve(S[a:a+l],T))

print(ans)

Submission status: Accepted

Solution code:
import sys
# sys.stdin  = open("input.txt")
s=input()
t=input()
lol=float('inf')
for i in range(len(s)-len(t)+1):
    ch=0
    # print(i)
    for j in range(len(t)):
        # if i+j==(len(s)-1):
        #     print("yey")
        if s[i+j]!=t[j]:
            ch+=1
    lol=min(lol,ch)
print(lol)

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:
def main():
    S = input()
    T = input()
    ans = len(T)
    for start in range(len(S) - len(T) + 1):
        cnt = 0
        for i in range(len(T)):
            if S[start + i] != T[i]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

ans = 10**9

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

    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

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

s = input()
t = input()
n = len(t)
ans = 10 ** 10
for i in range(len(s) - n + 1):
    ans = min(ans, check(s[i: i + n], t))
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 10**10

len_s = len(S)
len_t = len(T)

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

Submission status: Accepted

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

ans = 0

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

    ans = max(ans, ansi)

print(len(T) - ans)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

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

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#=map(int,input().split())
S=input()
T=input()
ls=len(S)
lt=len(T)
ans=float('inf')
for i in range(ls-lt+1):
    ans_=0
    for j in range(lt):
        if S[i+j]!=T[j]:
            ans_+=1
    ans=min(ans,ans_)
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()
nt = len(t)
def check(a,b):
    cnt = 0
    for sa,sb in zip(a,b):
        if sa != sb:
            cnt += 1
    return cnt
ans = 1 << 50
for i in range(nt,len(s)+1):
    s_p = s[i-nt:i]
    # print(s_p,t)
    ans = min(check(s_p,t),ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #d, t, s = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s = input()
    t = input()
    #print("Yes" if s*t >= d else "No")
    ans = len(s)
    st = set()
    for i in range(len(s) - len(t)+1):
        anss = 0
        for j in range(len(t)):
            if t[j] != s[i+j]:
                anss += 1
        ans = min(ans, anss)
    print(ans)

Submission status: Accepted

Solution code:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    S=input()
    T=input()
    min_change = 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
        min_change = min(min_change,tmp)
    print(min_change)




    
main()

Submission status: Accepted

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

ans = len(s)
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()
min_c = 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
    min_c = min(min_c, cnt)
print(min_c)

Submission status: Accepted

Solution code:
s=input()
t=input()
tl=len(t)
m=0
for i in range(len(s)-tl+1):
    c=0
    for x,y in zip(t,s[i:i+tl]):
        if x==y:
            c+=1
    m=max(m,c)
print(tl-m)

Submission status: Accepted

Solution code:
def main():
	S = input()
	T = input()
	ls = len(S)
	lt = len(T)
	ans = []
	for i in range(ls - lt + 1):
		cnt = 0
		for j in range(lt):
			if S[i + j] != T[j]:
				cnt += 1
		ans.append(cnt)
	print(min(ans))

main()

Submission status: Accepted

Solution code:
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9) + 7


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

Submission status: Accepted

Solution code:
S = input()
T = input()
def f(s,t):
    ret = 0
    for c,d in zip(s,t):
        if c != d:
            ret += 1
    return ret
ans = len(T)
for i in range(0, len(S)-len(T)+1):
    ans = min(ans, f(S[i:i+len(T)], T))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

S = input()
T = input()
ans = len(T)
for i in range(len(S) - len(T) + 1):
    ans = min(ans, diff_str(S[i : i + len(T)], 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):
    a = 0
    for j in range(lent):
        a += (T[j] != S[i+j])
    ans = min(a,ans)

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
N, M = len(S), len(T)
ma = 0
for i in range(N-M+1):
    c = 0
    for j in range(M):
        if S[i+j] == T[j]:
            c += 1
    ma = max(ma, c)

print(M - ma)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

S=input().strip()
T=input().strip()

ANS=10000
LENT=len(T)
LENS=len(S)

for i in range(LENS-LENT+1):
    score=0
    for j in range(LENT):
        if T[j]!=S[i+j]:
            score+=1

    #print(i,score)
    ANS=min(ANS,score)

print(ANS)