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=100000000
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()
min_count = len(s)
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 min_count > count:
        min_count = count
print(min_count)

Submission status: Accepted

Solution code:
S=input()
T=input()
Slen=len(S)
Tlen=len(T)
ans=5000
for i in range(0,Slen-Tlen+1):
    tans=0
    for j in range(0,Tlen):
        if S[i+j]!=T[j]:
            tans+=1
    if tans<ans:
        ans=tans
print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
a = len(s)
b = len(t)
l = []
for i in range(a-b+1):
    cnt = 0
    c = s[i:i+b]
    for x, y in zip(c, t):
        if x != y:
            cnt +=1
    l.append(cnt)
print(min(l))

Submission status: Accepted

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

for i in range(lenS - lenT +1):
    tempS = S[i : i+lenT]
    splitS.append(tempS)

answer = lenT
for tempS in splitS:
    count = 0
    for i in range(lenT):
        if tempS[i] != T[i]:
            count += 1
    answer = min(answer, count)
print(answer)

Submission status: Accepted

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

i = 0
ans =[]

while i + len(T) <= len(S):
    n = 0
    for s, t in zip(S[i:i+len(T)], T):
        if s != t:
            n += 1
    ans.append(n)
    i += 1

print(min(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):
    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()

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

Submission status: Accepted

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

ans = 2000

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
S = str(input());T = str(input())
N = len(S)
M = len(T)
ans = M
for i in range(N-M+1):
  kouho = S[i:i+M]
  temp = 0
  #print(kouho,T)
  for j in range(M):
    if kouho[j] != T[j]:
      temp += 1
  ans = min(ans,temp)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s, t = [input() for _ in range(2)]
max_count = 0
for i in range(len(s) - len(t) + 1):
    m_count = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            m_count += 1
    if max_count < m_count:
        max_count = m_count

print(len(t)-max_count)

Submission status: Accepted

Solution code:
s, t = [input() for _ in range(2)]
max_count = 0
for i in range(len(s) - len(t) + 1):
    m_count = 0
    for j in range(len(t)):
        if s[i:][j] == t[j]:
            m_count += 1
    if max_count < m_count:
        max_count = m_count

print(len(t)-max_count)

Submission status: Accepted

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

for idx in range(len(t), len(s)+1):
    tmp = 0
    for s_s, t_s in zip(list(s[idx-len(t):idx]), list(t)):
        if not s_s == t_s:
            tmp += 1
    if ans > tmp:
        ans = tmp

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

diff = 0
min_diff = len(t)

for cnt_s in range(0, len(s) - len(t)+1):
    diff = 0
    for cnt_t in range(0, len(t)):
        if s[cnt_s + cnt_t] != t[cnt_t]:
            diff += 1
    if min_diff > diff:
        min_diff = diff

print(min_diff)

Submission status: Accepted

Solution code:

def count(s1,s2):
	cnt = 0
	for i in range(len(s2)):
		if s1[i] != s2[i]:
			cnt += 1
	return cnt 


S1 = input()
S2 = input()

mmin = len(S2)
for i in range(len(S1)-len(S2)+1):
	k = count(S1[i:len(S2)+i],S2)
	if k < mmin:
		mmin = k

print(mmin)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
ans=[]

for i in range(len(s)-len(t)+1):
    u=s[i:len(t)+i]
    a=0
    for j in range(len(t)):
        if not t[j-1]==u[j-1]:
            a=a+1
    ans.append(a)
print(min(ans))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

ans = 1e10

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

print(ans)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

_INPUT = """\
codeforces
atcoder
"""

def main(*, input=input):
    sr = lambda: input()
    ir = lambda: int(sr())
    lr = lambda: list(map(int, sr().split()))

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


if __name__ == "__main__":
    import io, sys

    # sys.stdin = io.StringIO(_INPUT)

    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def match_len(S, T):
    ls, lt = len(S), len(T)
    ret = 0
    for i in range(ls - lt + 1):
        tmp = 0
        for x, y in zip(S[i:], T):
            tmp += x == y
        ret = tmp if tmp > ret else ret
    return ret

S = input()
T = input()
print(len(T) - match_len(S, T))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
ans = 1001
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(len(t)-tmp,ans)
print(ans)

Submission status: Accepted

Solution code:
S = list(str(input()))
T = list(str(input()))
i = 0
ans = []
len_s = len(S)
len_t = len(T)
while i < len_s-len_t+1:
    cnt = 0
    for ss, tt in zip(S[i:i+len_t], T):
        if ss != tt:
            cnt += 1
    ans.append(cnt)
    i += 1
print(min(ans))

Submission status: Accepted

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

min_dist = 10**10
for i in range(len(S) - len(T) + 1):
    for k in range(len(T)):
        dist = 0
        for s, t in zip(S[i:i + len(T)], T):
            if s != t:
                dist += 1
            if dist >= min_dist:
                break

        min_dist = min(dist, min_dist)
        if min_dist == 0:
            print(0)
            exit()

print(min_dist)

Submission status: Accepted

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

n = len(s)
m = len(t)
ans = m
for i in range(n-m+1):
  p = 0
  for j in range(m):
    if s[i+j] != t[j]: p += 1
  if p < ans: ans = p
print(ans)

Submission status: Accepted

Solution code:
##B - Substring
S = str(input())
T = str(input())
L = len(S) - len(T) + 1
##print(L)
ansL = []
for i in range(L):
    ans = 0
    for j in range(len(T)):
        if S[j] != T[j]:
            ans += 1
    ##print(ans)
    ansL.append(ans)
    S = S[1:]
print(min(ansL))

Submission status: Accepted

Solution code:
S = list(str(input()))
T = list(str(input()))
s = 0
t = 0
len_s = len(S)
len_t = len(T)
i = 0
ans = []

while i < len_s-len_t+1:
    cnt = 0
    #print(S[i:i+len_t])
    for ss, tt in zip(S[i:i+len_t], T):
        #print(ss,tt)
        if ss != tt:
            cnt +=1
    ans.append(cnt)
    i += 1

#print(ans)
print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 171 B
S = input()
T = input()
ans = []
for i in range(0, (len(S)-len(T) + 1)):
    tmp = 0
    #print(i)
    for j in range(0, len(T)):
        if T[j] != S[i +j]:
            tmp += 1
            #print(S[i +j] + T[j])
        #print('tmp:' + str(tmp))
    ans.append(tmp)
        
print(min(ans))

Submission status: Accepted

Solution code:
S, T = [input() for _ in range(2)]

answer = float("inf")

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

Submission status: Accepted

Solution code:
#from sys import stdin

#input = stdin.readline
#inputRstrip = stdin.readline().rstrip

#x = input().rstrip()
#n = int(input())

#a,b,c = input().split()
#a,b,c = map(int, input().split())

ST = [input() for i in range(2)]
S = ST[0]
T = ST[1]
ans = len(T)

for i in range(len(S) - len(T) + 1):
	count = len(T)
	for j in range(len(T)):
		if(T[j] == S[i + j]):
			count -= 1
	if(ans > count):
		ans = count
print(ans)

Submission status: Accepted

Solution code:
S, T = [input() for _ in range(2)]
answer = 1001

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

Submission status: Accepted

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

s_len = len(s)
t_len = len(t)

out = t_len

for i in range(0, s_len - t_len + 1):
    diff = 0
    for j in range(0, t_len):
        if t[j] != s[i + j]:
            diff += 1
    out = min(out, diff)

print(out)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = [0] * (len(S) - len(T)+1)
for a in range(len(S) - len(T)+1):
    for b in range(len(T)):
        if S[a + b] != T[b]:
            ans[a] += 1

print(min(ans))

Submission status: Accepted

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

ans = 1e+9

for si in range(len(s)):
    if si + len(t) > len(s):
        continue
    cnt = 0
    for ti in range(len(t)):
        if s[si+ti] != t[ti]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

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

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

result = len(T)
x = 0

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# B - Substring

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

s = len(S)
t = len(T)
ans = 10**18

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

print(ans)

Submission status: Accepted

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

    ans = float('inf')
    for i in range(0,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)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = len(T)

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

Submission status: Accepted

Solution code:
s = input()
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 = cnt + 1
    ans = min(ans,cnt)

print(ans)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()
    T = SS()
    len_S = len(S)
    len_T = len(T)

    ans = len(T)
    for i in range(len_S - len_T + 1):
        diff = len([(j, k) for j, k in zip(S[i:i+len_T], T) if j != k])
        ans = min(diff, ans)

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:

S=input()
T=input()
check=[]
for i in range(len(S)-len(T)+1):
    check.append(0)
    for j,tt in enumerate(T):
        if tt==S[i+j]:
            check[i]+=1
# print(check)
check.append(0)
# print(check)
print(len(T)-max(check))

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
length = len(s)-len(t) + 1
max = 0
for i in range(length):
    count = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            count += 1
        if j == len(t)-1 and max < count:
            max = count
print(len(t) - max)

Submission status: Accepted

Solution code:
s = input()
t = input()
ss = len(s)
tt = len(t)
min = tt


for i in range(ss - tt + 1):
  count = 0
  for j in range(tt):
    if s[i+j] != t[j]:
      count += 1
  if min > count:
    min = count

print(min)

Submission status: Accepted

Solution code:
S=input()
T=input()
match=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=count+1
    if match<count:
        match=count
print(len(T)-match)

Submission status: Accepted

Solution code:
def count(s1, s2):
    dst = 0
    for c1, c2 in zip(s1, s2):
        if c1 != c2: dst+=1

    return dst

def execute(S, T):
    dst = len(T)

    for i in range(len(S) - len(T)+1):
        s = S[i:i+len(T)]
        c = count(s, T)
        if c < dst:
            dst = c

    return dst

if __name__ == '__main__':
    S = input()
    T = input()

    print(execute(S, T))

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 1000
c = 0


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

print(ans)

Submission status: Accepted

Solution code:
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t) + 1):
  d = len(t)
  for a, b in zip(s[i:], t):
    if a == b:
      d -= 1
  c.append(d)
print(min(c))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    S = input()
    T = input()
    len_s = len(S)
    len_t = len(T)
    ans = 1000
    for i in range(len_s-len_t+1):
        cunt = 0
        for j in range(len_t):
            if S[i+j] != T[j]:
                cunt += 1
        ans = min(ans, cunt)
    print(ans)

if __name__=='__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main(S, T):
    score = float('inf')
    org_length = len(S)
    part_length = len(T)

    for i in range(0, org_length - part_length + 1):
        part_str = S[i:i + part_length]

        count = 0
        for a, b in zip(part_str, T):
            if a != b:
                count+=1
        score = min(count, score)

    print(score)


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = input()

ans = len(t)

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

    ans = min(ans, dif)

print(ans)

Submission status: Accepted

Solution code:
def comp(a,b):
    s = 0
    for i,j in zip(a,b):
        if not i == j:
            s += 1
    return s
 
s = input()
t = input()
ans = len(t)
 
for i in range(len(s) - len(t) + 1):
    score = comp(s[i:i+len(t)],t)
    if score == 0:
        ans = score
        break
    if ans > score:
        ans = score
 
print(ans)

Submission status: Accepted

Solution code:
s = input().rstrip()
t = input().rstrip()
l_s = len(s)
l_t = len(t)
ans = l_t
for i in range(l_s-l_t+1):
  tmp_ans = l_t
  for j in range(l_t):
    if t[j] == s[i+j]:
      tmp_ans -= 1
  ans = min(ans, tmp_ans)
print(ans)

Submission status: Accepted

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

max_ans=0
for i in range(len(S)):
  max_n = 0
  for j in range(len(T)):
    if len(S) >= i + len(T):
      if S[i+j]==T[j]:
      	max_n=max_n+1
  
  if max_ans <= max_n:
    max_ans=max_n

print(len(T)-max_ans)

Submission status: Accepted

Solution code:
def comp(a,b):
    s = 0
    for i,j in zip(a,b):
        if not i == j:
            s += 1
    return s

s = input()
t = input()
ans = len(t)

for i in range(len(s) - len(t) + 1):
    score = comp(s[i:i+len(t)],t)
    if score == 0:
        ans = score
        break
    if ans > score:
        ans = score

print(ans)

Submission status: Accepted

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

count_min = 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 count < count_min:
    count_min = count

print(count_min)

Submission status: Accepted

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

ans = len(t)

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

Submission status: Accepted

Solution code:
S = input() # 本体
T = input() # 部分文字列

min_hamming = len(T)
for i in range(len(S) - len(T) + 1) :
    # print(S[i:i+len(T)], T, end = " ")
    hamming = 0
    for ch1, ch2 in zip(S[i:i+len(T)], T):
        hamming += 1 if ch1 != ch2 else 0
    # print(hamming)
    min_hamming = min(min_hamming, hamming)

print(min_hamming)

Submission status: Accepted

Solution code:
s1 = input()
s2 = input()
list_s1 = list(s1)
list_s2 = list(s2)
len_s1 = len(s1)
len_s2 = len(s2)
change_count_min = len_s2
for i in range(len_s1 - len_s2 + 1):
    change_count = len_s2
    for j in range(len_s2):
        if list_s1[j+i] == list_s2[j]:
            change_count -= 1
    if change_count < change_count_min:
        change_count_min = change_count
print(change_count_min)

Submission status: Accepted

Solution code:
#177B

S=input()
T=input()

Ss=[]
Ts=[]
Us=[]
Vs=[]

len_T=len(T)
len_S=len(S)

s=0

#初期配列を作成
for t in range(len_T):
    Ts.append(T[t])
    Ss.append(S[t])

#一致していない箇所の個数を数え、記録
for t in range(len_T):
    Us.append(Ts[t]!=Ss[t])
Vs.append(sum(Us))


for s in range(1,len_S-len_T+1):
    #Ss配列をずらす
    Ss.append(S[len_T+s-1])
    Ss.remove(S[s-1])
    #Usをリセットして、一致していない箇所の個数を数え、記録
    Us=[]
    for t in range(len(T)):
        Us.append(Ts[t]!=Ss[t])
    Vs.append(sum(Us))
    
print(str(min(Vs)))

Submission status: Accepted

Solution code:
a = input()
b = input()

T=1000

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

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

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
 
def main():
    s = input()
    t = input()

    min_num = 10**5
    max_num = 0
    count = 0
    for i in range(len(s) - len(t)+1):
        for j in range(len(t)):
            if s[i+j] == t[j]:
                count += 1
        if max_num <= count:
            max_num = count
        count = 0

    print(len(t) - max_num)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

min_m = len(T)
dif = range(len(S)-min_m+1)

for j in dif:
  St = S[j:len(T)+j]
  miss = 0
  for i in range(len(T)):
    if St[i] != T[i]:
      miss += 1
  if miss < min_m:
    min_m = miss

print(min_m)

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(ans, tmp)
  
print(ans)

Submission status: Accepted

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

S = input()
T = input()

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

Submission status: Accepted

Solution code:
def main():
    s, t = input(), input()
    ans = len(t)
    for i in range(len(s) - len(t)+1):
        substr = s[i:i+len(t)]
        diff = 0
        for a, b in zip(substr, t):
            if a != b:
                diff += 1
        if ans > diff:
            ans = diff
    print(ans)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
s=str(input())
s1=str(input())
l=[]
for i in range(0,len(s)-len(s1)+1):
    e=s[i:i+len(s1)]
    f=0
    for j in range(0,len(e)):
        if(e[j]!=s1[j]):
            f=f+1
    l.append(f)
print(min(l))

Submission status: Accepted

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

ans=10*100

for i in range(len(s)):
  ss=len(t)+i
  a=s[i:ss]
  if len(t) != len(a):
    continue
  aaa=0
  for j in range(len(t)):
    if t[j] != a[j]:
      aaa+=1
  ans=min(ans,aaa)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
count = []
for k in range(0,len(S)-len(T)+1):
    sum = 0
    for i in range(k,k+len(T)):
        if (S[i] != T[i-k]):
            sum += 1
    count.append(sum)

print(min(count))

Submission status: Accepted

Solution code:
S = input()
T = input()
 
ans = 1000
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().rstrip()
T = input().rstrip()

ans = 1000
for offset in range(len(S) - len(T) + 1):
    miss = 0
    for s, t in zip(S[offset:offset+len(T)], T):
        if s != t:
            miss += 1
    ans = min(ans, miss)

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
n = len(T)
ans = len(T)
for st in range(0, len(S)-len(T)+1):
    SS = S[st:st+len(T)]
    tmp = len(T)
    for s,t in zip(SS,T):
        if s==t:
            tmp -= 1
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
s = input()
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
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

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

S_len = len(S)
T_len = len(T)
A_sum = []
count = 0

for i in range(S_len - T_len + 1):
    for j in range(T_len):
        if S[i+j] == T[j]:
            count += 1
    A_sum.append(count)
    count = 0

ans = T_len - max(A_sum) 

print(ans)

Submission status: Accepted

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

INF = 10**9

s = input()
t = input()
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)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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