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:
import sys


def resolve(in_):
    S = next(in_).strip()
    T = next(in_).strip()

    ans = 0
    for i in range(len(S)):
        if len(S) - i < len(T):
            break
        v = 0
        for x, y in zip(S[i:], T):
            if x == y:
                v += 1
            ans = max(ans, v)
    
    return len(T) - ans
    

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque
import re

S=input()
T = input()

snum = len(S)
tnum = len(T)

m = tnum

for start in range(snum - tnum + 1):
    diff = 0
    for i in range(tnum):
        if S[start+i] != T[i]:
            diff += 1
    m = min(m, diff)

print(m)

Submission status: Accepted

Solution code:
s = input()
t = input()
L = len(s)
l = len(t)
p = L-l
li = []
for i in range(p+1):
    ns = s[i:i+l]
    num = 0
    for j in range(l):
        if ns[j]!=t[j]:
            num +=1
    li += [num]
print(min(li))

Submission status: Accepted

Solution code:
def core(s, t):
  result = len(t)
  for start in range(len(s) - len(t) + 1):
    diff = 0
    for i in range(len(t)):
      if t[i] != s[start + i]:
        diff += 1
    result = min([diff, result])
  
  return result
if __name__ == "__main__":
  strings = [input() for i in range(2)]
  print(core(strings[0], strings[1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
Answer = len(T)
for i in range(0,len(S)-len(T)):
    String = S[i:i+len(T)]
    B = len(T)
    for j in range(len(String)):
        if String[j] == T[j]:
            B -= 1
    Answer = min(Answer,B)
if len(S) == len(T):
    B = len(S)
    for j in range(len(S)):
        if T[j] == S[j]:
            B -=1
    Answer = min(Answer,B)
print(Answer)

Submission status: Accepted

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

min_count = len(T)
for s_i in range(len(S)):
    i = s_i
    matched = 0
    for j in range(len(T)):
        if len(S) <= i:  # Out of S
            matched = 0  # Cannot append characters to S
            break
        if S[i] == T[j]:
            matched += 1
        i += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

Submission status: Accepted

Solution code:
s = input()
t = input()
ls = []
for i in range(len(s) - len(t) + 1):
    ls.append(s[i:i+len(t)])
now = 0
minimum = len(t)
for i in range(len(ls)):
    now = 0
    for j in range(len(t)):
        if t[j] == ls[i][j]:
            now += 1
    if len(t) - now < minimum:
        minimum = len(t) - now
print(minimum)

Submission status: Accepted

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

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

ans = lt
for i in range(ls - lt + 1):
    cnt = 0
    for es, et in zip(s[i:i+lt], t):
        cnt += es != et

    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))

Submission status: Accepted

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

ans = len(T) + 1
for i in range(len(S) - len(T) + 1):
    val = sum(1 for a, b in zip(S[i:i+len(T)], T) if a != b)
    ans = min(ans,  val)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S,T = LS2(),LS2()
a,b = len(S),len(T)

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

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    s = input()
    t = input()
    hoge = 10000
    let = len(t)
    les = len(s)
    ans = 10000
    for i in range(les-let+1):
        hoge = s[i:i+let]
        piyo = 0
        for j, k in zip(hoge,t):
            if j != k:
                piyo += 1
        if piyo < ans:
            ans = piyo
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    S = input()
    T = input()
    ans = INF
    for i in range(len(S) - len(T) + 1):
        ans = min(ans, sum(s != t for s, t in zip(S[i : i + len(T)], T)))
    print(ans)
resolve()

Submission status: Accepted

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

n = len(s)
nt = len(t)

ans = 1000
for i in range(n - nt + 1):
    string = s[i:i + nt]

    count = 0
    for c1, c2 in zip(string, t):
        if c1!=c2: count += 1
    
    ans = min(ans, count)

print(ans)

Submission status: Accepted

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

def main():
    s = list( input() )
    t = list( input() )
    s.pop(-1)
    t.pop(-1)
    len_s = len( s )
    len_t = len( t )
    max = 0
    for i in range( len_s - len_t + 1 ):
        same = 0

        for j in range(len_t ):
            if s[ i + j ] == t[ j ]:
                same += 1

        if same > max:
            max = same
    
    print( len_t - max )

main()

Submission status: Accepted

Solution code:
S = input()
T = input()
Sn = len(S)
Tn = len(T)
ans = 0

for i in range(Sn-Tn+1):
    M = 0
    for j, k in zip(S[i:], T):
        if j == k:
            M += 1
    
    if M > ans:
        ans = M

print(Tn - ans)

Submission status: Accepted

Solution code:
n = input()
m = input()
lst = []
if m in n:
    print(0)
else:
    for i in range(len(n) - len(m) + 1):
        count = 0
        for j in range(i, len(m) + i):
            if n[j] != m[j-i]:
                count += 1
        lst.append(count)
    print(min(lst))

Submission status: Accepted

Solution code:
S = input()
T = input()
sl = len(S)
tl = len(T)
ans = tl
for i in range(sl - tl + 1):
    flag = 0
    tmp = 0
    for j in range(tl):
        if S[j + i] == T[j]:
            tmp += 1
    ans = min(ans,tl - tmp)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
S = np.array(list(input().rstrip()))
T = np.array(list(input().rstrip()))

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

max_count = 0

for i in range(s-t+1):
  max_count = max(max_count, (S[i:i+t]==T).sum())
      
print(len(T) - max_count)

#print(S[5:5+1])
#print(T[-(10-5):5+1])
#print(S[5:5+1] in T[-(10-5):5+1])

Submission status: Accepted

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

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

ans = 10**10
for i in range(len_S - len_T+1):
    num = 0
    for j in range(len_T):
        if S[i+j] != T[j]:
            num+=1
    ans = min(ans, num)

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
len_S = len(S)
len_T = len(T)
N = len_S-len_T+1
max_cnt = 0
for i in range(N):
    cnt = 0
    for j in range(len_T):
        if S[i+j]==T[j]:
            cnt+=1
        if j==len_T-1:
            if max_cnt<cnt:
                max_cnt=cnt
print(len_T-max_cnt)

Submission status: Accepted

Solution code:
import sys

def minChange(S2, S1):
   
    n, m = len(S1), len(S2) 
  
    ans = sys.maxsize 

    for i in range(m - n + 1): 
        minRemovedChar = 0
  
        for j in range(n): 
            if (S1[j] != S2[i + j]): 
                minRemovedChar += 1
                  
        ans = min(minRemovedChar, ans) 

    return ans 

S = str(input())
T = str(input())
print(minChange(S, T))

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
dif = len(S) - len(T) + 1
lis = []

for i in range(dif):
  ng = 0
  S_new = S[i:i+len(T)]
  for j in range(len(T)):
    if S_new[j] != T[j]:
      ng += 1
  lis.append(ng)
print(min(lis))

Submission status: Accepted

Solution code:
s = input()
t = input()
res = 1000
for i in range(len(s)-len(t)+1):
  st = s[i:i+len(t)]
  #print(st)
  #print(t)
  count=0
  for j in range(len(t)):
    #print(st[j], t[j])
    if st[j] != t[j]:
      count+=1
  if res > count:
    res = count
print(res)

Submission status: Accepted

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

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

print(len(T)-tmp)

Submission status: Accepted

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

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

print(m)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B_fix_2
# CreatedDate:  2020-08-29 22:10:51 +0900
# LastModified: 2020-08-29 22:37:02 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    S = input()
    T = input()
#    if S==T:
#        print(0)
#        return
    ans = 0
    for i in range(len(S)-len(T)+1):
        stack = 0
        ans_tmp = 0
        for t in T:
            if t == S[i+stack]:
                ans_tmp += 1
            if ans_tmp > ans:
                ans = ans_tmp
            stack += 1
    print(len(T)-ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def count(A,B):
    counter=0
    for i in range(len(A)):
        if A[i]==B[i]:
            counter+=1
    return len(A)-counter
 
S = input()
T = input()
t = len(T)
s = len(S)
_min = float('inf')
for i in range(s-t+1):
    _min = min(_min,count(S[i:i+t],T))
print(_min)

Submission status: Accepted

Solution code:
def resolve():
    all_string = input()
    target_string = input()
    all_length = len(all_string)
    target_length = len(target_string)
    max_count = 0
    for i in range(all_length - target_length + 1):
        count = 0
        part_string = all_string[i:i+target_length]
        for s1, s2 in zip(part_string, target_string):
            if s1 == s2:
                count +=1
        if count>max_count:
            max_count = count
    print(target_length - max_count)

resolve()

Submission status: Accepted

Solution code:
S = input()
T = input()
x = len(S)-len(T)+1
y = len(T)
list = [0] * (x)
for i in range(x):
  X = S[i:i+y]
  for j in range(y):
    if X[j] != T[j]:
      list[i] += 1
list = sorted(list)
print(list[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 177
# B - Substring

S=input()
T=input()

Slen=len(S)
Tlen=len(T)

m=0

for i in range (Slen-Tlen+1):
    temp=0
    for j in range (Tlen):
        if T[j]==S[i+j]:
            temp+=1
        else:
            continue
    else:
        if temp>m:
            m=temp
print(Tlen-m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
a=set() ; b=[]
c=0
for i in input():
    a.add((i,c))
    c+=1
c=0
for i in input():
    b.append([i,c])
    c+=1
ans=0 ; cur=0
for num in range(len(a)-len(b)+1):
    cur=0
    for i in b:
        need=tuple([i[0],i[1]+num])
        if need in a:
            cur+=1
        ans=max(ans,cur)
print(len(b)-ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
if T in S:
  print(0)
else:
  biggest_match = 0
  start = 0
  for i in range(len(S)-len(T)+1):
    j = 0
    match = 0
    for t in T:
      if t == S[i+j]:
        match += 1
      j += 1
    if match > biggest_match:
      biggest_match = match
      start = i
  print(len(T) - biggest_match)

Submission status: Accepted

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

    tmp_S = S

    num = 0

    for k in range(len(S) - len(T) + 1):
        tmp_n = 0
        for i in range(len(T)):
            if tmp_S[i] == T[i]:
                tmp_n += 1
        #        print(tmp_n)
        if num <= tmp_n:
            num = tmp_n
        del tmp_S[0]

    ans = len(T) - num

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S = input()
T = input()
cnt_list = []

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

Submission status: Accepted

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

N = len(S)
M = len(T)
l = []
for i in range(N+1):
  sim = 0
  if len(S[i:i+M]) != M: break
  for j in range(M):
    if S[i:i+M][j] == T[j]:
      sim += 1
  dis = M - sim
  l.append(dis)
  
print(min(l))

Submission status: Accepted

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

# t0=time()

n = len(s)
k = len(t)


maxn = 0
if s==t:
    maxn=k
for i in range(n-k+1):
    # print(s[i:i+k], t)
    neq = 0
    for c1, c2 in zip(s[i:i+k], t):
        neq += int(c1==c2)
    # print('n symbols equal:',neq)
    if neq > maxn:
        maxn=neq
        # print('max_eq', maxn)
print(k-maxn)

Submission status: Accepted

Solution code:
def main():

    # 変数宣言
    m_cnt_tmp = 0
    m_cnt_ans = 0

    # 標準入力からデータの受け取り
    s = input()
    t = input()
    s_len = len(s)
    t_len = len(t)

    # ループを回しながら調べていく
    for s_cnt in range(0, s_len - t_len + 1):
        for t_cnt in range(0, t_len):
            if (t[t_cnt] == s[s_cnt + t_cnt]):
                m_cnt_tmp += 1
        if (m_cnt_ans < m_cnt_tmp):
            m_cnt_ans = m_cnt_tmp
        m_cnt_tmp = 0

    # 結果表示
    print(t_len - m_cnt_ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
T = input()
count = len(T)
tmp = 0
j = 0
i = len(S) - len(T)

while(i >= 0):
    #print(S[i:i+len(T)])
    #print(T[0:i+len(T)])
    for k in range(len(T)):
        if S[i+k] == T[k]:
            #print("S:"+S[i+k]+" T:"+T[k])
            j += 1
        else:
            #print("j:"+str(j))
            tmp = len(T) - j
            #print("tmp:"+str(tmp))
            if count > tmp:
                count = tmp
            tmp = len(T)
    if len(T) == j:
        count = 0
    i -= 1
    j = 0

print(count)

Submission status: Accepted

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

len_s, len_t = len(S), len(T)
l = []
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
    l.append(tmp)
print(min(l))

Submission status: Accepted

Solution code:
a = input()
b = input()
count = [0]*(len(a)-len(b)+1)

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

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
cnt = len(t)
diff = cnt

for i in range(len(s)):
    for j in range(len(t)):
        if len(s) <= i+j:
            cnt = len(t)
            break
        elif s[i+j] == t[j]:
            cnt -= 1
    if cnt < diff:
        diff = cnt
    cnt = len(t)
print(diff)

Submission status: Accepted

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

s = len(S)
t = len(T)
"""
if T in S:
     print(0)
     """
#else:
m = s - t + 1
bag = []
for i in range(m):
     #bag = []
     num2 = t
     for j in range(t):
          #print(S[i+j])
          #print(T[j])
          if S[i+j] == T[j]:
               num2 -= 1
     #print(num2)
     bag.append(num2)

list.sort(bag)
print(bag[0])

Submission status: Accepted

Solution code:
s1=input()
s2=input()
ans=0
for i in range(len(s1)-len(s2)+1):
    c=0
    j=0
    while j<len(s2):
        if s1[i+j]==s2[j]:
            c+=1
        j+=1
    ans=max(ans,c)
print(len(s2)-ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,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())
def main():
    s = S()
    t = S()
    s = list(s)
    t = list(t)
    slen = len(s)
    tlen = len(t)
    ans = float("inf")

    for i in range(tlen):
        char = t[i]
        for j in range(i,slen-(tlen-i-1)):
            aaa = s[j]
            if aaa==char:
                rng = s[j:j+tlen-i]
                ex = t[i:]
                cnt = 0
                for x,y in zip(rng,ex):
                    if x == y:
                        cnt += 1
                ans = min(ans, tlen-cnt)
    if ans == float("inf"):
        ans = tlen
    print(ans)

main()

Submission status: Accepted

Solution code:
s=input()
t=input()
sl=len(s)
tl=len(t)
kotae=tl
for i in range(0,sl-tl+1):
  x=s[i:i+tl]
  b=0
  for j in range(tl):
    if x[j]!=t[j]:
      b+=1
  if b<kotae:
    kotae=b
print(kotae)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def f(l,s):
	c=0
	for i in range(len(l)):
		if l[i]==s[i]:
			c+=1
	return len(l)-c

t=input()
sub=input()
n=len(t)
m=len(sub)
c=m
for i in range(0,n-m):
	c=min(c,f(t[i:i+m],sub))
if n==m:
	c=f(sub,t)
print(c)

Submission status: Accepted

Solution code:
from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
# import sys
# sys.setrecursionlimit(10**7)
# sys.stdin = open('inpy.txt', 'r')
# sys.stdout = open('outpy.txt', 'w')
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def inin():
    return int(input())
def stin():
    return input()
def spin():
    return map(int,stin().split())
def lin():                           #takes array as input
    return list(map(int,stin().split()))
def matrix(n):
    #matrix input
    return [list(map(int,input().split()))for i in range(n)]

################################################
def string2intlist(s):
    return list(map(int, s))

def calculate_sum(a, N): #sum of a to N
    # Number of multiples 
    m = N / a 
    # sum of first m natural numbers 
    sum = m * (m + 1) / 2
    # sum of multiples 
    ans = a * sum
    return ans
def series(N):
    return (N*(N+1))//2

def count2Dmatrix(i,list):
    return sum(c.count(i) for c in list)

def modinv(n,p):
    return pow(n,p-2,p)

def GCD(x, y): 
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y): 
        x, y = y, x % y 
    return x
def LCM (x, y):
    return (x * y) // GCD(x, y)
    
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l
def isprime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
prime=[]
def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
q=[]       
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j
# d = {}
 
"""*******************************************************"""
s = stin()
t = stin()
c,d = 0,0
for i in range(len(s)-len(t)+1):
    d=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            d+=1
    # print(c, d)
    c=max(d,c)
print(len(t)-c)
# for i in range(len(t), 0,-1):
#     # print(t[:i])
#     if t[:i] in s:
#         # print(c)
#         break
#     else:
#         c+=1
#     # print(t[:i], t[:i] in s)
# for i in range(len(t)):
#     # print(t[i:])
#     if t[i:] in s:
#         # print(d)
#         break
#     else:
#         d+=1
# # print("ab" in s)
# print(min(c, d))

Submission status: Accepted

Solution code:
s=input()
t=input()
len_s=len(s)
len_t=len(t)
len_n=len_s-len_t
ans=100000
for i in range(0,len_n+1):
    cnt=0
    for j in range(len_t):
        if s[i+j]!=t[j]:
            cnt+=1

    ans=min(ans,cnt)
print(ans)

Submission status: Accepted

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

a = []
sum_ = 0
for i in range(ls-lt+1):
    ss = s[i:i+lt]
    sum_ = 0
    for i, alb in enumerate(t):
        if alb == ss[i]:
            sum_+= 1
    a.append(sum_)

print(lt - max(a))

Submission status: Accepted

Solution code:
S=input()
T=input()
ans=10**5
for i in range(len(S)-len(T)+1):
    res=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            res+=1
    ans=min(ans,res)

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
 
ans = float('inf')
for i in range(0,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)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
import numpy as numpy
len_S = len(S)
len_T = len(T)
count = numpy.zeros(len_S-len_T+1)
for i in range(len_S-len_T+1):
  for j in range(len_T):
    if not S[i+j] == T[j]:
      count[i] +=1
print(int(min(count)))

Submission status: Accepted

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

s = len(S)
t = len(T)
u = s-t+1

A = []
for i in range(u):
  count = 0
  for j in range(t):
    if T[j] != S[i+j]:
      count += 1
  A.append(count)
print(min(A))

Submission status: Accepted

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

def same_chara(list1, list2):
  count = 0
  for a, b in zip(list1, list2):
    if a == b:
      count += 1
  return count

m = 0
for i in range(len(S) - len(T) + 1):
  m = max(m, same_chara(S[i:len(T)+i], T))
  
print(len(T) - m)

Submission status: Accepted

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

Submission status: Accepted

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

    if T in S:
        print(0)
        return
    if len(T) == len(S):
        count = 0
        for t, s in zip(S, T):
            if t != s:
                count += 1
        print(count)
        return

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


def main():
    probB()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

ans = 1000
max_cnt = 0
for i in range(len_s - len_t + 1):
    cnt = 0
    l = []
    for j in range(len_t):
        if s[i : i + len_t][j] == t[j]:
            cnt += 1
        if s[i : i + len_t][j] != t[j]:
            cnt += 0
    max_cnt = max(max_cnt, cnt)

ans = min(ans, len_t - max_cnt)

print(ans)

Submission status: Accepted

Solution code:
import sys
s = str(input())
t = str(input())
ans = sys.maxsize 
for i in range(len(s) - len(t) + 1): 
        minRemovedChar = 0
        for j in range(len(t)): 
            if (t[j] != s[i + j]): 
                minRemovedChar += 1
        ans = min(minRemovedChar, ans) 
print(ans)

Submission status: Accepted

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

maiores = []
maior = 0

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] == t[j]:
            maior += 1
    maiores.append(maior)
    maior = 0


print(len(t) - max(maiores))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
main = input()
word = input()
temp = main
resultArray = []
final = len(word)
for j in range(len(main) - (len(word) - 1)):
    result = ''
    for i in range(len(word)):
        if main[j + i] == word[i]:
            result += '1'
        else:
            result += '0'
    resultArray.append(result)
for i in resultArray:
    if i.count('0') < final:
        final = i.count('0')
print(final)

Submission status: Accepted

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

r = len(s) - len(t)
l = []
if r != 0:
    for start in range(r):
        count = 0
        for i in range(len(t)):
            if t[i] == s[start+i]:
                count +=1
        l.append(count)
    ans = len(t)- max(l)
else:
    count = 0
    for i in range(len(t)):
        if t[i] == s[i]:
            count +=1
    ans = len(t)- count   

print(ans)

Submission status: Accepted

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

ans = 0
cnt = 0

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


print(len(T) - ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

S = input()
T = input()

SL = len(S)
TL = len(T)
X = SL - TL + 1
min = SL
for i in range(X):
    dif = 0
    for j in range(TL):
        if S[i+j] != T[j]:
            dif += 1
    if dif < min:
        min = dif
    # print(dif)
print(min)

Submission status: Accepted

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

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

print(l-ans)

Submission status: Accepted

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

min_ch = 9999999
for i in range(0, len(S) - len(T) + 1):
    s = S[i:i+len(T)]
    ch = 0
    for j in range(len(T)):
        if T[j] != s[j]:
            ch += 1

    if ch < min_ch:
        min_ch = ch

print(min_ch)

Submission status: Accepted

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

# print(S, T)
# # ない場合はTを分解し、それらの文字列が存在するかを確認
# for i in range(1, len(T)):
#   # 分解文字列
#   for j in range(i+1):
#     subTs= T[j:len(T)-i+j]
#     if subTs in S[j:len(T)-i+j]:
#       print(i)
#       exit()
#   print(subTs)
# # 全てない場合は全文字を書き換える
# print(len(T))

# ない場合は、文字列の類似数を算出する
def similar(str1, str2):
  # print(str1, str2)
  cnt = 0
  for i in range(len(str1)):
    if str1[i] == str2[i]:
      cnt += 1
  return cnt

max_value = 0
for i in range(0, len(S)-len(T)+1):
  t = similar(S[i:len(T)+i], T)
  # print('t', t)
  if t > max_value:
    max_value = t
print(len(T)-max_value)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input() # 長い文字列
T=input() # 短い文字列

count_min=1000 # SとTの最小距離

for ind_s in range(0,len(S)-len(T)+1): # 各Tのスタートについて
    count=0 # 何文字一致しているか

    for ind_t in range(0,len(T)): # 各T内のオフセットについて
        count+=int(S[ind_s+ind_t]!=T[ind_t]) # 一致していたらカウントをインクリメント

    if count<count_min: # もし最小を更新する場合
        count_min=count # 最小値を更新

print(count_min)

Submission status: Accepted

Solution code:
import re

s=input()
t=input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a = len(s)
b = len(t)
c = a-b;
min1 = 0;
min2 = 0;
for i in range(c+1):
  for j in range(b):
    
    if s[j+i]==t[j]:
      
      min2 += 1
  if min1<min2:
    min1 = min2
  min2 =0
print(b-min1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
s = input()
t = input()
ans = 0

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

    if ans < num:
        ans = num

print(len(t) - ans)