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:
if __name__ == "__main__":
    s = input()
    t = input()

    test1  = len(s) - len(t) + 1

    test3 = []
    for i in range(test1):
        test2 = s[i:i+len(t)]
        test4 = 0
        for j in range(len(test2)):
            if test2[j] == t[j]:
                test4 += 1
        test3.append(test4)

    print(len(t)-max(test3))

Submission status: Accepted

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

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len + 1):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
  temp = 0

print(t_len - max_)

Submission status: Accepted

Solution code:
s = input()
t = input()
if t in s:
    print(0)
else:
    count = 0
    val = 10001
    for j in range(len(s)-len(t)+1):
        k = 0
        count= 0
        for i in range(j,len(t)+j):
            if s[i]!=t[k]:
                count+=1
            k+=1
        val = min(val,count)
    print(val)

Submission status: Accepted

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

min = len(t)

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

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
b=0
c=len(T)


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

max = 0
max_i = 0
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
    if cnt > max:
        max = cnt
        max_i = i
        ans = len(T) - max

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
count = 0
lenS = len(S)
lenT = len(T)
ans = lenT

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

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

    nt = len(T)
    ans = INF
    for i in range(0, len(S)-nt+1):
        # print(i, S[i: i+nt])
        ss = S[i: i+nt]
        cnt = 0
        for j, s in enumerate(ss):
            if s == T[j]:
                pass
            else:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

nmax=len(t)
nmin=len(t)

for i in range(len(s)-nmax+1):
  n=0
  for j in range(nmax):
    if s[i+j]!=t[j]:
      n=n+1
    if n==nmin:
      break
      
  nmin=n
  if nmin==0:
    break
print(nmin)

Submission status: Accepted

Solution code:
s=input()
t=input()
a=float('inf')
n=0
for i in range(len(s)-len(t)+1):
    n=0
    for ss,tt in zip(s[i:i+len(t)] , t):
        if ss != tt:
            n+=1
    a=min(a,n)
print(a)

Submission status: Accepted

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

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

ma = 0
for i in range(n-m+1):
    tmp = 0
    s_sub = s[i:i+m]
    for j in range(m):
        if s_sub[j] == t[j]:
            tmp += 1
    ma = max(ma, tmp)

print(m - ma)

Submission status: Accepted

Solution code:

S = str(input())
T = str(input())
x = 0
ans = 100000000

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np

(S,) = input().split()
(T,) = input().split()


ans = 10000
for i in range(len(S) - len(T) + 1):
    cnt = 0
    tmp = S[0 + i : len(T) + i]
    for s, t in zip(tmp, T):
        if s != t:
            cnt += 1
    if cnt == 0:
        ans = 0
        break
    else:
        if ans > cnt:
            ans = cnt


print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()
SN = len(S)
TN = len(T)
m = 0

for i in range(SN-TN+1):
    t = 0
    for j in range(TN):
        if T[j]==S[i+j]:
            t += 1
    m = max(m,t)
print(TN-m)

Submission status: Accepted

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

ans = float("inf")
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
    
    ans = min(ans, mismatch)

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
substis = []
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
    substis.append(len(T)-count)
print(min(substis))

Submission status: Accepted

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

import sys

def n_gram(target, n):
    return [ target[idx:idx + n] for idx in range(len(target) - n + 1)]

def main():
    s = input()
    t = input()
    ans_list=[]
    ans=[]
    count=0

    ans_list=n_gram(s,len(t))

    for word in ans_list:
        for str1,str2 in zip(word,t):
            if str1==str2:
                count+=1
        ans.append(count)
        count=0
    print(len(t)-max(ans))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
t = S()
if s == t:
    print(0)
    exit()

ans = len(t)
for i in range(len(s)-len(t)+1):
    # print(f'{i=}')
    now = 0
    for j in range(len(t)):
        # print(f'{(s[i+j], t[j])=}')
        if s[i+j] != t[j]:
            now += 1
    # print(f'{now=}')
    ans = min(ans, now)

print(ans)

Submission status: Accepted

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

len_s = len(s)
len_t = len(t)
count = 0
biggest = 0

for i in range(len_s-len_t+1):
  now = s[i:i+len_t]

  for j in range(len_t):
    if t[j] == now[j]:
      count += 1
      
  if biggest < count:
    biggest = count
    count = 0
  else:
    count = 0
    
print(len_t - biggest)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


# 1文字ずつ探してなん文字合致するかカウントする
lenT = len(T)
maxCount = 0
for i in range(len(S) - lenT + 1):
    token = S[i:i + lenT]
    count = matchCount(token, T)
    if count > maxCount:
        maxCount = count

print(lenT - maxCount)

Submission status: Accepted

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

dist = len(T)

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

print(dist)

Submission status: Accepted

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

ss = len(S)
tt = len(T)

count = 0
res = []


for i in range(ss-tt+1):
    for j in range(tt):
        if S[i+j] != T[j]:
            count += 1
    res.append(count)
    count = 0

print(min(res))

Submission status: Accepted

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

n = [0]*(len(s) - len(t) + 1)

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

print(len(t) - max(n))

Submission status: Accepted

Solution code:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


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


def II():
    return int(input())


def nitti(x, y):
    count = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            count += 1
    return count


S = input()
T = input()


lt = len(T)
res = 0
for i in range(0, len(S)-len(T)+1):
    res = max(res, nitti(S[i:(i+lt-1)], T))
    #print(i, S[i:(i+lt-1)], T)


print(lt-res-1)

Submission status: Accepted

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

len_s = len(s)
len_t = len(t)

max_score = 0
for i in range(len(s)-len(t)+1):
    match = zip(t, s[i:i+len_t])
    score = sum([1 for x in match if x[0]==x[1]])
    max_score = max(max_score, score)
print(len_t - max_score)

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    T = input()
    mincnt = float("inf")
    for ptr in range(len(S)-len(T)+1):
        cnt = 0
        for i in range(len(T)):
            sptr = ptr + i
            if S[sptr] != T[i]:
                cnt += 1
        mincnt = min(cnt, mincnt)
    print(mincnt)



    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
def solve():
    S = input()
    T = input()
    ans = len(T)
    if (len(S) == len(T)):
        tmp = 0
        for j in range(len(T)):
            if S[j] != T[j]:
                tmp += 1
        ans = tmp
    else:
        for i in range(len(S) - len(T)):
            tmp = 0
            for j in range(len(T)):
                if S[j + i] != T[j]:
                    tmp += 1
            ans = min(ans, tmp)
    print(ans)
        

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
A = []
count = 0

for x in range(0, len(S)-len(T)+1):
    for y in range(0, len(T)):
        if(S[x+y] != T[y]):
            count += 1
        else:
            pass
    A.append(count)
    count = 0

print(min(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
s = input()
t = input()
Min = len(t)

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


print(Min)

Submission status: Accepted

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

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

j = 0
while j+t_len <= s_len:
    sub_s = s[j:j+t_len]
    
    count = 0
    for i in range(t_len):
        if sub_s[i] != t[i]:
            count += 1
            
    if count < min_count:
        min_count = count

    j+=1
        
print(min_count)

Submission status: Accepted

Solution code:
import sys

S = input()
T = input()

if len(S) == len(T):
    changeCounter = 0
    for j in range(len(S)):
        if not S[j] == T[j]:
            changeCounter += 1
    print(changeCounter)
    sys.exit()

minChangeCounter = 1000000
for i in range(len(S) - len(T)):
    substr = S[i:i + len(T)]
    changeCounter = 0
    for j in range(len(T)):
        if not substr[j] == T[j]:
            changeCounter += 1
    if changeCounter < minChangeCounter: minChangeCounter = changeCounter
print(minChangeCounter)

Submission status: Accepted

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

match_n = 0
for i in range(len(S)):
    match_n_sub = 0
    if i <= len(S)-len(T):
        for j in range(0, len(T)):
            if S[i+j] == T[j]:
                match_n_sub += 1
    match_n = max(match_n, match_n_sub)

print(len(T)-match_n)

Submission status: Accepted

Solution code:
s=input()
n1=len(s)
t=input()
n=len(t)
mini=int(1e9)
start=0
end=n-1
md=0
while end!=n1:
    md=0
    j=0
    for i in range(start,end+1,1):
        if s[i]!=t[j]:
            md+=1
        j+=1
    mini=min(mini,md)
    start+=1
    end+=1
print(mini)

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

T_length = len(T)
max_count = 0

for i in range(len(S)-T_length+1):
  count = 0
  for j in range(T_length):
    if S[i:i + T_length][j] == T[j]:
      count += 1
  else:
    if max_count < count:
      max_count = count

print(T_length - max_count)

Submission status: Accepted

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

cnt = 10 ** 9
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if i + j < len(S) and S[i + j] == T[j]:
            continue
        else:
            tmp += 1
    cnt = min(cnt, tmp)

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_n = input()
n = str(input_n)

listS = list(n)
#listN = n.split(' ')

input_m = input()
m = str(input_m)

listT = list(m)

min = 10000

if (len(listS) - len(listT)) == 0:
    tmp = 0
    for j in range(len(listT)):
        if listS[j] != listT[j]:
            tmp += 1
    if tmp < min:
        min = tmp

for i in range(len(listS) - len(listT)):
    tmp = 0
    for j in range(len(listT)):
        if listS[i + j] != listT[j]:
            tmp += 1
    if tmp < min:
        min = tmp

print(str(min))

Submission status: Accepted

Solution code:
s=input()
t=input()
sl=len(s)
tl=len(t)

cnt=0
ans=0

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

print(tl-ans)

Submission status: Accepted

Solution code:
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
s=input()
t=input()
ans=0
flag=0
for j in range(len(s)-len(t)+1):
    flag=0
    for i in range(len(t)):
        if s[i+j]==t[i]:
            flag=flag+1
    if flag>ans:
        ans=flag
print(len(t)-ans)

Submission status: Accepted

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

x = lt
for i in range(0,ls-lt+1):
    m = 0
    for j in range(lt):
        if T[j] != S[i+j]:
            m += 1
    x = min(x,m)

print(x)

Submission status: Accepted

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

best_num_char=0
for i in range(len(S)-len(T)+1):
    # print(T[i:])
    num_char=0
    for j in range(len(T)):
        num_char+=1 if S[i+j]==T[j] else 0
        # print(num_char,S[i + j])
    if best_num_char<num_char:
        best_num_char=num_char

# print(len(T))
print(len(T)-best_num_char)

Submission status: Accepted

Solution code:
input_list = [input() for i in range(2)]
M = input_list[0]
N = input_list[1]

ans = []

for i in range(len(M)-len(N)+1):

    num = 0

    substring = input_list[0][i:i+len(N)]

    for j in range(len(N)):

        if substring[j] != N[j]:

            num += 1

    ans.append(num)

print(min(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

match_ans = 0

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

print(len(t) - match_ans)

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
r=tn=len(t)
for u in (s[i:i+tn] for i in range(len(s)-tn+1)):
	k=0
	for i,j in zip(u,t):
		k+=(i!=j)
	r=min(r,k)
print(r)

Submission status: Accepted

Solution code:
#B - Substring
S = input()
T = input()
ans = 10**9
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
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)

Submission status: Accepted

Solution code:
S=input()
T=input()
a=len(S)
b=len(T)
m=a-b
ans=b
if m!=0:
    for i in range(m):
        cnt=b
        for j in range(b):
            if S[i+j]==T[j]:
                cnt-=1
        ans=min(cnt,ans)
else:
    cnt=b
    for i in range(a):
        if S[i]==T[i]:
            cnt-=1
    ans=min(cnt,ans)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import Counter,deque
import math
cin = stdin.readline
cout = stdout.write
def inpn():
    return(int(cin()))
def inpl():
    return(list(map(int,cin().split())))
def inps():
    return cin()[:-1]
def inpv():
    return (map(int, cin().split()))
def outs(s):
    cout(s)
def outn(n):
    cout(str(n))
def outl(l):
    for i in l:
        cout(str(i)+" ")
def outb(s):
    cout(str(s))


# n = inpn()
# l=inpl()
# m=1000000007
# add=0
# for i in range(n-1):
#     for j in range(i+1,n):
#         add+=(l[i]%m*l[j]%m)%m
#
# outn(add%m)
# cout("\n")

s=inps()
t=inps()
ans=1000
if t in s:
    outn(0)
    cout("\n")
else:
    if len(s)!=len(t):
        for i in range(len(s)-len(t)):
            count=0
            for j in range(len(t)):
                if s[i+j]!=t[j]:
                    count+=1
            ans=min(ans, count)
        outn(ans)
        cout("\n")
    else:
        ans=0
        for i in range(len(s)):
            if s[i]!=t[i]:
                ans+=1
        outn(ans)
        cout("\n")

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
S,T = [S() for _ in range(2)]
num = 0
for i in range(len(S)-len(T)+1):
    str = S[i:i+len(T)]
    count = 0
    for j in range(len(T)):
        if str[j]==T[j]:
            count += 1
        num = max(num,count)
print(len(T)-num)

Submission status: Accepted

Solution code:
S = input()
T = input()
min_diff = len(T)
for i in range(0,len(S)-len(T)+1):
    diff = 0
    for j in range(0,len(T)):
        if S[i+j] != T[j]:
            diff += 1
    else:
        min_diff = diff if min_diff > diff else min_diff
print(min_diff)

Submission status: Accepted

Solution code:
S = input()
T = input()
Ans = len(T)
for i in range(len(S)-len(T)+1):
    d = 0
    for j in range(len(T)):
        if T[j] != S[i:i+len(T)][j]:
            d += 1
    if d <= Ans:
        Ans = d

print(Ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
d = len(S) - len(T)
print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + len(T) + 1])) for i in range(d + 1)))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

maxtmp = 0
if len(S) == 1:
    if T in S:
        print(0)
    else:
        print(1)
else:
    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 maxtmp < tmp:
            maxtmp = tmp
    print(len(T) - maxtmp)

Submission status: Accepted

Solution code:
s = input()
t = input()
minr = len(t)
s_t_d = len(s) - len(t)
for i in range(s_t_d + 1):
    cnt = 0
    for ss, ts in zip(s[i:i + len(t)], t):
        if ss != ts:
            cnt += 1
    minr = min(minr, cnt)
print(minr)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
Snagasa = len(S)
Tnagasa = len(T)
saisyuicchi = 0
for i in range (Snagasa-Tnagasa+1):
 icchi = 0
 for j in range (Tnagasa):
  if S[i+j] == T[j]:
   icchi = icchi + 1
  else:
   icchi = icchi
 if icchi > saisyuicchi:
  saisyuicchi = icchi
ans = Tnagasa - saisyuicchi
print (ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
m = 0
for i in range(len(s)-len(t)+1):
    x = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            x+=1
    if x > m:
        m = x
ans = len(t)-m
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
from operator import mul
from functools import reduce
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


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

min_ = 0
max_ = len(T)
# len(S) - len(T) + 1
for x in range(max_+1):
    # x文字置き換えて良い
    for i in range(len(S) - len(T) + 1):
        count = 0
        for (a, b) in zip(T, S[i:i + len(T)]):
            if (a == b):
                count += 1
        if (count+x >= len(T)):
            print(x)
            exit()

Submission status: Accepted

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

Submission status: Accepted

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

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

min_count = float('inf')
for i in range(len_S - len_T + 1):
    # print(S[i:i+len(T)])
    match = 0
    for j in range(len_T):

        if T[j] == S[i + j]:
            match += 1
    min_count = min(len_T-match, min_count)
print(min_count)

Submission status: Accepted

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

r=len(t)
for ii in range(len(s)-len(t)+1):
  rr=0
  for jj in range(len(t)):
    if s[ii+jj]!=t[jj]:
      rr+=1
  if rr<r:
    r=rr
print(r)

Submission status: Accepted

Solution code:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

s = inp()
t = inp()

total = 10**9

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

print(total)

Submission status: Accepted

Solution code:
S = input()
T = input()
count = 0
if T in S:
    print(0)
else:
    #SのなかでTを動かしていき最大マッチ数を考える
    for i in range(len(S)-len(T)+1):
        check = S[i:len(T)+i-1]
        point = 0
        for w1, w2 in zip(T, check):
            if w1 == w2:
                point += 1
        if point > count:
            count = point
    print(len(T)-count)

Submission status: Accepted

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

lens = len(s)
lent = len(t)

con = lent;

for x in range(lens - lent + 1):
    zz = 0;
    for y in range(lent):
        if s[x+y] != t[y]:
            zz += 1;
    if zz < con:
        con = zz;

print(con)

Submission status: Accepted

Solution code:
S = input()
T = input()
m = 0
lt = len(T)
for i in range(len(S)- lt+1):
    pm = 0
    ps = S[i:lt+i]
    for j in range(lt):
          if ps[j] == T[j]:
               pm += 1
    m = max(m,pm)
              #m = max(m,len(T[i:j]))
print(len(T)-m)

Submission status: Accepted

Solution code:
S=input()
T=input()
count=0
min=1000000
for i in range(len(S)):
    count = 0
    if i + len(T) <= len(S):
        for j in range(len(T)):
            if T[j] != S[i + j]:
                count += 1
    else:
        break

    if count<min:
        min=count

print(min)

Submission status: Accepted

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

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


ans = 1e10

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

print(ans)

Submission status: Accepted

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

maxt = len(t)

for i in range(0,len(s) - len(t) +1):
    s_part = s[i:i+len(t)+1]
    n=0
    for tt,ss in zip(t,s_part):
        if tt==ss:
            n+=1
    maxt =min(maxt,len(t)-n)
print(maxt)

Submission status: Accepted

Solution code:
s = input()
t = input()
mini = -1 
for i in range(len(s) - len(t)+1):
    temp = 0
    for j in range(len(t)):
        if(s[j + i] != t[j]):
            temp+=1
    if(mini == -1 or temp < mini):
        mini = temp
print(mini)

Submission status: Accepted

Solution code:
S = input()
T = input()
len_S = len(S) - len(T)

ans = 0

for i in range(len_S+1):
    temp = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            temp += 1
    ans = max(ans,temp)

print(len(T)-ans)

Submission status: Accepted

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

ans = len(T)
f = 0
for i in range(len(S)-len(T)+1):
  st = S[f:f+len(T)]
  iti = sum([1 for i,j in zip(st, T) if i == j])
  ans = min(ans, len(T)-iti)
  f += 1
  
print(ans)

Submission status: Accepted

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


def count_diff_chars(s, t):
    """
    文字列s, tの差分がある文字列数を数える
    """
    count = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1
    return count


def count_diff_chars_t(s): return count_diff_chars(s, T)


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


if len_s == len_t:
    print(count_diff_chars_t(S))
else:
    now_min_diff = 1001

    for i in range(len_s - len_t):
        s_ = S[i: len_t + i]
        diff_num = count_diff_chars_t(s_)
        now_min_diff = min(diff_num, now_min_diff)

    print(now_min_diff)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, permutations, combinations, accumulate
from bisect import bisect_left, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor


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


def input_int():
    return int(input())


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