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: Wrong Answer

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

min_count = len(T)
for s in range(len(S) - len(T) + 1):  # T cannot exceed the length of S
    matched = 0
    for i in range(len(T)):
        print(f'S[{s + i}] == T[{i}]')
        if S[s + i] == T[i]:
            matched += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans = 0
count = 0 
saishou = 0

for i in range(len(T)):
  for j in range(i, len(S)-len(T)+i):
    c = 0
    while T[i+c] == S[j+c]:
      c = c + 1
      ans = max(ans, c)
      if i + c > len(T)-1 or j + c  > len(S)-1 :
        break

saishou = len(T) - ans
print(saishou)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
minCount = len(t)
i = 0
while i < len(s):
    countSame = 0
    j = 0
    while j < len(t) and i+j < len(s):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    s = input()
    t = input()

    res = 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
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

min_count = len(T)
for s in range(len(S) - len(T)):  # T cannot exceed the length of S
    matched = 0
    for i in range(len(T)):
        if S[s + i] == T[i]:
            matched += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

Submission status: Wrong Answer

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

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

for i in range(len(s) - len(t) + 1):
    maxCommonNum = 0
    tmpCommonCharNum = getCommonCharNum(s[i: len(t) + i], t)  #s[0, len(s)] → s[0 + last_i, len(s) + last_i]
    if maxCommonNum < tmpCommonCharNum:
        maxCommonNum = tmpCommonCharNum
print(len(t) - maxCommonNum)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if t != s:
            print(1)
            sys.exit()
    lens = len(s)
    lent = len(t)
    olent = lent
    res = set()
    cnt = 0
    while lent:
        for i1 in range(1, lent + 1):
            end = lens - (lent - i1)
            if t[:i1] in s[:end]:
                res.add(cnt + (lent - i1))
            #print(i1, t[:i1],s[:end], res)
        s = s[1:]
        t = t[1:]
        lent -= 1
        lens -= 1
        cnt += 1
    if res:
        r = min(res)
        print(r)
    else:
        print(olent)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
  s=input()
  t=input()
  ls=len(s)
  lt=len(t)
  st= [ [ 0 for y in range(ls ) ] for x in range( lt ) ]
  for si in range(ls):
    for ti in range(lt):
      if s[si]==t[ti]:
        st[ti][si]=1
        break
  r=0
  for si in range(ls-lt):
    rt=0
    for ti in range(lt-si):
      rt+=st[ti][(si+ti)]
    if r<rt:
      r=rt
  print(lt-r)
main()

Submission status: Wrong Answer

Solution code:
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
        else:
            cnt = 0
        if cnt > ans:
            ans = cnt
print(len(T)-ans)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)):
        if i + len(t) > len(s): break
        diff = 0
        for j in range(len(t)):
            if i + j - 1 > len(s): break
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if t != s:
            print(1)
            sys.exit()
    lens = len(s)
    lent = len(t)
    res = []
    cnt = 0
    while lent:
        for i1 in range(1, lent + 1):
            end = lens - (lent - i1)
            if t[:i1] in s[:end]:
                res.append(cnt + (lent - i1))
            #print(i1, t[:i1],s[:end], res)
        s = s[1:]
        t = t[1:]
        lent -= 1
        lens -= 1
        cnt += 1
    if res:
        r = min(res)
        print(r)
    else:
        print(lent)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
  s=input()
  t=input()
  ls=len(s)
  lt=len(t)
  st= [ [ 0 for y in range(ls ) ] for x in range( lt ) ]
  for si in range(ls):
    for ti in range(lt):
      if s[si]==t[ti]:
        st[ti][si]=1
        break
  r=0
  for si in range(ls):
    rt=0
    for ti in range(lt-si):
      rt+=st[ti][(si+ti)]
    if r<rt:
      r=rt
  print(lt-r)
main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
S = input()
T = input()

#print(len(S))

a = 0
ans = len(T)

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

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)):
        if i + len(t) > len(s): break
        diff = 0
        for j in range(len(t)):
            if i + j > len(s): break
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
S = input()
T = input()

print(len(S))

a = 0
ans = len(T)

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

Submission status: Wrong Answer

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

cnt = 0

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

print(len(s) - cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
n=len(t)
val=0
for i in range(len(s)-n):
    temp=0
    for j in range(n):
        if s[i+j]==t[j]:
            temp+=1
    val=max(val,temp)
    if val==n:
        break
print(n-val)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)):
        if i + len(t) > len(s): break
        diff = 0
        for j in range(len(t)):
            if i + j - 1 >= len(s): break
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = len(s) - len(t)

match_b = len(t)
match_a = 0
for i in range(diff):
    for j in range(len(t)):
        if s[i + j] != t[j]:
            match_a += 1
    if match_b > match_a:
        match_b = match_a
        match_a = 0
    else :
        match_a = 0

print(match_b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
ans = float('inf')

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)

print(ans)

Submission status: Wrong Answer

Solution code:
S,T=open(0).read().split()
def main():
    for i in range(1,len(T)):
        for j in range(i+1):
            if T[j:(len(T)-i+j)] in S[j:(len(S)-i+j)]:
                return i
    return len(T)
if T in S:
    print(0)
else:
    print(main())

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

diff = len(s) - len(t)

match_b = 0
match_a = 0
for i in range(diff):
    for j in range(len(t)):
        if s[i + j] == t[j]:
            match_a += 1
    if match_b < match_a:
        match_b = match_a
        match_a = 0
    else :
        match_a = 0

print(len(t) - match_b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ns = len(s)
nt = len(t)

ans = nt

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

Submission status: Wrong Answer

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


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


print(len(t)-ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


print(len(t)-ans)

Submission status: Wrong Answer

Solution code:
S,T=open(0).read().split()
def main():
    for i in range(1,len(T)+1):
        for j in range(i+1):
            if T[j:(len(T)-i+j)] in S[j:(len(S)-i+j)]:
                return i
                break
    return len(T)
if T in S:
    print(0)
else:
    print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S,T=open(0).read().split()
def main():
    for i in range(1,len(T)+1):
        for j in range(i+1):
            if T[j:(len(T)-i+j)] in S[j:(len(S)-i+j)]:
                return i
                break
if T in S:
    print(0)
else:
    print(main())

Submission status: Wrong Answer

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

if len(S) == 1:
    if S == T:
        print(0)
    else:
        print(1)

else:
    l = []
    for i in range(len(S) - len(T) + 1):
        A = S[i:i + (len(T))]
        print(A)
        count = 0
        for j in range(len(A)):
            if A[j] == T[j]:
                count += 1
                print(count)
        l.append(count)

    print(l)
    if len(l) > 0:
        a = len(T) - max(l)
        print(a)
    else:
        a = 1
        print(a)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

for r in range(len(T),0,-1):
    for i in range(len(T)-r+1):
        if T[i:i+r] in S[i:]:
            break
    else:
        continue
    print(len(T)-r)
    break
else:
    print(len(T))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
count = 0
def ans(s, t):
    max = pow(10,9)
    if len(s)==len(t):
        for i in range(len(s)):
            if s[i]!=t[i]:
                max+=1
                return max
    else:
        for i in range(len(s)-len(t)+1):
            count = 0
            for j in range(len(t)):
                if s[i+j] != t[j]:
                    count+=1
            if max > count:
                max = count
        return max
print(ans(s,t))

Submission status: Wrong Answer

Solution code:
def resolve():
    s = input()
    t = input()
    ans = 0

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

resolve()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0
l = len(T)
for m in range (len(S)-l):
    diff = 0
    for i in range (l):
        if S[m+i] != T[i]:
            diff+=1
    ans = max(ans, diff)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = ls

for i in range(0, lt):

    for j in range(0, lt - i + 1):
        r = t[i:i+j]
        
        if r in s[i:ls-j + 1]:
            
            a = lt - len(r)
            if a < ans:
                ans = a

print(ans)

Submission status: Wrong Answer

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

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

ans = ls

for i in range(0, lt):

    for j in range(0, lt - i + 1):
        r = t[i:i+j]
        
        if r in s[i:ls-j]:
            
            a = lt - len(r)
            if a < ans:
                ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
sList = list(input())
tList = list(input())
lenS = len(sList)
lenT = len(tList)
minDiff = lenT
  
for start in range(lenS - lenT):
  diff = 0
  for i in range(lenT):
    if sList[start + i] != tList[i]:
      diff += 1
  if minDiff > diff:
    minDiff = diff

print(minDiff)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
amount = 0
for i in range(len(T)):
    for j in range(i+1,len(T)+1):
        tmp = T[i:j]
        if tmp in S and amount < len(tmp) and S.index(tmp) >= T.index(tmp):
            amount = len(tmp)
print(len(T)-amount)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
lenS = len(S)
lenT = len(T)
maxans = 0
for i in range(lenS-lenT+1):
    maxcnt = 0
    cnt = 0
    for j in range(lenT):
        if S[i+j] == T[j]:
            cnt += 1
        else:
            cnt = 0
        maxcnt = max(maxcnt, cnt)
    maxans = max(maxans, maxcnt)
print(lenT - maxans)

Submission status: Wrong Answer

Solution code:
import sys
s=input()
t=input()
for i in range(len(t)):
    for j in range(len(t)-i):
        for k in range(i,len(s)-len(t[i:len(t)-j])):
            if t[i:len(t)-j]==s[k:k+len(t[i:len(t)-j])]:
                print(len(t)-len(t[i:len(t)-j]))
                sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = 10000000000

for i in range(0, len(s)-len(t)+1):
    m = 0
    # print(s[i:], t)
    # for j, k in zip(s[i:],t):
    #     print(j,k)
    #     if j==k:
    #         m += 1
    for j in range(0, len(t)):
        # print(s[j], t[j])
        if(s[j]==t[j]):
            m+=1
            
    res = min(res, len(t)-m)
    # print(len(t)-m)

print(res)

Submission status: Wrong Answer

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

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

rec = len(T)
for i in range(len(S)-len(T)):
    subst = S[i:i+len(T)]
    rec = min(rec, len(T) - matchcount(subst, T))

print(rec)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans = len(t)
    for v in range(len(s) - len(t) + 1):
        print(f'{v=}')
        a = [t[i] != x for i, x in enumerate(s[v:len(t)+v])]
        print(s[v:v + len(t) - v])
        print(a)
        print(s[v:len(t)+v])
        if sum(a) < ans:
            ans = sum(a)
    print(ans)


if __name__ == '__main__':
    Qb()

Submission status: Wrong Answer

Solution code:
def resolve():
    s = input()
    t = input()
    ans = 0

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


    print(len(t) - ans)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S,T=open(0).read().split()
def main():
    for i in range(1,len(T)):
        for j in range(i):
            if T[j:-(i-j)] in S[j:-(i-j)]:
                return i
                break
if T in S:
    print(0)
else:
    print(main())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

S=input()
T=input()

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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
    print(s[i+j])
    ans = min(ans, ans_tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
n_gram = lambda target, n: [target[i:i+n] for i in range(len(target) - n + 1)]

S = input()
T = input()

count = len(T)
hit = False

for n in reversed(range(1, len(T) + 1)):
    l = n_gram(T, n)
    for i in range(len(l)):
        idx = -1
        try:
            idx = S.index(l[i])
        except:
            idx = -1
        if idx == -1:
            continue
        start_ok = idx - i >= 0
        end_ok = len(S) - (idx + n) >= len(l) - 1 - i
        if start_ok and end_ok:
            count = min(count, len(T) - n)
            hit = True
            break
    if hit:
        break
print(count)

Submission status: Wrong Answer

Solution code:
import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   if i + l > L:
      continue
   for j in range(l):
      ans = 0
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Submission status: Wrong Answer

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

ans = len(T)

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

Submission status: Wrong Answer

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(tnum, diff)

print(m)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
S = str(input())
T = str(input())

len_T = len(T)
T_part_dict = {}
for i in range(len_T):
    for j in range(i, len_T):
        T_part_dict[T[i:j + 1]] = i

len_S = len(S)
max_part_len = 0
for part_str, len_from_top in T_part_dict.items():
    now_len_part = len(part_str)
    if now_len_part <= max_part_len:
        continue
    if S[len_from_top:len_S - (len_T - len_from_top - now_len_part)].count(part_str) > 0:
        max_part_len = now_len_part

print(len_T - max_part_len)

Submission status: Wrong Answer

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(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if s in t:
            print(0)
            sys.exit()
        else:
            print(1)
            sys.exit()

    lent = len(t)
    lens = len(s)
    res = []
    for i1 in range(lent):
        tmp1 = t[i1:]
        for i2 in range(lent - i1, 0, -1):
            end = lens - i2
            if tmp1[:i2] in s[i1:end]:
                res.append(lent - len(tmp1[:i2]))
            #print(i1, i2, tmp1[:i2], res)
    if res:
        r = min(res)
        print(r)
    else:
        print(lent)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 0
for ti in range(len(t)):
    cnt = 0
    for si in range(ti,len(s)):
        if t[ti] == s[si]:
            cnt += 1
            ans = max(ans,cnt)
        else:
            cnt = 0
print(len(t) - ans)

Submission status: Wrong Answer

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

len_t = len(t)
ans = len_t
for i in range(len(s) - len_t):
    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: Wrong Answer

Solution code:
import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   for j in range(l):
      ans = 0
      if i + l > L:
         continue
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Submission status: Wrong Answer

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

m = 0
l = len(t)
# print(l)
ans = 100000000
for tt in range(0,l):
    a = 0
    for pp in range(l-tt , 0, -1):
        # print(t[tt:pp])
        if t[tt:tt+pp] in s[tt:len(s)-a]:
            # print("ok ", tt + (l-pp))
            if ans > tt + a:
                ans = tt + a

        a += 1


print(ans)

Submission status: Wrong Answer

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

for first in range(len(S)-len(T)):
    ruiji = 0
    for i in range(len(T)):
        if S[first+i] == T[i]:
            ruiji += 1
    if ruijimax <= ruiji:
        ruijimax = ruiji

print(len(T)-ruijimax)

Submission status: Wrong Answer

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

ans = 10000
len_t = len(t)
for i in range(len(s) - len_t):
    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: Wrong Answer

Solution code:
S = input()
T = input()
c =0
C = [0]
for i in range(len(S)):
  c = 0
  for j in range(len(T)):
    if S[i] == T[j] and i-j >= 0 and len(S)-i -1 >= len(T)-j -1:
      
      c = 1
      if not(i == len(S)-1 and j == len(T)-1):
        for k in range(len(T) - j-2):
          if S[i + k + 1] == T[j + k +1]:
            c += 1
        C.append(c)
        c = 0
C.append(c)

print(len(T)-max(C))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
max_length = 0
# for i in range(len(t)):
#     for j in range(i, len(s)):
#         if t[i] == s[j]:
#             length = 0
#             for k in range(min(len(t)-i, len(s)-j)):
#                 if t[i+k] == s[j+k]:
#                     length += 1
#             for l in range(1, i+1):
#                 if t[i-l] == s[j-l]:
#                     length += 1
#             if length > max_length:
#                 max_length = length
# print(len(t)-max_length)
# for i in range(len(t)):
#     for j in range(i+1, len(t)):
#         t_part = t[i:j]
#         if (t_part in s[i:] and j-i > max_length):
#             max_length = j-i

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
print(Answer)

Submission status: Wrong Answer

Solution code:
S=list(input())
T=list(input())
x=[0]*(len(S)+1)
for i in range(len(S)):
    for j in range(len(T)):
        if T[j]==S[i] and j<i:
            if T[j-1]==S[i-1] and j-1>=0 and i-1>=0:
                x[i]=x[i-1]+1
            else:
                x[i]=1


print(len(T)-max(x))

Submission status: Wrong Answer

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

rec = len(T)
for i in range(len(T)):
    for j in range(len(T)-i):
        subst = T[i:len(T)-j]
        subst_s = S[i:len(S)-j]
#        print(subst, subst_s)
        if subst_s.find(subst)>=0:
#            print('found:', subst)
            rec = min(rec, len(T) - len(subst))
#            exit(0)

print(rec)

Submission status: Wrong Answer

Solution code:
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
S =input().strip()
T =input().strip()
len_t =len(T)
ans =0

for l in range(len_t,0,-1):
    front_T =T[:l]
    back_T =T[-l:]
    if front_T in S or back_T in S:
        print(len_t -l)
        break

Submission status: Wrong Answer

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

l = len(s)
k = len(t)
min = 1002

for j in range(0,k):
    t1 = t[0:k-j]
    for i in range(0,l-k+j+1):
        s1 = s[i:i+k-j]
        if t1 == s1:
            min = j
    if min != 1002:
        break
            
print(min)

Submission status: Wrong Answer

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()
    m = len(S)
    l = len(T)
    # m > l
    ans = INF
    for i in range(m - l + 1):
        ans = sum(s != t for s, t in zip(S[i : i + l], T))
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
s=input().strip()
t=input().strip()
def longestSubstringFinder(string1, string2):
    answer = ""
    len1, len2 = len(string1), len(string2)
    for i in range(len1):
        match = ""
        for j in range(len2):
            if (i + j < len1 and string1[i + j] == string2[j]):
                match += string2[j]
            else:
                if (len(match) > len(answer)): answer = match
                match = ""
    return answer

if longestSubstringFinder(s,t):
	print (len(t)-len(longestSubstringFinder(s,t)))
else:
  print(len(t))