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()
ans = 1001
for i in range(len(s)-len(t)) :
    point = 0
    for j in range(len(t)) :
        if t[j] != s[j+i] :
            point += 1
    ans = min(point,ans)
print(ans)

Submission status: Wrong Answer

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

slist = list(s)
tlist = list(t)
ans = 0
for i in range(len(slist)-len(tlist)):
    
    num = 0
    for k in range(len(tlist)):
        if slist[i+k] == tlist[k]:
            num += 1
    if num >= ans:
        ans = num
print(len(tlist)-ans)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
t = input()

ans = 10**5

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

S = []

for i in range(len_s):
    S.append(s[i])

for i in range(len_s - len_t):
    tmp = 0
    for j in range(len_t):
        if t[j] != S[i+j]:
            tmp += 1
    if tmp == t:
        print(0)
        exit()
    if tmp < ans:
        ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
n = len(t)
sl = len(s)
mmax= 0
for i in range(sl):
    cnt=0
    for y in range(n):
        #print(s[i+y],t[y])
        if i+y>=sl:
            break
        if s[i+y]==t[y]:
            cnt+=1
    mmax = max(mmax,cnt)
print(n-mmax)

Submission status: Wrong Answer

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

s_length = len(s)
t_length = len(t)

ans = 1000

for i in range(s_length - t_length):
  diff = 0
  parts = s[i:t_length+i]
  for j in range(t_length):
    if parts[j] != t[j]:
      diff += 1
  if ans > diff:
    ans = diff

print(ans)

Submission status: Wrong Answer

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

print(min_num)

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,0,-1):
  for t_range in range(n-size):
    bubun = t[t_range:t_range+size]
    for s_range in range(t_range,len(s)-size):
      if bubun == s[s_range:s_range+size]:
        no_change = size
  if no_change != 0:
    break

print(n-no_change)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
if t in s: print(0)
else:
    for i in range(1, len(t) + 1):
        if t[:i] in s:
            print(i)
            break
    for j in s:
        for k in t:
            if j == k:
                s0 = s[:s.index(j)]
                s1 = s[s.index(j):]
                t0 = t[:t.index(k)]
                t1 = t[t.index(k):]
                if len(s0) > len(s1) and len(t0) > len(t1): print(len(t) - 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

t2_list = []
for i in range(len(t)):
    for j in range(i, len(t)):
        t2_list.append(t[i:j+1])
t2_list.sort(key=len, reverse=True)
# print(t2_list)

flg = True
for t2 in t2_list:
    if s.find(t2) != -1:
#         print(f"t2: {t2}")
        s_find = s.find(t2)
        t_find = t.find(t2)
        
        s_nokori = len(s) - s_find - len(t2)
#         print(len(s), s_find, len(t2))
        if (s_find >= t_find) & (s_nokori >= 0):
#             print(f's_find: {s_find}, t_find: {t_find}, s_nokori: {s_nokori}')
            print(len(t) - len(t2))
            flg = False
            break

if flg:
    print(len(t))

Submission status: Wrong Answer

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

N = len(T)

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

min_change = N
for i in range(len(S) - N):
    S_part = S[i:i+N]

    change = N
    for j in range(N):
        if (S_part[j] == T[j]):
            change = change - 1

    if (change < min_change):
        min_change = change

print(min_change)

Submission status: Wrong Answer

Solution code:
import numpy as np
S = input()
T = input()

tmp = np.zeros(len(T))

i=0
flg=True

while flg:
    for j in range(i, len(T)):
        if T[i:j+1] in S:
            tmp[i] = j
    i = i + int(tmp[i])
    if i >= len(T)-1:
        flg=False

print(int(np.max(tmp)))

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[i:-(len(T) - j)]:
            if len(T) - len(T[i:j]) < ans:
                ans = len(T) - len(T[i:j])

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = str(input())
T = str(input())
temp = ""
tempcount=0
mincount = 0

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

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

Submission status: Wrong Answer

Solution code:
import re
s=input()
t=input()
len_t=len(t)
m = re.match(t, s)
if not m==None:
  print(0)
  exit()
else:
  t_0="\w"+t[1:]
  m = re.search(t_0, s)
  if not m==None:
    print(1)
    exit()
  for i in range(1,len_t-1):
    t_0=t[:i]+"[a-z]"+t[i+1:]
    m = re.search(t_0, s)
    if not m==None:
      print(1)
      exit()
  for j in range(2,len_t):
    t_0="[a-z]{"+str(j)+"}"+t[j:]
    m = re.search(t_0, s)
    if not m==None:
      print(j)
      exit()
      for i in range(1,len_t-j):
        t_0=t[:i]+"[a-z]{"+str(j)+"}"+t[i+j:]
        m = re.search(t_0, s)
        if not m==None:
          print(j)
          exit()  
print(len_t)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans = len(T)
for i in range(0, len(S)-len(T)):
    cnt = len(T)
    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 = input()
T = input()

s_len = len(S)
t_len = len(T)

longest = 0
for i in range(t_len):
  for j in range(i+1, t_len+1):
    word = T[i:j]
    tmp_s = S[i:s_len-(t_len-j)]
    if word in tmp_s and len(word) > longest:
      longest = len(word)

print(str(t_len - longest))

Submission status: Wrong Answer

Solution code:
import re
S=str(input())
T=str(input())
L=len(T)
tmp=None
if re.search(T,S)==None:

  for i in range(L):
    U=""
    U=T[0:L-i]
    for j in range(i):
      U=U+"."
    ##print(U)
    if re.search(U,S)!=None:
      tmp=i
      break
  for i in range(L):
    V=""
    for j in range(i):
      V="."+V
    V=V+T[i:L]
    ##print(V)
    if re.search(V,S)!=None:
      if tmp==None:
        tmp=i
      break
if tmp==None:
  tmp=L
print(tmp)

Submission status: Wrong Answer

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

N = len(T)

min_change = N
for i in range(len(S) - N):
    S_part = S[i:i+N]

    change = N
    for j in range(N):
        if (S_part[j] == T[j]):
            change = change - 1

    if (change < min_change):
        min_change = change

print(min_change)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def match_num(s, part_s):
    match = 0
    max_match = 0
    for (s_char, part_s_char) in zip(s, part_s):
        if s_char == part_s_char:
            match += 1
        else:
            if match > max_match:
                max_match = match
            match = 0

    if match > max_match:
                max_match = match
    return max_match


s = input()
t = input()

max_match = 0

for i in range(len(s)):
    if i+len(t) > len(s):
        break
    part_s = s[i:i+len(t)]
    match = match_num(t, part_s)
    if match > max_match:
        max_match = match

print(len(t)-max_match)

Submission status: Wrong Answer

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

slist = list(s)
tlist = list(t)
ans = 0
for i in range(len(slist)-len(tlist)):
    
    num = 0
    for k in range(len(tlist)):
        if slist[i+k] == tlist[k]:
            num += 1
    if num > ans:
        ans = num
print(len(tlist)-ans)

Submission status: Wrong Answer

Solution code:
def B():
    s = input()
    t = input()
    import re
    if t in s:
        print(0)
        return
    for i in range(1,len(t)):
        for j in range(len(t)-i):
            tmp = t[:j+1]+"[a-z]{"+str(i)+"}"+t[i+j+1:]
            ret = re.search(tmp, s)
            if ret:
                print(i)
                return
    print(len(t))
B()

Submission status: Wrong Answer

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

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

if flag == 0:
    print(l)

Submission status: Wrong Answer

Solution code:
def main():
    import copy
    S = str(input())
    T = str(input())
    ans = 0
    temp = 0

    for i in range(len(S)) :
        #print("S=",S[i])
        ans = 0
        for j in range(len(T)):
            #print("S=", S[i+j])
            #print("T=", T[j])
            if i+j >= len(S) :
                break
            #print("T=", T[j])
            #print("S=", S[i+j])
            if T[j] in S[i+j] :
                ans += 1
                #print(ans)
        temp = max(ans, temp)

    ans = len(T) - temp
    #if len(S) == 1 and len(T) == 1 and S == T :
    #    ans = 0
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

S = input()
T = input()

text = ''

for moji in T:
    text += moji
    if S.count(text) == 0:
        text = text[0:-1]
        break

if text == '':
    print(len(T)-1)
else:
    print(len(T)-len(text))

Submission status: Wrong Answer

Solution code:
import re
import sys
s = input()
t = input()
for i in range(len(t)):
  if  re.search(t,s) != None:
    print(0)
    sys.exit()
  t1 = t[1:]
  t2 = t[:len(t)-i]
  if None!=re.search( ".+"+t1+".+",s):
    print(i)
    sys.exit()
  if None!=re.search( ".+" + t2 + ".+",s):
    print(i)
    sys.exit()
    
  if i == len(t)-1:
    print(len(t)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
n = 0
ans = len(t)
while len(t) > n:
    a = 0
    con = len(t)
    b = 0
    while len(s) > a:
        if len(t) <= n+b:
            break
        if a + n >= len(s):
            break
        
        if s[a+n] == t[n+b]:
            con -=1
            b += 1
        else:
            con = len(t)
            b = 0
        a += 1
        ans = min(ans,con)
        if ans == 0:
            break
    n += 1
    if ans == 0:
        break
print(ans)

Submission status: Wrong Answer

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

def count(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 == c2:
            cnt += 1
    return cnt

max_ = 0
for i in range(1,len(S)-len(T)+1):
    max_= max( count(S[i:len(T)+i],T) ,max_ )

print( len(T) - max_ )

Submission status: Wrong Answer

Solution code:
s_long = input()
s_shor = input()

ans = len(s_shor)

strr_1 = s_shor
strr_2 = s_shor

if (strr_1 in s_long):
    print(0)
    exit()

else:
    for i in range(1, len(s_shor)):
        strr_1 = s_shor[: - i]
        strr_2 = s_shor[i:]
    
        if (strr_1 in s_long or strr_2 in s_long):
            ans = min(ans, i)
    
    

print(ans)

Submission status: Wrong Answer

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

for l in reversed(range(len(T))):
    length = l + 1
    #print(length)
    for start in range(len(T) - l):
        #print(T[start:start + length])
        if T[start:start + length] in S[start:]:
            print(len(T) - length)
            #print(T[start:start + length])
            #print(S[start:])
            break
        elif l == 0:
            print(len(T))
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = []
for i in range(len(t)):
    for j in range(i, len(t)):
        if (len(t)-1) != j:
            if s[i:-(len(t)-j)].count(t[i:j+1]) >= 1:
                ans.append(j+1-i)
        else:
            if s[i:].count(t[i:j+1]) >= 1:
                ans.append(j+1-i)
if ans == []:
    print(len(t))
else:
    print(len(t)-max(ans))

Submission status: Wrong Answer

Solution code:
from collections import deque
s = input()
s1 = list(s)
t = input()
t1 = deque()

for i in t:
    t1.append(i)

if t in s:
    print(0)
    exit()

for i in range(1,len(t)):
    t1.pop()
    a = ''.join(t1)

    if a in s:
        print(i)
        exit()
    if i == len(t)-1:
        print(len(t)-1)

Submission status: Wrong Answer

Solution code:
def check(a,b):
    cnt=0
    for x in range(len(a)):
        if a[x]!=b[x]:
            cnt+=1
    return cnt        
s=input()
t=input()
k=len(t)
ans=k
for x in range(len(s)-len(t)):
    ans=min(ans,check(s[x:x+k],t))
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
s = input()
t = input()
ans = 0
for i in range(len(t)):
    for j in range(i,len(t)):
        me = t[i:j]
        if(me in s[i:]):
            ans = max(len(me),ans)
print(len(t)-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)
for i in range(len(t)):
    for k in range(len(t) - len(T)):
        if T in S[k:k + len(T)]:
            print(len(t) - len(T))
            ret = True
if not ret:
    print(len(t))

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
s = len(S)
t = len(T)

def longestSubstringFinder(string1, string2):
    answer = ""
    len1, len2 = len(string1), len(string2)
    for i in range(len1-len2):
        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


print(t-len(longestSubstringFinder(S,T)))

Submission status: Wrong Answer

Solution code:
n = 2  # nは入力回数
str_list = [input() for _ in range(n)]
print(str_list)

S = str_list[0]
T = str_list[1]
count1 = 0
count2 = 0

for i in range(len(T)):
    if T in S:
        break
    else:
        count1 += 1
        T = T[:-1]
        
S = str_list[0]
T = str_list[1]

for i in range(len(T)):
    if T in S:
        break
    else:
        count2 += 1
        T = T[1:]
        
if count1>count2:
    print(count2)
else: print(count1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def cout_dif(a, b):
    sum = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            sum += 1
    return sum
    
def main():
    s = input()
    t = input()
    min = 10**5
    for i in range(len(s)-len(t)):
        sum = cout_dif(t, s[i:i+len(t)+1])
        if sum < min:
            min = sum
    print(min)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
index=0
count=0
for i in range (len(s)):
    if s[i]==t[0]:
       index=i+1
       break
if index == 0 or len(s[index:len(s)])<len(t)-1:
    print(len(s[index:len(s)]))
    for j in range(len(t)):
        if t[j]!=s[j]:
            count+=1
else:
    for j in range (1,len(t)):
        if t[j]!= s[index]:
            count+=1
        index+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
max = 0
for i in reversed(range(len(t)+1)):
    for j in range(len(t)-i+1):
        search = i+j-len(t)
        if search == 0:
            if t[j:i+j] in s[j:] and i >= max:
                max = i
        else:
            if t[j:i+j] in s[j:search] and i >= max:
                max = i

print(len(t) - max)

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
s=S
t=T
for x in range(len(t)):
    if T[:len(S)-x] in S:
        break
    else:
        T=T[:-1]
count=0
for x in range(len(t)-len(T)):
    if s[len(T)+x]!=t[len(T)+x]:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import itertools
s = input(); t = input()
perm = []
for i, j in itertools.combinations(range(len(t) + 1), 2):
    perm.append(t[i:j])
    
new_list_reverse = sorted(perm, key=len, reverse=True)

for c in new_list_reverse:
    if s.find(c) != -1 and s.find(c) >= t.find(c):
        print(len(t) - len(c))
        break

Submission status: Wrong Answer

Solution code:
a = list(input())
b = list(input())
min_k = len(b)
for i,k in enumerate(b):
  
  flag = True
  for j,m in enumerate(a):
    count=0
    if k==m:
      s = i+1
      l = j+1
      count+=1
      if s>=len(b) or l>=len(a):
        flag =False
      if i>=j:
        flag = False
      while flag:
        if b[s]==a[l]:
          count+=1
        s = s+1
        l = l+1
        if s>=len(b) or l>=len(a):
          flag =False
      min_k = min(min_k,len(b)-count)
          
print(min_k)

Submission status: Wrong Answer

Solution code:
# def Substring(S, T):
#     n = len(S)
#     m = len(T)
#     dic = {}
#
#     def traverse(i, j):
#         if i != n and j == m:
#             return 0
#         elif (i, j) in dic:
#             return dic[(i, j)]
#         else:
#             if S[i] == T[j]:
#                 ans = traverse(i + 1, j + 1)
#             else:
#                 ans = 1 + min(traverse(i + 1, j + 1), traverse(i+1,j))
#         return ans
#     return traverse(0,0)
# print(Substring("cabacc",
# "abc"))

def char_match(s,t,m):
    match = 0
    for i in range(m):
        if s[i] == t[i]:
            match += 1
    return match
def substring(S,T):
    m = len(T)
    char_mismatch = m
    for i in range(0,len(S)-m):
        char_mismatch = min(char_mismatch, m - char_match(S[i:i+m],T, m))
    return char_mismatch

def start():
    S = input()
    T = input()
    print(substring(S,T))
start()

Submission status: Wrong Answer

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

for i in range(len(t)+1):
	if t[0:len(t)-i] in s or t[i:len(t)] in s:
		break

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

ans = 0

for i in range(Sn - Tn):
    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()
N = len(s)
n = len(t)
m = 0
for i in range(N-n):
    cnt = 0
    S = list(s)[i:i+n]
    T = list(t)
    for j in range(n):
        if S[j] == T[j]:
            cnt += 1
    if m < cnt:
        m = cnt
print(n-m)

Submission status: Wrong Answer

Solution code:
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    S = s_input()
    T = s_input()

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

    print(min)

    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
cnt = 0
ans = 0

for ti in range(len(t)):
    for si in range(ti,len(s)):
        if t[ti] == s[si]:
            if len(t) -ti < len(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()
ans=1000

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

Submission status: Wrong Answer

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

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

lt = len(T)
ls = len(S)
for t in range(1,lt):
  if ((T[t:] in S) and (t <= S.find(T[t:]))):
    ans = t
    break
  if ((T[:-1*t] in S) and (ls - S.find(T[:-1*t]) - len(T[:-1*t]) >= t)):
    ans = t
    break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

def main():

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S,T = input(),input()
num = len(T)
ans = num
for i in range(num):
    for j in range(i+1,num+1):
        str = T[i:j]
        if str in S[i:len(S)-(num-j)]:
            ans = min(ans,num - len((T[i:j])))
            # print(i,j,ans,T[i:j],S[i:len(S)-(num-j)])

print(ans)

Submission status: Wrong Answer

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

for l in reversed(range(len(T))):
    length = l + 1
    #print(length)
    for start in range(len(T) - l):
        #print(T[start:start + length])
        if T[start:start + length] in S[start:]:
            print(len(T) - length)
            #print(T[start:start + length])
            #print(S[start:])
            break
    else:
        continue
    break

Submission status: Wrong Answer

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

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

count = 0
res = []


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

print(res)
print(min(res))

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
i,m=0,1e9
while(i<len(s)):
    c=0
    if(i+len(t)<len(s)):
        for j in range(len(t)):
            if(s[i]!=t[j]):
                c+=1
            i+=1 
    else:
        break
    m=min(m,c)
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    min_num = len(T)
    for i in range(len(S)):
        count = 0
        for j in range(len(T)):
            if i+j > len(S)-1:
                break
            if S[i+j] == T[j]:
                count += 1
        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()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
import sys
s = input()
t = input()
for i in range(len(t)):
  if  re.search(t,s) != None:
    print(0)
    sys.exit()
  t1 = t[1:]
  t2 = t[:len(t)-i]
  if None!=re.search( ".+"+t1+".+",s):
    print(i)
    sys.exit()
  if None!=re.search( ".+" + t2 + ".+",s):
    print(i)
    sys.exit()

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
cnt = 0
s_len = len(s)
t_len = len(t)
sa = s_len - t_len
Max = 0
for i in range(len(s) - len(t) - 1):
    ss = s[i:i+len(t)]
    for j in range(len(t)):
        if ss[j] == t[j]:
            cnt += 1
    Max = max(Max,cnt)
    cnt = 0
print(len(t) - Max)

Submission status: Wrong Answer

Solution code:
import math
min = math.inf
S = input()
T = input()

len_t = len(T)
for s in range(0,len(S)-len_t):
    sub = S[s: s+len_t]
    diff = 0
    for i in range(len_t):
        if sub[i] != T[i]:
            diff += 1
            if diff > min:
                break
    else:
        if diff < min:
            min = diff
print(min)

Submission status: Wrong Answer

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

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

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

print(m - ma)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = len(t)
long = ans

for i in range(len(t)):
    tc = t[i]
    for j in range(0+i,len(s)):
        if tc == s[j] and long - i - 1 <= len(s) - j - 1:
            count = 1
            if long == 1:
                ans = 0
            for k in range(1,long-i):
                if t[i+k] == s[j+k]:
                    count += 1
                else:
                    if ans > long - count:
                        ans = long - count
                    break
                if k == long - i - 1:
                    if ans > long - count:
                        ans = long - count
                    break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import copy
    S = str(input())
    T = str(input())
    ans = 0
    temp = 0

    for i in range(len(S)) :
        temp = max(ans, temp)
        ans = 0
        for j in range(len(T)):
            if i+j >= len(S) :
                break
            #print("T=", T[j])
            #print("S=", S[i+j])
            if T[j] in S[i+j] :
                ans += 1
                #print(ans)

    ans = len(T) - temp
    if len(S) == 1 and len(T) == 1 and S == T :
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()