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

print(ans)

Submission status: Accepted

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

num=len(t)
num_2=len(s)-num+1
count_list=[]

for i in range(num_2):
    s_2=s[i:i+num]
    
    count=0
    for j in range(num):
        if t[j]!=s_2[j]:
            count+=1
    count_list.append(count)

print(min(count_list))

Submission status: Accepted

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

Submission status: Accepted

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

ans=1000000
num=len(s)-len(t)
for i in range(num+1):
  r=0
  for j in range(len(t)):
      
    if s[i+j]!=t[j]:
      r+=1
  if r<ans:
      ans=r
print(ans)

Submission status: Accepted

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

sum = 1000
for i in range(len(s)-len(t)+1):
  sch = s[i:i+len(t)]
  tm = 0
  for si in range(len(t)):
    if sch[si] != t[si]:
    	tm += 1
        
  if tm < sum:
    sum = tm
print(sum)

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
NS=len(S)
NT=len(T)
X=[0]*(NS-NT+1)
for i in range(NS-NT+1):
  for ii in range(NT):
    if S[i+ii]==T[ii]:
      X[i]+=1
print(NT-max(X))

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
ans = 1e9

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

print(ans)

Submission status: Accepted

Solution code:
s = list(str(input()))
t = list(str(input()))
l = []
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

    l.append(count)
    count = 0
print(min(l))

Submission status: Accepted

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

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

for i in range(l):
    for j in range(len(t)):
        if s[i+j] != t[j]:
            c[i] += 1

print(min(c))

Submission status: Accepted

Solution code:
def mismatch(x, y) :
    m = 0
    for i in range(len(x)):
        if x[i] != y[i] :
            m += 1
    return m

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


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

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
sl = len(s)
tl = len(t)
ans = 10**8
for i in range(sl-tl+1):
  tmp = s[i:i+tl]
  pen = 0
  for j,k in enumerate(tmp):
    if t[j]!=k: pen += 1
  ans = min(ans,pen)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
c = 0
c_list = []
for i in range(len(s)-len(t)+1):
    #print(s[i:len(t)+i])
    tmp_s = s[i:len(t)+i]
    for j in range(len(t)):
        if(tmp_s[j] == t[j]):
            c += 1
    c_list.append(c)
    c = 0

print(len(t)-max(c_list))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

LS = len(s)
LT = len(t)
# 最長で何文字一致するか
max_match = 0
for i in range(LS - LT + 1):
    ss = s[i:i+LT]
    match = 0
    for a,b in zip(t, ss):
        if a==b:
            match += 1
            max_match = max(max_match, match)

print(LT - max_match)

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    S = str(input()[:-1])
    T = str(input()[:-1])

    ans = 1000

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
k1=10**10
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
    if k<k1:k1=k
print(k1)

Submission status: Accepted

Solution code:
# import math


def get_int_args():
    args = input().split()
    return list(map(int, args)), len(args)


def get_str_args():
    return input().split()


if __name__ == '__main__':
    a, b = input(), input()
    min = 1e10
    for i in range(len(a) - len(b) + 1):
        c = 0
        for j in range(len(b)):
            if a[i + j] != b[j]:
                c += 1
        if c < min:
            min = c
    print(min)

Submission status: Accepted

Solution code:
#B
S = input()
T = input()
def counter(A,B):
    tmp = 0
    for j in range(len(A)):
        if A[j]==B[j]:
            tmp += 1
    return tmp
result = 0
if S == T:
    result = len(T)
else:
    for i in range(len(S)-len(T)+1):
        if counter(S[i:i+len(T)],T) > result:
            result = counter(S[i:i+len(T)],T)
print(len(T)-result)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 10000
for i in range(ls - lt + 1):
    S1 = S[i: i+lt]
    same = 0
    for j in range(lt):
        if S1[j] == T[j]:
            same += 1
    ans = min(ans, lt-same)

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

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

ans = float('inf')
for i in range(len(S)):
    count = 0
    flag = False
    for j in range(len(T)):
        if i+j >= len(S):
            flag = True
            break
        if S[i+j] != T[j]:
            count += 1
    if flag:
        continue
    else:
        ans = min(ans,count)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def common(x, y):
    ans = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            ans += 1
            
    return ans

s = input()
t = input()

m = -1

for i in range(len(s)-len(t)+1):
    r = s[i:i+len(t)]
    m = max(m, common(r, t))
    
print(len(t)-m)

Submission status: Accepted

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

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

print(len(t) - max_count)

Submission status: Accepted

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

s = input()
n = len(s)
t = input()
k = len(t)
ans = 10000
for i in range(n-k+1):
  ans = min(ans,count(s[i:i+k],t))
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
score=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] :
            continue
        elif s[i+j]!=t[j] :
            ans+=1
    score=min(ans,score)

print(score)

Submission status: Accepted

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

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

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

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

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
# t, s = map(str,input().split())

s = input()
t = input()

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

    min_change = min(min_change, change)

print(min_change)

Submission status: Accepted

Solution code:
def resolve():
    s = str(input())
    t = str(input())
    ans = 1000
    tmp = 1000
    for pos in range(len(s)-len(t)+1):
        tmp = 0
        for i in range(len(t)):
            if s[pos+i] != t[i]:
                tmp += 1

        ans = min(ans, tmp)
    print(ans)
    
resolve()

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
O = list()
a = 0
for i in range (len(S) - len(T) + 1):
    b = 0
    m = 0
    for i in range (len(T)):
        if S[b + a] != T[b]:
            m = m + 1
        b = b + 1
    O.append(m)
    a = a + 1
O.sort()
print(O[0])

Submission status: Accepted

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

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

print(m - ans)

Submission status: Accepted

Solution code:
import difflib
S=input()
T=input()
lenT=len(T)
ans=len(T)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(S,T):
    n,m=len(S),len(T)
    i,j=0,m-1
    diff=0
    for k in range(i,j+1):
        if S[k]!=T[k]:
            diff+=1
    best=diff
    i+=1
    j+=1
    while j<n:
        diff=0
        for k,t in enumerate(T):
            if S[i+k]!=t:
                diff+=1
        best=min(diff,best)
        i+=1
        j+=1
    return best

S=input()
T=input()
print(solve(S,T))

Submission status: Accepted

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

for i in range(len(s) - len(t) + 1):
    counter = 0
    for j, char in enumerate(s[i:i + len(t)]):
        if char == t[j]:
            counter += 1
    if change > (len(t) - counter):
        change = len(t) - counter

print(change)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=str(input())
S=list(map(str,S))
T=str(input())
T=list(map(str,T))
Ca=len(T)
for i in range(len(S)-len(T)+1):
  Cb=len(T)
  for j in range(len(T)):
    if S[i+j]==T[j]:
      Cb-=1
  if Ca>Cb:
    Ca=Cb
print(Ca)

Submission status: Accepted

Solution code:
import numpy as np

S=input()
T=input()

length = len(list(T))
S_length = len(list(S))

max_score = 0
for i in range(len(list(S))-len(list(T))):
    tmp_T = np.array(list(T))
    tmp_S = np.array(list(S))[i:i+len(tmp_T)]
    score = np.zeros(len(tmp_T))
    score[tmp_T==tmp_S]=1
    score = np.sum(score)
    if max_score < score:
        max_score=score

if S_length==length:
    tmp_T = np.array(list(T))
    tmp_S = np.array(list(S))
    score = np.zeros(len(tmp_T))
    score[tmp_T==tmp_S]=1
    max_score = np.sum(score)
print(int(length-max_score))

Submission status: Accepted

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

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

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

print(min(a))

Submission status: Accepted

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

ans = float('inf')
for i in range(len(s) - len(t)+1):
    temp = 0
    for _s, _t in zip(s[i:], t):
        if _s != _t: temp+=1
    ans = min(ans, temp)
print(ans)

Submission status: Accepted

Solution code:
first = input()
second = input()

shortest = 100000

for i in range(len(first) - len(second) + 1):
  num_diff = 0
  for j in range(len(second)):
    if first[j+i] != second[j]:
      num_diff += 1

  if shortest > num_diff:
    shortest = num_diff
        
print(shortest)

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

s_list = list(S)
ns = len(s_list)

t_list = list(T)
nt = len(t_list)

max_match = 0
for i in range(ns-nt+1):
    match = 0
    for j in range(nt):
        if t_list[j] == s_list[j+i]:
            match += 1
    if match > max_match:
        max_match = match

ans = nt - max_match

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

Submission status: Accepted

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

num_S = len(S)
num_T = len(T)

N = num_S - num_T + 1
C = [0]*N
for i in range(N):
  A = S[i:i+num_T]
#  print(S[i:i+num_T])
  count = num_T
  for j in range(num_T):
    if T[j] == A[j]:
      count = count - 1
    else:
      None
  C[i] = count
print(min(C))

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
L = len(T)
ans = L
for i in range(len(S)-L+1):
    check = 0
    for j in range(L):
        if(S[i+j] != T[j]):
            check += 1
    if(ans > check):
        ans = check
print(ans)

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
S = input()
T = input()
M = len(S)
N = len(T)

ans = N
for i in range(M-N+1):
    tmp = 0
    for j in range(N):
        if S[i+j] != T[j]:
            tmp += 1
            if tmp >= ans:
                break
    else:
        if tmp < ans:
            ans = tmp
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    s = input().rstrip()
    t = input().rstrip()
    length_s = len(s)
    length_t = len(t)
    res = 0
    
    for i in range(length_s-length_t+1):
        temp = 0
        for j in range(length_t):
            if s[i+j] == t[j]:
                temp+=1
        res = max(res, temp)
    
    print(length_t - res)

    
     
if __name__ == "__main__":
    main()

Submission status: Accepted

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

result = 10**5
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for s, t in zip(S[i: (i + lt)], T):
        if s != t:
            cnt += 1
    result = min(cnt, result)
print(result)

Submission status: Accepted

Solution code:

X = input().strip()
Y = input().strip()

res = float("inf")
for i in range(len(X)-len(Y)+1):
    cnt =0
    for j in range(len(Y)):
        if X[i+j]!=Y[j]:cnt+=1
    res = min(res,cnt)
print(res if res!=float("inf") else 0)

Submission status: Accepted

Solution code:
S=input()
T=input()
sn=len(S)
tn=len(T)

n=sn-tn+1

n_matches=[]
for i in range(n):
  Si=S[i:i+tn]
  n_match=0
  for j in range(tn):
    if Si[j]==T[j]:
      n_match+=1
  n_matches.append(n_match)

print(tn-max(n_matches))

Submission status: Accepted

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

length = len(T)
index = 0
minimum = 1000
count = 0
for i in range(len(S)):
    if length+index > len(S):
        break
    bubun = S[index:length+index]
    for s, t in zip(bubun, T):
        if s != t:
            count += 1
    minimum = min(minimum, count)
    index += 1
    count = 0

print(minimum)

Submission status: Accepted

Solution code:
S = input()
T = input()
num_S = len(S)
num_T = len(T)
match = 0

for i in range(num_S - num_T + 1):
    count = 0
    for j in range(num_T):
        if S[i+j] == T[j]:
            count += 1
    if count > match:
        match = count

print(num_T - match)

Submission status: Accepted

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

def main():
    m = float("inf")
    for i in range(len(s) - len(t) + 1):
        rr = 0
        r = ""
        for j in range(len(t)):
            r += s[i + j]
        for x in range(len(t)):
            if r[x] != t[x]:
                rr += 1
        
        m = min(m, rr)
    print(m)
    return 

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
print(min(sum(1 for a, b in zip(t, s[i:i + len(t)]) if a != b)
          for i in range(len(s) - len(t) + 1)))

Submission status: Accepted

Solution code:
def count_diff(a, b):
    cnt = 0
    for c_a, c_b in zip(a, b):
        if c_a != c_b:
            cnt += 1
    return cnt

S = input()
T = input()

if len(S) == len(T):
    ans = count_diff(S, T)
    print(ans)
    exit()

ans = float('inf')
for i in range(len(S)-len(T)):
    word = S[i:i+len(T)]
    tmp = count_diff(word, T)
    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
def diff(X,Y):
    l=len(X) 
    c=0 
    for i in range(l):
        if X[i]!=Y[i]:
            c+=1 
    return c
s=input() 
t=input() 
i=0 
ans=len(s)
for _ in range(len(s)-len(t)+1):
    ans=min(ans,(diff(s[_:_+len(t)],t))) 
print(ans)

Submission status: Accepted

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

if T in S:
  print(0)
  exit()

def f(s1,s2):
  r=0
  for i,j in zip(s1,s2):
    if i != j: r += 1
  return r

a=len(S)
for i in range(len(S)-len(T)+1):
  r = f(S[i:i+len(T)],T)
  if a > r: a = r

print(a)

Submission status: Accepted

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

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen+1):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

    print(ansCnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s1 = str(input())
s2 = str(input())
diff=[]
for i in range(0,len(s1)-len(s2)+1):
  str1 = s1[i:i+len(s2)]
  #print(str1)
  val=0
  for i in range(len(str1)):
    if(abs(ord(str1[i])-ord(s2[i])) > 0):
      val += 1
  diff.append(val)
print(min(diff))

Submission status: Accepted

Solution code:
import sys


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

def main():
    S =input()
    T =input()
    ls =len(S)
    lt =len(T)

    count = lt
    for i in range(ls-lt+1):
        fixing =0
        for j in range(lt):
            if T[j] !=S[i+j]:
                fixing +=1

        count =min(count,fixing)
    print(count)












if __name__ == "__main__":
    main()

Submission status: Accepted

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

SN = len(S)
TN = len(T)

SL = []
for i in range(SN - TN+1):
    SL.append(S[i : TN+i])

C = []
for s in SL:
    tmp = 0
    for t in range(TN):
        if s[t] != T[t]:
            tmp += 1
    C.append(tmp)

print(min(C))

Submission status: Accepted

Solution code:
s =list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)+1):
    check=0
    s_check=s[i:i+len(t)]
    for k in range(len(s_check)):
        if s_check[k]==t[k]:
            check+=1
    ans.append(check)
print(len(t)-max(ans))

Submission status: Accepted

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

m = 0
for i in range(len(S) - len(T) + 1):
    res = 0
    for a, b in zip(T, S[i:i + len(T)]):
        if a == b:
            res += 1
    if res > m:
        m = res

print(len(T) - m)

Submission status: Accepted

Solution code:
s = input()
t = input()
l = len(s)
t_l = len(t)
l_gap = l - t_l

x = 0
for i in range(l_gap + 1):
  c = 0
  for m in range(t_l):
    if t[m] == s[i+m]:
      c += 1
  if c > x:
    x = c
print(t_l -x)

Submission status: Accepted

Solution code:
s = input()
t = input()
min_num = len(t)
for i in range(len(s)-len(t)+1):
    num = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            num += 1
    if min_num >= num:
        min_num = num

print(min_num)

Submission status: Accepted

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

i = 0
ans = []
while i <= len(s) - len(t):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    ans.append(cnt)
    i += 1

print(min(ans))

Submission status: Accepted

Solution code:
s = input()
t = input()
m = []

for i in range(len(s)):
    a = s[i:len(t)+i]
    if  len(a) < len(t):
        break
    else:
        cnt = 0
        for x,y in zip(a,t):
            if x != y:
                cnt += 1
        m.append(cnt)
print(min(m))

Submission status: Accepted

Solution code:
S=input()
T=input()
minchange=len(T)
if len(S)==len(T):
    temp=0
    for i in range(len(S)):
        if S[i]!=T[i]:
            temp+=1
    minchange=min(minchange,temp)

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

Submission status: Accepted

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

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

d=0
for j in range(len_t):
    if s[j]!=t[j]:
        d+=1
for i in range(len_s - len_t):
    s2 = s[i:i+len_t]
#    print(s2)
    d2=0
    for j in range(len_t):
        if s2[j]!=t[j]:
            d2+=1
#   print("{}/{}".format(s2,t))
    if d2<d:
        d=d2
print(d)

Submission status: Accepted

Solution code:
import math

S=input()
T=input()
ans=0
#print("ans="+str(ans))

for i in range(len(S)-len(T)+1):
    tmp=0
    for j in range(len(T)):
        #print("i="+str(i)+"\tj="+str(j)+"\tT[j]="+T[j]+"\tS[i+j]"+S[i+j])
        if T[j]==S[i+j]:
            tmp+=1
    if ans<tmp:
        ans=tmp
print(len(T)-ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=0
for i in range(len(s)-len(t)):
    u=0
    for a,b in zip(t,s[i:len(t)+i]):
        if a==b:u+=1
    ans=max(ans,u)  
if len(s)==len(t):
    for a,b in zip(t,s):
        if a==b:ans+=1    
print(len(t)-ans)

Submission status: Accepted

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

ans = len(t)

for i in range(len(s)-len(t)+1):
  si = s[i:i+len(t)]
  cnt = 0
  if len(si) == len(t):
    for sii, ti in zip(si, t):
      if sii != ti:
        cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq
from collections import deque
from functools import cmp_to_key
from itertools import combinations
from itertools import permutations
si = sys.stdin.readline
so = sys.stdout.write
sys.setrecursionlimit(10000)


def main():
    s = si()[:-1]
    t = si()[:-1]
    cnt = 1000+1
    for i in range(len(s)-len(t)+1):
        curr = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                curr += 1
        cnt = min(cnt, curr)
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
l_s = len(s)
l_t = len(t)

match = 0
num = 0
for i in range(l_s - l_t + 1):
    for j in range(l_t):
        if s[i + j] == t[j]:
            match += 1
    num = max(num, match)
    match = 0
print(l_t - num)

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    S = input()
    T = input()
    len_t = len(T)
    len_s = len(S)
    max_diff = 0
    for i in range(0, len_s - len_t + 1):
        max_diff = max(max_diff, diff(S[i::], T))
    print(len_t - max_diff)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def resolve():
	S = list(input())
	T = list(input())
	lenT = len(T)
	res = lenT
	for i in range(len(S)-lenT+1):
		tmp = lenT
		for j in range(lenT):
			if S[i+j] == T[j]:
				tmp -= 1
		res = min(res, tmp)
	print(res)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

mindiff = 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
    mindiff = min(mindiff, diff)
print(mindiff)

Submission status: Accepted

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

res = 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
  res = min(res, tmp)

print(res)

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s)
m = len(t)
def check(s, t):
    count = 0
    for i, j in zip(s, t):
        if i == j:
            count += 1
    return count
ans = -1
for i in range(n - m + 1):
    tmp = s[i:i + m]
    count = check(tmp, t)
    ans = max(ans, count)
print(m-ans)

Submission status: Accepted

Solution code:

def resolve():
    S = input()
    T = input()
    s_n = len(S)
    t_n = len(T)

    ans = 1 << 60
    for i in range(s_n - t_n + 1):
        cnt = 0
        for j in range(t_n):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)

    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
a = input()
b = input()
mini = len(b)
if a == b:
  print(0)
  exit(0)
for s in range(len(a) - len(b) + 1):
  c = 0
  for i, j in zip(a[s:s + len(b)], b):
    if i != j:
      c += 1
  mini = min([mini, c])
print(mini)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = len(T)

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

Submission status: Accepted

Solution code:
""" B
    https://atcoder.jp/contests/abc175/tasks/abc175_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [readIntegerSet(m) for _ in range(0, n)]

def main(T, S):
    best = sys.maxsize
    for i in range(len(T)-len(S)+1):
        s = T[i:i+len(S)]
        count = 0
        for j in range(len(S)):
            if s[j] != S[j]:
                count += 1
        if best > count:
            best = count
    return best


if __name__ == "__main__":
    _T = readString().rstrip()
    _S = readString().rstrip()

    print(main(_T, _S))