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: Time Limit Exceeded

Solution code:
import sys

s = input()
t = input()

if t in s:
  print(0)
  sys.exit()

s1={i for i in s}
s2={i for i in t}
if len(s1&s2)==0:
  print(len(t))
  sys.exit()

unmatch=10000

for i in range(len(t)):

  for j in range(i,len(s)-(len(t)-i-1)):

    if t[i] == s[j]:
      buf=i
      for l in range(len(t)-i-1):
        if t[i+l+1] != s[j+l+1]:
          buf+=1
          
      if buf < unmatch:
        unmatch=buf
if unmatch==10000:
  print(len(t))
else:
  print(unmatch)

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(t)):
        for j in range(len(s)):
            if t[i] == s[j]:
                if ((len(t) - i) <= (len(s) - j)) and i <= j:
                    k = i + 1
                    l = j + 1
                    cnt1 = 0
                    while k < len(t):
                        if t[k] != s[l]:
                            cnt1 += 1
                        k += 1
                        l += 1
                    k = i - 1
                    l = j - 1
                    cnt2 = 0
                    while k >= 0:
                        if t[k] != s[l]:
                            cnt2 += 1
                        k -= 1
                        l -= 1
                    ans = min(ans, cnt1 + cnt2)  
                else:
                    if ((len(t) - i) > (len(s) - j)):
                        break
               
    print(ans)

Submission status: Time Limit Exceeded

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

for i in range(len(t)):
  j = i
  while j < len(s) - i:
    if t[i] == s[j]:
      count = 0
      
      s_rem = len(s) - j
      t_rem = len(t) - i
      
      if t_rem > s_rem:
        j += 1
        continue
      
      k = 0
      while k < len(t):
        if t[k] == s[j-i+k]:
          count += 1
        k += 1
      ans = min(ans, len(t) - count)
    j += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(t)):
        for j in range(len(s)):
            if t[i] == s[j]:
                if ((len(t) - i) <= (len(s) - j)) and i <= j:
                    k = i + 1
                    l = j + 1
                    cnt1 = 0
                    while k < len(t):
                        if t[k] != s[l]:
                            cnt1 += 1
                        k += 1
                        l += 1
                    k = i - 1
                    l = j - 1
                    cnt2 = 0
                    while k >= 0:
                        if t[k] != s[l]:
                            cnt2 += 1
                        k -= 1
                        l -= 1
                    ans = min(ans, cnt1 + cnt2)  
                else:
                  if ((len(t) - i) > (len(s) - j)):
                    break
               
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(t)):
        for j in range(len(s)):
            if t[i] == s[j]:
                if ((len(t) - i) <= (len(s) - j)) and i <= j:
                    k = i + 1
                    l = j + 1
                    cnt1 = 0
                    while k < len(t):
                        if t[k] != s[l]:
                            cnt1 += 1
                        k += 1
                        l += 1
                    k = i - 1
                    l = j - 1
                    cnt2 = 0
                    while k >= 0:
                        if t[k] != s[l]:
                            cnt2 += 1
                        k -= 1
                        l -= 1
                    ans = min(ans, cnt1 + cnt2)  
                 
               
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

s = input()
t = input()

if t in s:
  print(0)
  sys.exit()

unmatch=10000

for i in range(len(t)):

  for j in range(i,len(s)-(len(t)-i-1)):

    if t[i] == s[j]:
      buf=i
      for l in range(len(t)-i-1):
        if t[i+l+1] != s[j+l+1]:
          buf+=1
          
      if buf < unmatch:
        unmatch=buf
if unmatch==10000:
  print(len(t))
else:
  print(unmatch)

Submission status: Time Limit Exceeded

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

count = len(T)

for i in range(len(T)):
    for j in range(len(S)):
        if T[i] == S[j]:
            start = j - i
            end = j + (len(T) - i)
            if start < 0 or end > len(S):
                continue
            else:
                s = S[start:end]
                c = 0
                for k in range(len(T)):
                    if T[k] != s[k]:
                        c += 1
                count = min(count, c)
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

s = input()
t = input()

unmatch=10000

for i in range(len(t)):

  for j in range(i,len(s)-(len(t)-i-1)):

    if t[i] == s[j]:
      buf=i
      for l in range(len(t)-i-1):
        if t[i+l+1] != s[j+l+1]:
          buf+=1
      if buf == 0:
        print(buf)
        sys.exit()
      else:
        if buf < unmatch:
          unmatch=buf
if unmatch==10000:
  print(len(t))
else:
  print(unmatch)

Submission status: Time Limit Exceeded

Solution code:
import re
if __name__ == '__main__':
    s = input()
    t = input()

    str_mat = [list('.'*len(t)), list(t)]

    bin_str_dict = {}
    for i in range(0, 2 ** len(t)):
        bin_str = format(i, 'b').zfill(len(t))
        if not bin_str.count('0') in bin_str_dict:
            bin_str_dict[bin_str.count('0')] = [bin_str]
        else:
            bin_str_dict[bin_str.count('0')].append(bin_str)

    def judge(i):
        for pattern in bin_str_dict[i]:
            pattern = ''.join([str_mat[int(bin_num)][index] for index, bin_num in enumerate(pattern)])
            if re.search(pattern, s):
                return True
        return False

    for i in range(0, len(t)):
        flag = judge(i)
        if flag:
            print(i)
            break
    if not flag:
        print(len(t))

Submission status: Time Limit Exceeded

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

def count_ans(a,b):    
    ans = 0
    for k in range(len(a)):
        for l in range(len(b)):
            if k==l and a[k]==b[l]:
                ans += 1
    return ans

ans = 0
for i in range(len(s)-len(t)+1):
    ans_ = count_ans(s[i:i+len(t)],t)
    if ans < ans_:
        ans = ans_

print(len(t)-ans)

Submission status: Time Limit Exceeded

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

def count_ans(a,b):    
    ans = 0
    for k in range(len(a)):
        for l in range(len(b)):
            if k==l and a[k]==b[l]:
                ans += 1
    return ans

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

print(len(t)-ans)

Submission status: Time Limit Exceeded

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

for i in range(len(T)):
    for j in range(len(S)):
        if j < i or len(S) - j < len(T) - i:
            continue;
        
        if S[j] == T[i]:
            copyS = S[j-i:j-i+len(T)]
            countNotEqual = 0
            for k in range(len(copyS)):
                if copyS[k] != T[k]:
                    countNotEqual += 1
            if countNotEqual < maxCount:
                maxCount = countNotEqual
print(maxCount)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import re
from itertools import combinations


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    S = _in[0]  # type:str
    T = _in[1]  # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    if T in S:
        ans = 0
    else:
        for i in range(len(T)):
            ans = i + 1
            index = [j for j in range(len(T))]
            comb = list(combinations(index, i+1))

            for _comb in comb:
                t = list(T)
                for _i in _comb:
                    t[_i] = r'(\w)'
                t = r''.join(t)
                if re.search(t, S):
                    break
            else:
                continue
            break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import re
if __name__ == '__main__':
    s = input()
    t = input()

    str_mat = [list('.'*len(t)), list(t)]
    min = len(t)

    for i in range(2**len(t)-1, -1, -1):
        bin_str = format(i, 'b').zfill(len(t))
        indices = map(int, list(bin_str))
        pattern = ''.join([str_mat[index][num] for num, index in enumerate(indices)])
        m = re.search(pattern, s)
        if m:
            tmp = bin_str.count('0')
            if min > tmp:
                min = tmp
    print(min)

Submission status: Time Limit Exceeded

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

for i in range(len(T)):
    for j in range(len(S)):
        if S[j] == T[i]:
            if j >= i and len(S)-j >= len(T)-i:
                copyS = S[j-i:j-i+len(T)]
                countNotEqual = 0
                for k in range(len(copyS)):
                    if copyS[k] != T[k]:
                        countNotEqual += 1
                if countNotEqual < maxCount:
                    maxCount = countNotEqual
print(maxCount)

Submission status: Time Limit Exceeded

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

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

t_max = 10000
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        tmp = func(s[i:i+len(t)], t)
        if tmp < t_max:
            t_max = tmp
print(t_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

t_max = 10000
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        tmp = func(s[i:i+len(t)], t)
        if tmp < t_max:
            t_max = tmp
print(t_max)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T) + 1))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
    s = tuple(input())
    t = tuple(input())
    s_len = len(s)
    t_len = len(t)
    r = s_len
    for i1 in range(s_len - t_len + 1):
        s2 = s[i1:i1 + t_len + 1]
        tmp0 = sum([se != te for se, te in zip(s2, t)])
        r = min(r, tmp0)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input("")
t = input("")
k = 0

if len(s) == len(t):
    s += "?"

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

print(len(t)-k)

Submission status: Accepted

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

ans = 10000

for i in range(len(s)-len(t)+1):
    cnt = 0
    S = s[i:i+len(t)]
    for j in range(len(t)):
        if S[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):
    count = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            count += 1
    # print(count)
    ans = min(ans, count)

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
l = []
for i in range(len(s)-len(t)+1):
  cha = 0
  for j in range(len(t)):
    if s[j+i] == t[j]:
      cha += 1
  l.append(cha)
print(len(t)-max(l))

Submission status: Accepted

Solution code:
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

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

if __name__=='__main__':
    s = S()
    t = S()
    solve()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

s = len(S)
t = len(T)
m = 10 ** 4

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def substring(s, t):
    min = 10000    # 変更数の最小
    startIdx = 0   # arraySのstartインデックス
    arrayIdx = 0   # arraySのインデックス
    arrayS = []
    arrayT = []
    
    for item in s:
        arrayS.append(item)

    # Sの文字列-Tの文字列+1回ループ
    loopCnt = len(s) - len(t) + 1
    for i in range(0, loopCnt):
        count = 0       # 変更数

        arrayIdx = startIdx

        for item in t:
            if not item == arrayS[arrayIdx]:
                count += 1
            arrayIdx += 1

        if count < min:
            min = count
        
        startIdx += 1

    print(min)


        

s = input()
t = input()

substring(s, t)

Submission status: Accepted

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

min_length = 10000
len_def = len(S) - len(T)
for i in range(len_def + 1):
    counter = 0
    for j in range(len(T)):
        if S[j + i] != T[j]:
            counter += 1

    if counter < min_length:
        min_length = counter
print(min_length)

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=int(len(s))
for i in range(len(s)-len(t)+1):
    now=int(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()

res = 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
  res = max(res,count)

print(len(t)- res)

Submission status: Accepted

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

l = len(t)
n = len(s) - len(t)

def count_diffs(lhs, rhs):
    return len(list(filter(lambda t: t[0] != t[1], zip(lhs, rhs))))

min_diff = l

for i in range(n):
    diff = count_diffs(s[i : i + l], t)

    if diff < min_diff:
        min_diff = diff

if n != 0:
    print(min_diff)

else:
    print(count_diffs(s, t))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
match_cnt = 0

S = input()
T = input()

S_len = len(S)
T_len = len(T)

for S_idx in range(S_len - T_len + 1):
  cnt = 0

  for T_idx in range(T_len):
    if(S[S_idx + T_idx] == T[T_idx]):
      cnt += 1
  
  if( cnt > match_cnt ):
    match_cnt = cnt

print(T_len - match_cnt)

Submission status: Accepted

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

def count_diff(s, t):
    N = 0
    for i, j in zip(s, t):
        if i != j:
            N += 1
    return N


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

res = nt
for i in range(ns - nt + 1):
    sub = S[i:i+nt]
    a = count_diff(sub, T)
    if a < res:
        res = a

print(res)

Submission status: Accepted

Solution code:
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
            
    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

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

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

print(len(t)-res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(word1, word2):
	n1, n2 = len(word1), len(word2)
	res = []
	
	for i in range(n1 - n2 + 1):
		cur_s = word1[i : i + n2]
		res.append(sum(cur_s[j] != word2[j] for j in range(len(cur_s))))
	
	return min(res)
  
s = input()
p = input()
print(solve(s, p))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = len(s)

for i in range(len(s) - len(t) + 1):
    sub = s[i:i+len(t)]
    ans = min(ans, len(t) - sum(a == b for a, b in zip(sub, t)))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    s = input()
    t = input()
    min = int(1e9)
    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 min > cnt:
            min = cnt
    print(min)
            
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

s = str(input())
t = str(input())


# 全探索
k = len(t)
li = []
for i in range(len(s) - len(t) + 1):
    # print(i)
    tmp = k
    for l in range( k ):
        if t[l] == s[i+l]:
            tmp -= 1
    li.append(tmp)
print(min(li))

Submission status: Accepted

Solution code:

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

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

        ans = min(ans, m)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

m = 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
    m = max(m, cnt)

ANS = len(T) - m

print(ANS)

Submission status: Accepted

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

a = []

for i in range(len(s) - len(t) + 1):
    w = s[i:i + len(t)]
    sum = 0
    for j in range(len(t)):
        if w[j] != t[j]:
            sum += 1
    a.append(sum)

print(min(a))

Submission status: Accepted

Solution code:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

S = input()
T = input()
lenS = len(S)
lenT = len(T)

difmin = float("inf")
for si in range(lenS - lenT + 1):
    dif = 0
    for s, t in zip(S[si:], T):
        if s != t:
            dif += 1
    difmin = min(difmin, dif)

print(difmin)

Submission status: Accepted

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

ans = []

for i in range(0, len(s) - len(t) + 1):
  score = 0
  # sをtと同じ文字列分、切り取る
  u = s[i:i + len(t)]
  for j in range(len(t)):
    # 切り取った文字列のsとtが同じかどうか比較する
    if u[j] != t[j]:
      score += 1
  ans.append(score)

print(min(ans))

Submission status: Accepted

Solution code:
s = input()
t = input()
change = len(t)
for x in range(len(s) - len(t) + 1):
    temp_change = 0
    for y in range(len(t)):
        if s[x+y] != t[y]:
            temp_change += 1
    if change > temp_change:
        change = temp_change
print(change)

Submission status: Accepted

Solution code:
                                                                                                                                                      
                                                                                                                                                       
                                                                                                                                                       
S=list(input())                                                                                                                                        
T=list(input())                                                                                                                                        
                                                                                                                                                       
T_size = len(T)                                                                                                                                        
                                                                                                                                                       
def match_num(x):                                                                                                                                      
    return T_size - sum([1 for a,t in zip(x, T) if a==t])                                                                                              
                                                                                                                                                       
b=[]                                                                                                                                                   
for i in range(len(S)-T_size+1):                                                                                                                       
    b.append(match_num(S[i:i+T_size]))                                                                                                                 
                                                                                                                                                       
print(min(b))

Submission status: Accepted

Solution code:
s, t = [input() for i in range(2)]
ans = float("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
        if ans  > cnt:
                ans = cnt
print(ans)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    ans = 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
        ans = min(ans, count)
    print(ans)
        
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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

result =0
index = 0
Min = len(T)

while True:
    sum = 0
    temp = S[index : index + len(T)]
    
    for i in range (len(T)):
        if temp[i] != T[i]:
            sum+=1
    
    Min = min(Min,sum)
    
    index +=1
    
    if index + len(T) >  len(S):
        break
    
print(Min)

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):
    cnt = 0
    for j in range(0, LT):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())
#a, b = map(int, input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)


#a[始まりの位置: 終わりの位置: スライスの増分] # (a は配列)


#import numpy as np  #importに100 ms 程度かかる。
import math
import copy
import string
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = int(10**18) #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。
#np.gcd.reduce(A) #(Aは配列) で、Aの全ての要素の gcd が計算できる。





S = input()
T = input()

NS = len(S)
NT = len(T)


res = NT
for i in range(0, NS - NT + 1):
    tempo = 0
    for j in range(0, NT):
            if S[i + j] != T[j]: tempo += 1   
    res = min(res, tempo)
print(res)

Submission status: Accepted

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

ans = len(t)

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

print(ans)

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,t=input(),input()
ans=len(t)
"""
s[x]から、t文字分探索。tと一致しない箇所があればtmpをプラス。
tmpの合計は直さなくてはいけない文字の数だから、tmpの各合計の中で最も小さい数が答え。
"""
for x in range(len(s)-len(t)+1):
    tmp=0
    for y in range(len(t)):
        if s[x+y]!=t[y]:
            tmp+=1
    ans=min(ans,tmp)        
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
Ns = len(S)
Nt = len(T)

ans = 0
for i in range(Ns - Nt + 1):
    tmp = 0
    for j in range(Nt):
        if S[i + j] == T[j]:
            tmp += 1
        ans = max(ans, tmp)
print(Nt - ans)

Submission status: Accepted

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

Submission status: Accepted

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


max_change = len(t)
for start in range(len(s) - len(t) +1):
    diff =0
    for i in range(len(t)):
        if s[start + i] != t[i]:
            diff += 1
    if diff <= max_change:
        max_change = diff
print(max_change)

Submission status: Accepted

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


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

    ans = float("inf")

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

    print(ans)


main()

Submission status: Accepted

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

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

    if ans > tmp:
        ans = tmp
print(ans)

Submission status: Accepted

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