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:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    s = S()
    t = S()
    ans = inf
    for i in range(len(s) - len(t)):
        tmp = 0
        for j in range(len(t)):
            if s[i + j] == t[j]:
                continue
            tmp += 1
        ans = min(ans, tmp)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:

S = input()
T = input()

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

while i < Tlen:
    if T[i:] in S[i:]:
        if len(T[i:Tlen-i])< len(S[:(Slen-i)]):
            break
    if T[:(Tlen-i)] in S[:(Slen-i)]:
        break
    i += 1

if i != Tlen:
    print(i)
else:
    print(Tlen)

Submission status: Wrong Answer

Solution code:
import sys                                                                                                                               
                                                                                                                                         
S = input()                                                                                                                              
T = input()                                                                                                                              
                                                                                                                                         
##print(S)                                                                                                                               
##print(T)                                                                                                                               
                                                                                                                                         
flag = 0                                                                                                                                 
count = 0                                                                                                                                
                                                                                                                                         
##print(len(T))                                                                                                                          
tmp_len = len(T)                                                                                                                         
                                                                                                                                         
                                                                                                                                         
while 1:                                                                                                                                 
                                                                                                                                         
    ##print("")                                                                                                                          
    for i in range(0, count + 1):                                                                                                        
        tmp_st = T[i:tmp_len-count+i]                                                                                                    
        ##print(tmp_st)                                                                                                                  
        ##print(S[i:len(S)-count+i])                                                                                                     
        if tmp_st in S[i:len(S)-count+i]:                                                                                                
            flag = 1                                                                                                                     
            break                                                                                                                        
                                                                                                                                         
        ##print("")                                                                                                                      
    if flag == 1:                                                                                                                        
        break                                                                                                                            
    count = count + 1                                                                                                                    
                                                                                                                                         
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = input()
n = len(t)
no_change = 0
for size in range(n-1,-1,-1):
  for t_range in range(n-size):
    bubun = t[t_range:t_range+size+1]
    for s_range in range(t_range,len(s)-len(t)):
      if bubun == s[s_range:s_range+size+1]:
        no_change = size
        break
    if no_change != 0:
      break
  if no_change != 0:
    break

print(n-no_change-1)

Submission status: Wrong Answer

Solution code:
#one, two, three, four, five = map(int, input().split())
#li = list(map(int, input().split()))
def Levenshtein(str1,str2):
  count = 0
  for i in range(len(str1)):
    if str1[i] != str2[i]:
      count += 1
  return count

S = input()
T = input()
min_ = 9999999
for i in range(len(S)-len(T)):
  str1 = S[i:i+len(T)]
  str2 = T
  #print(str1,str2)
  leven = Levenshtein(str1,str2)
  if(leven < min_):
    min_ = leven
if S==T:
  min_=0
print(min_)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
find = False
minimum = 0
for j in range(len(T)):
    if S[j] != T[j]:
        minimum += 1
for i in range(len(S)):
    if find == True:
        break
    m = 0
    for j in range(len(T)):
        if i + j >= len(S):
            print(minimum)
            find = True
            break
        else:
            if S[i+j] != T[j]:
                m += 1
    if m <= minimum:
        minimum = m

Submission status: Wrong Answer

Solution code:
import itertools
import re
import sys

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

lst = [i for i in range(len(T))]
# print(lst)
combs = []

if(T in S):
    print(0)

for i in range(1, len(lst)+1):
    els = [list(x) for x in itertools.combinations(lst, i)]
    # print(i, els)
    for e in els:
        pattern = T
        for j in e:
            str_list = list(pattern)
            str_list[j] = '.'
            pattern = "".join(str_list)
            # print(i, ".*" + pattern + ".*")
            if(re.search(".*" + pattern + ".*", S)):
                print(i)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

if __name__ == '__main__':
    S = sys.stdin.readline().rstrip()
    T = sys.stdin.readline().rstrip()
    max_match = 0
    for i in range(len(T)):
        for j in range(i+1, len(T)):
            # pos = S[i:-j].find(T[i:j])
            pos = S[i:-(len(T)-j)].find(T[i:j])
            # print(S[i:-(len(T)-j)], T[i:j])
            if max_match < j-i and pos != -1:
                # print(i, j)
                max_match = j - i
    # print(T, len(T))
    # print(len(T), max_match, len(T)-max_match)
    print(len(T)-max_match)

Submission status: Wrong Answer

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

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

print(l-num)

Submission status: Wrong Answer

Solution code:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


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

    min_len = 10**9
    for i, s in enumerate(S[:len(S)-len(T)+1]):
        sub = S[i:i+len(T)]
        # print(sub)
        count = 0
        for j, t in enumerate(T):
            if sub == T:
                min_len = min(min_len, count)
                break
            if sub[j] == t:
                continue
            sub = sub[:j] + t + sub[j+1:]
            count += 1

    return min_len


def main():
    print(solve())


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
result = [0]*len(s)
for i in range(len(s)):
    for j in range(len(t)):
        try:
            if s[j] == t[j]:
                result[i] += 1
        except:
            pass
    s = s[1:]
print(len(t) - max(result))

Submission status: Wrong Answer

Solution code:
main = input()
word = input()
temp = main
resultArray = []
final = len(word)
for j in range(len(main) - len(word)):
    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: Wrong Answer

Solution code:

import numpy as np

S = input()
T = input()

Sl = list(S)
Tl = list(T)
num=[]

for i in np.arange(len(Tl)):
    if(T[:len(Tl)-i] in Sl):
        num.append(len(Tl)-i)
if (num==[]):
    print(len(Tl)-1)
else:
    print(min(num))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if T in S:
        print(0)
        return
    if len(T) == len(S):
        count = 0
        for i, _ in enumerate(T):
            if T[i] != S[i]:
                count += 1
        print(count)
        return

    maxdiff = 0
    for i in range(len(S) - len(T)):
        count = 0
        for j, c in enumerate(T):
            if S[i + j] != c:
                count += 1
            if (count > maxdiff):
                maxdiff = count
    print(maxdiff)


def main():
    probB()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

min = len(T)
for t in range(len(S) - len(T)):
    tmp = 0
    for i in range(len(T)):
        if S[i+t] != T[i]:
            tmp+=1
    
    if tmp < min:
        min = tmp

print(min)

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
sizeT = len(T)
sizeS = len(S)
count = 0
tmp = 0
for i in range(sizeT):
    # print("あ")
    # print(S.index(T[i]))
    for j in range(i,sizeS):
        tmp = 0
        for k in range(sizeT-i):
            # print(tmp)  
            # print("K",k)
            if j+k < sizeS:
                if T[i+k]==S[j+k]:
                    tmp += 1
                    # print(tmp)
                else:
                    k = sizeT-i-1
                    # print("sizeT-i",k)
                    break
        if tmp > count:
            count = tmp

print(sizeT-count)

Submission status: Wrong Answer

Solution code:
s=str(input())
t=str(input())
n=len(t)
m=len(s)
ans=0
a=[]
if t in s:
  print(0)
else:
  for i in range(m-n+1): #ずらす文字数
    for j in range(n):
      if s[i+j]!=t[j]:
        ans+=1
    a.append(ans)
  print(min(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
temp = T
ans = 0
ret = False
t = list(T)
s = list(S)
t_ans = len(t)
f_ans = len(t)
if T[0] in S:
    for i in range(len(t)):
        if T in S:
            t_ans = ans
            ret = True
            break
        ans += 1
        T = T[:-1]
T = temp
ans = 0
if T[-1] in S:
    for i in range(len(t)):
        if T in S:
            f_ans = ans
            ret = True
            break
        ans += 1
        T = T[1:]
if ret:
    print(min(f_ans, t_ans))
else:
    print(len(t))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

S = input()
T = input()
if(T in S):
    print(0)
Sl = list(S)
Tl = list(T)
num=[]

for i in np.arange(len(Tl)):
    if(T[:len(Tl)-i] in Sl):
        num.append(len(Tl)-i)
if (num==[]):
    print(len(Tl)-1)
else:
    print(min(num))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
cnt = 0
min = 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 min < cnt:
        min = cnt
ans = len(t)-min

s = s[::-1]
t = t[::-1]
cnt=0
min=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 min < cnt:
        min = cnt
if ans > len(t)-min:
    ans = len(t)-min
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 177B
#
import sys

s = input()
t = input()

i = 0
tl = t
while i<len(t):
    if t[0:(len(t)-i)] in s:
        tl = t[0:(len(t)-i)]
        #print(tl)
        break
    i += 1

l = len(t)-len(tl)

#print("==================")

i = 0
tr = t
#print("start tr:"+tr)
while i<len(t):
    if t[i:len(t)] in s:
        tr = t[i:(len(t))]
        #print("i:"+str(i)+"  tr:"+tr)
        break
    i += 1
#print("result tr:"+tr)

r = len(t)-len(tr)

#print("l:"+str(l))
#print("r:"+str(r))

if t==s:
    print("0")
    sys.exit()

if l==0 and r==0:
    print(len(t))
    sys.exit()

if l==0:
    print(r)
    sys.exit()
elif r==0:
    print(l)
    sys.exit()

if l>r :
    print(str(r))
else:
    print(str(l))

Submission status: Wrong Answer

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

c = []
flag = False
for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        if s[j+i] == t[j]:
            if flag:
                count += 1
            else:
                count = 1
            flag = True
        else:
            flag = False
    c.append(count)

print(len(t) - max(c))

Submission status: Wrong Answer

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

Sn = len(S)
Tn = len(T)

ans = 0

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

print(Tn - ans)

Submission status: Wrong Answer

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

length_s, length_t = len(S), len(T)

dif = length_s-length_t

res = 0
for i in range(dif):
    st = sum(1 if s == t else 0 for s, t in zip(S[i:i+length_t], T))
    res = max(res, st)

print(length_t-res)

Submission status: Wrong Answer

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

t_length = len(t)

for i in range(t_length):
  if t[0:t_length - i] in s:
     break   
print(i)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
pos = True
for i in range(len(t)):
    if t[:len(t) - i] in s:
        print(i)
        pos = False
        break
s1, t1 = s, t
if pos:
    for j in t:
        if j in s:
            s1 = s1.split(j)
            t1 = t1.split(j)
            if len(s1[0]) >= len(t1[0]) and len(s1[1]) > len(t1[1]):
                print(len(t) - 1)
                break
            else: s1, t1 = s, t

Submission status: Wrong Answer

Solution code:
import itertools
import re
import sys

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

lst = [i for i in range(len(T))]
# print(lst)
combs = []

if(T in S):
    print(0)

for i in range(1, len(lst)+1):
    els = [list(x) for x in itertools.combinations(lst, i)]
    # print(i, els)
    for e in els:
        pattern = T
        for j in e:
            str_list = list(pattern)
            str_list[j] = '.'
            pattern = "".join(str_list)
            # print(i, ".*" + pattern + ".*")
            if(re.search(pattern, S)):
                print(i)
                sys.exit()

Submission status: Wrong Answer

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

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

print(l-num)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input()
T = input()
if len(S) - len(T) > 0:
  score_list = []
  for i in range(0, len(S) - len(T)):
    s = S[i:i+len(T)]
    score = sum([1 if s[i]==T[i] else 0 for i in range(len(s))])
    score_list.append(score)
  print(len(T) - max(score_list))
else:
  score = sum([1 if S[i]==T[i] else 0 for i in range(len(S))])
  print(len(T) - score)

Submission status: Wrong Answer

Solution code:
from difflib import SequenceMatcher
s = input()
t = input()
 
match = SequenceMatcher(None, s, t).find_longest_match(0, len(s), 0, len(t))
ans = len(t) - match.size
print(ans)

Submission status: Wrong Answer

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

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

print(len(T))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

while len(T) < len(S):
  cnt = 0
  for(SL,TL) in zip(list(S),list(T)):
    if SL != TL:
      cnt = cnt + 1
  
  if MIN > cnt:
   MIN = cnt
  
  S = S[1:]

print(MIN)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

s = input()
t = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

max_cnt = 0
for i in range(len(s) - len(t)):
    _s = s[i:i + len(t)]

    cnt = 0
    for j in range(len(t)):
        if _s[j] == t[j]:
            cnt += 1

    # print('match', cnt)

    if max_cnt < cnt:
        max_cnt = cnt

print(len(t) - max_cnt)

Submission status: Wrong Answer

Solution code:
import re
s=input()
t=input()
li=[]
cntli=[]
n=len(t)
for i in range(1,1<<n):
  wk=""
  cnt=0
  for j in range(n):
    if (i>>j) & 1 == 1:
      wk+=t[j]
    else:
      wk+="."
      cnt+=1
  li.append(wk)
  cntli.append(cnt)
ans=n
for i in range(len(li)):
  if re.search(li[i],s):
    ans=cntli[i]
    break
print(ans)

Submission status: Wrong Answer

Solution code:
#
# 177B
#
import sys

s = input()
t = input()

i = 0
tl = t
while i<len(t):
    if t[0:(len(t)-i)] in s:
        tl = t[0:(len(t)-i)]
        #print(tl)
        break
    i += 1

l = len(t)-len(tl)

#print("==================")

i = 0
tr = t
#print("start tr:"+tr)
while i<len(t):
    if t[i:len(t)] in s:
        tr = t[i:(len(t))]
        #print("i:"+str(i)+"  tr:"+tr)
        break
    i += 1
#print("result tr:"+tr)

r = len(t)-len(tr)

#print("l:"+str(l))
#print("r:"+str(r))

if l==0 and r==0:
    print(len(t))
    sys.exit()

if l==0:
    print(r)
    sys.exit()
elif r==0:
    print(l)
    sys.exit()

if l>r :
    print(str(r))
else:
    print(str(l))

Submission status: Wrong Answer

Solution code:
def main():
    min_num = 10000
    for i in range(len(S)):
        count = 0
        for j in range(len(T)):
            try:
                if S[i+j] == T[j]:
                    count += 1
            except:
                break
        min_num = min_num if min_num < len(T)-count else len(T)-count
    print(min_num)

S = input()
T = input()
main()

Submission status: Wrong Answer

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

count = 10000

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

Submission status: Wrong Answer

Solution code:
import sys

s = input()
t = input()
if t in s:
    print(0)
    sys.exit()
l = len(t)
for i in range(l):
    for j in range(i):
        a = 0
        if i == j:
            a = len(s)
        else:
            a = j - i
        if t[j:j + (l-i)] in s[j:a]:
            print(i)
            sys.exit()
print(l)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
A = len(T)
for i in range(len(T)):
    M = S.find(T[i:])
    if M >= i and A > i:
        A = i
    M = S.rfind(T[i:])
    if M >= i and A > i:
        A = i
for i in range(1,len(T)):
    M = S.find(T[:i])
    if M >= i and A > len(T)-i + 1:
        A = len(T)-i +1 
    M = S.rfind(T[:i])
    if M >= i and A > len(T)-i:
        A = len(T)-i +1
print(A)

Submission status: Wrong Answer

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

suma=0
sumb=0
sumc=0

for i in range(len(T)):
    A = T[i:]
    B = T[:i+1]
    if A in S:
        pass
    else:
        suma+=1

    if B in S:
        pass
    else:
        sumb+=1

    if A in S:
        if B in S:
            pass
    else:
        sumc+=1


suma = min(suma, sumb)
suma = min(suma, sumc)
print(suma)

Submission status: Wrong Answer

Solution code:
s, t = input(), input()
i, j = 0, 0
longest = 0
for i in range(len(s)-len(t)):
    count = sum([s[i+j] == t[j] for j in range(len(t))])
    longest = max(longest, count)
print(len(t)-longest)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if len(s)==len(t):
  num=0
  for i,j in zip(s,t):
    if i!=j:
      num+=1
else:
  for i in range(len(s)-len(t)+1):
    a=s[i:len(t)+i]
    num=0
    for i,j in zip(t,a):
      if i!=j:
        num+=1
    num=min(1000,num)

print(num)

Submission status: Wrong Answer

Solution code:
import itertools

ans1 = []
def main():
  s = input()
  t = input()
  for i in range(len(t)):
    if t[0:i] in s:
    #  print(t[0:i],s,i)
      ans1.append(len(t[0:i]))
    if t[i:] in s:
   #   print(t[i:],s,i)
      ans1.append(len(t[i:]))      
  print(len(t)-max(ans1))
  #print(ans1,ans2)   
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

if t not in s:
    diff = len(s)
    for i in range(len(t),0,-1):
        for j in range(i):
            if t[j:i] in s:
                if s.index(t[j:i]) < j or len(s)-s.index(t[j:i])+len(t[j:i])  < len(t)-i:
                    continue
                if diff > len(t)-len(t[j:i]) :
                    diff = len(t)-len(t[j:i])
                
        if diff <= len(t) - i:
            break
print(diff)

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
A=[]
t=T
while t:
    for i in range(len(t)):
        A.append(t[i:])
    t=t[:len(t)-1]
ans=len(T)
for i in A:
    if i in S and len(S)-S[::-1].index(i[0])>=T.index(i[0]):
        c=len(T)-len(i)
        ans=min(ans,c)
print(ans)

Submission status: Wrong Answer

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

for i in range(len(T)):
    lT = len(T)-i+1
    sT = 0
    while lT != len(T)+1:
        if T[sT:lT-1] in S[sT:len(S)]:
            print(i)
            exit()
        else:
            sT += 1
            lT += 1

print(len(T))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

s = input()
t = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

max_cnt = 0
for i in range(len(s) - len(t)):
    _s = s[i:i + len(t)]
    # print(_s, t)
    if _s == t:
        print('0')
        exit()
    else:
        cnt = 0
        for j in range(len(t)):
            if _s[j] == t[j]:
                cnt += 1

    # print('match',cnt)

    if max_cnt < cnt:
        max_cnt = cnt

print(len(t) - max_cnt)

Submission status: Wrong Answer

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

for i in reversed(range(len(T))):
    for j in range(len(T)-i):
        subStr = T[j:i+1+j]
        if(subStr in S):
            if(S.find(subStr) >= j):
                print(len(T)-(i+1))
                exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input()
T = input()
score_list = []
if len(S) - len(T) > 0:
  for i in range(0, len(S) - len(T)):
    s = S[i:i+len(T)]
    score = sum([1 if s[i]==T[i] else 0 for i in range(len(s))])
    score_list.append(score)
  print(len(T) - max(score_list))
else:
  score = sum([1 if S[i]==T[i] else 0 for i in range(len(S))])
  print(len(T) - score)

Submission status: Wrong Answer

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

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

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

    ans = min(ans, len_t - max_cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
from difflib import SequenceMatcher

s = input()
t = input()

match = SequenceMatcher(None, s, t).find_longest_match(0, len(s), 0, len(t))

ans = len(t) - match.size

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    S = str(input())
    T = str(input())
    counter = 0
    max_match = 0

    if T in S:
        print(0)
    else:
        for i in range(len(T), len(S)):
            for j in range(len(T)):
                if S[i-len(T)+j] == T[j]:
                    counter += 1
            if max_match < counter:
                max_match = counter
            counter = 0
        print(len(T)-max_match)
main()

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
m = len(t)
for i in range(len(s)-len(t)+1):
    c = 0
    target = s[i:i+len(t)]
    print(target)
    for j in range(len(t)):
        print(target[j],t[j])
        if not target[j] == t[j]:
            c += 1
    print(m,c)
    if c < m :
        m = c
print(m)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
s_len = len(s)
t_len = len(t)

max_c = 0
if t in s:
    print(0)
    exit()
for i in range(s_len - t_len):
    count = 0
    for j in range(t_len):
        if s[i+j] == t[j]:
            count+=1
    if count == t_len:
        print(0)
        exit()
    if count > max_c:
        max_c = count
print(t_len-max_c)

Submission status: Wrong Answer

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

def count_equals_max(s_, t_, i_):
    max_partial_t = 0

    for l in range(len_t):
        for i in range(0, len_t - l):
            if t_[i : i + l] in s_ and max_partial_t < len(t_[i : i + l]) and i_ >= i:
                max_partial_t = len(t_[i : i + l])

    return max_partial_t

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

if len_s == len_t:
    print(len_s - count_equals_max(s, t, 0))
    exit()

for i in range(0, len_s - len_t + 1):
    equals = count_equals_max(s[i : i + len_t], t, i)

    if equals > max_t:
        max_t = equals

print(len_t - max_t)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input()
T = input()
score_list = []
if len(S) - len(T) > 0:
  for i in range(0, len(S) - len(T)):
    s = S[i:i+len(T)]
    score = sum([1 if s[i]==T[i] else 0 for i in range(len(s))])
    print(s, T, score)
    score_list.append(score)
  print(len(T) - max(score_list))
else:
  score = sum([1 if S[i]==T[i] else 0 for i in range(len(S))])
  print(len(T) - score)

Submission status: Wrong Answer

Solution code:
xmoji=input()
ymoji=input()

x=len(xmoji)
y=len(ymoji)
tempmin = 0
for i in range(0,x-y+1):
    xmin=xmoji[i:i+y]
    samenum=0
    for j in range(0,y-1):
        if(xmin[j]==ymoji[j]):
            samenum+=1
    if(tempmin<samenum):
        tempmin = samenum 
print(y-tempmin)