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:
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:
S = list(input())
T = list(input())
max_s = 0
max_temp = 0

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] == T[j]:
            max_temp = max_temp + 1
        elif max_s < max_temp:
            max_s = max_temp
        else:
            max_temp = 0

print(len(T)-max_s)

Submission status: Wrong Answer

Solution code:
S = str(input())
T = str(input())
init = len(T)-1
tmp = init
ans = tmp+1
for i in range(0,len(S)):
    if i > len(S)-len(T):
        break
    for n in range(0, len(T)):
        #print(n)
        if S[i]==T[n]:

            ans =ans -1


            i=i+1
            if ans < tmp:
                tmp =ans

        else:
            ans = init+1
            break


ans = tmp
if ans <0:
    ans=0
print(ans)

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(m)

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
array = [0. for i in range(len(S))]
count = 0

for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j] and i >= j:
            count += 1
            array[i] += count
            break
        else:
            count = 0
print(int(len(T)-max(array)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
A = len(T)
print(len(T))
for i in range(len(T)-1):
    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 >= len(T)-i and A > len(T)-i:
        A = len(T)-i 
    M = S.rfind(T[:i])
    if M >= len(T)-i and A > len(T)-i:
        A = len(T)-i 
print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = []
for i in range(len(t)):
    # print(t[i:])
    # print(s[i:])
    if t[i:] in s[i:]:
        break
    for j in range(1,len(t[i:])):
        # print(t[i:][:-j])
        # print(s[i:][:-j])
        if t[i:][:-j] in s[i:][:-j]:
            ans.append(i+j)
            break
if t in s:
    print(0)
elif len(ans) == 0:
    print(len(t))
else:
    print(min(ans))

Submission status: Wrong Answer

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

t_l = len(t)
diff_min = 99999999
for i in range(len(s)-t_l):
    seq=s[i:i+t_l]
    diff_c = 0
    for j in range(len(seq)):
        if seq[j] != t[j]:
            diff_c += 1
    if diff_c < diff_min:
        diff_min = diff_c


print(diff_min)

Submission status: Wrong Answer

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

S=input()
T=input()

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

m=0

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

Submission status: Wrong Answer

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

slen = len(s)
tlen = len(t)

sone = ''

small = 0

for i in range(slen-tlen):
    sone = s[i:i+tlen]
    count = 0
    for e in range(tlen):
        if sone[e] != t[e]:
            count = count + 1
    if i == 0:
        small = count
    else:
        if count <= small:
            small = count

print(small)

Submission status: Wrong Answer

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


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


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

lenS = len(S)
lenT = len(T)
substrings = [(i, j, T[i: j]) for i in range(lenT) for j in range(i + 1, lenT + 1)]

minv = lenT
for i, j, s in substrings:
    if s in S:
        sidx = S.index(s)
        if (sidx >= i) & (sidx + j - i - 1 <= lenS - 1):
            candidate = lenT - (j - i)
            if minv > candidate:
                minv = candidate
print(minv)

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:
            for i in range(0, len(t)-len(t[j:j+i])):
                try:
                    ind = s.index(t[j:j+i])
                    if ind >= j and len(s[ind:]) - len(t[j:]) >= 0:
                        print(t[j:j+i])
                        ans = i
                        flag = True
                        break
                except:
                    pass

    if flag:
        break


print(len(t)-ans)

Submission status: Wrong Answer

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

n_s = len(S)
n_t = len(T)

p = "O"
boolean = False

for i in range(n_t):
  for j in range(0,i+1):
    t = T[j:(j+n_t-i)]
    i_s = S.find(t)
    i_t = T.find(t)
    if p == t:
      i_t += 1
    # print(t,i_t,i_s,len(T[i_t:]),len(S[i_s:]) )
    p = t
    if t in S:
      if (i_t <= i_s) and (len(T[i_t:]) <= len(S[i_s:])):
        print(i)
        boolean = True
        break 
  else:
    continue
  break

if not (boolean):
  print(n_t)

Submission status: Wrong Answer

Solution code:
import re
s = input()
t = input()
T = t
ct = 0
cr = 0
while True:
    m = re.search(t, s)
    if m:
        break
    else:
        ct += 1
        t = t[:-1:]

while True:
    m = re.search(T, s)
    if m:
        break
    else:
        cr += 1
        T = T[1::]

if cr > ct:
    print(ct)
else:
    print(cr)

Submission status: Wrong Answer

Solution code:
S = str(input())
T = str(input())
init = len(T)-1
tmp = init
ans = tmp+1
for i in range(0,len(S)):
    if i > len(S)-len(T):
        break
    for n in range(0, len(T)):
        #print(n)
        if S[i]==T[n]:

            ans =ans -1


            i=i+1
            if ans < tmp:
                tmp =ans

        else:
            ans = init+1
            break


ans = tmp
print(ans)

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 S.find(T[i:j]) >= i and len(S) - S.find(T[i:j]) - 1 >= len(T) - i - 1:
                ans = min(ans, len(T)-len(T[i:j]))
print(ans)

Submission status: Wrong Answer

Solution code:
def count(A,B):
    counter=0
    for i in range(len(A)):
        if A[i]==B[i]:
            counter+=1
    return len(A)-counter

S = input()
T = input()
t = len(T)
s = len(S)
_min = float('inf')
for i in range(s-t):
    _min = min(_min,count(S[i:i+t],T))
print(_min)

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline
 
S = input()
T = input()
s = len(S)
t = len(T)
ANS=[0]*(len(S))
 
for i in range(len(S)-len(T)):
  for j in range(len(T)):
    if S[i+j] == T[j]:
      ANS[i] += 1

ans = t- max(ANS)

#print(s)
#print(t)
#print(ANS)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys

if __name__ == '__main__':
    S = input()
    T = input()
    
    for i in range(len(T), 0, -1): #Tのsubstringの文字数
        for j in range(0, len(T)-i+1): #Tのsubstringの開始位置
            #print (T[j:i-1+j+1])
            k = S.find(T[j:i-1+j+1])
            if k != -1:
                if len(S)-1 >= k + len(T) - 1 - j: # うしろ
                    if k - j >= 0: # まえ
                        print (len(T)-i)
                        sys.exit()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
N = len(t)
count = 0
for i in range(N):
  if t[i] in s[i]:
    count += 1

print(count)

Submission status: Wrong Answer

Solution code:
P = [input().split() for i in range(2)]

S_a = P[0]
S = S_a[0]
T_a = P[1]
T = T_a[0]

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

max_y = 0

for x in range(s_len - t_len):

    y = 0
    for t in T:
        if t == S[x]:
            y = y+1
            x = x+1
        else:
            x = x+1

    if max_y <= y:
        max_y = y

print(t_len - max_y)

Submission status: Wrong Answer

Solution code:
S = str(input())
T = str(input())
init = len(T)-1
tmp = init
ans = tmp+1
for i in range(0,len(S)):
    if i > len(S)-len(T):
        break
    for n in range(0, len(T)):
        #print(n)
        if S[i]==T[n]:
            print(ans)
            ans =ans -1


            i=i+1
            if ans < tmp:
                tmp =ans

        else:
            ans = init+1
            break


ans = tmp
print(ans)

Submission status: Wrong Answer

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

for i in range(len(T)):           
    for j in range(i,len(T)):
        SS = S[i:j]
        if SS in T:
               A.append(j-i+1)
p = min(A)
print(p)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys

if __name__ == '__main__':
    S = input()
    T = input()
    
    for i in range(len(T), 0, -1): #Tのsubstringの文字数
        for j in range(0, len(T)-i+1): #Tのsubstringの開始位置
            #print (T[j:i-1+j+1])
            k = S.find(T[j:i-1+j+1])
            if k != -1:
                if len(S)-1 > k + len(T) - 1 - j: # うしろ
                    if k - j >= 0: # まえ
                        print (len(T)-i)
                        sys.exit()

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
SL=len(S)
TL=len(T)
ans2=0
for i,key1 in enumerate(T):
    for j,key2 in enumerate(S):
        ans=0
        if key1==key2 and j>=i and j-i<=SL-TL:
            ans+=1
            while True:
                i+=1
                j+=1
                if TL<i+1 or SL<j+1:
                    break
                elif T[i]==S[j]:
                    ans+=1
        ans2=max(ans2,ans)
print(TL-ans2)

Submission status: Wrong Answer

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

min_count = 10000000

for k in range(len(T)):
  for i in range(len(S)-len(T)+1): 
    count = k
    if T[k] == S[k+i]:
      for j in range(1,len(T)-k):
        if S[k+i+j] != T[k+j]:
          count += 1
      if count < min_count:
        min_count = count
        
print(min_count)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 0
mans = 0
fans = []
k = 0
prev = 0
for i in range(len(t)):
    for j in range(k,len(s)):
        if(t[i] == s[j]):
            m = i+1
            l = j+1
            while(m < len(t) and l < len(s)):
                if(t[m] != s[l] and (len(s)-l >= len(t)-m)):
                    mans = len(t)-m
                    fans.append(ans+mans)
                    break
                m += 1
                l += 1
    ans += 1
    k += 1
if(len(fans) == 0):
    print(len(t))
else:
    #print(fans)
    #print(ans)
    print(min(fans))

Submission status: Wrong Answer

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

lenS = len(S)
lenT = len(T)
substrings = [(i, j, T[i: j]) for i in range(lenT) for j in range(i + 1, lenT + 1)]

minv = lenT
for i, j, s in substrings:
    if s in S:
        sidx = S.index(s)
        if (sidx >= i) & (sidx + j - i - 1 <= lenS):
            candidate = lenT - (j - i)
            if minv > candidate:
                minv = candidate
print(minv)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
c =0
C = [0]
for i in range(len(S)):
  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
      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:
import sys, 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 = len(t)
    for i in range(min):
        tt1 = t[i:]
        tt2 = t[0:len(t) - i]
        if s.find(tt1) >= 0 or s.find(tt2) >= 0:
            min = i
            break

    print(min)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline
 
S = input().rstrip()
T = input()
s = len(S)
t = len(T)
ANS=[0]*(len(S))
 
for i in range(len(S)-len(T)+1):
  for j in range(len(T)):
    if S[i+j] == T[j]:
      ANS[i] += 1

ans = t- max(ANS)

#print(s)
#print(t)
#print(ANS)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
A = len(T)
print(len(T))
for i in range(len(T)-1):
    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 > len(T)-i and A > len(T)-i:
        A = len(T)-i 
    M = S.rfind(T[:i])
    if M > len(T)-i and A > len(T)-i:
        A = len(T)-i 
print(A)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
c =0
C = [0]
for i in range(len(S)):
  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
      for k in range(len(T) - j-2):
        if S[i + k + 1] == T[j + k +1]:
          c += 1
      C.append(c)
      c = 0
      break
C.append(c)


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

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 cnt > 1:
                break
            cnt += 1
            ans = max(ans,cnt)
        else:
            cnt = 0
print(len(t) - ans)

Submission status: Wrong Answer

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

x = [0]
a = 0
for i in range(len(t)):
    for k in range(len(s)):
        if(t[i] == s[k] and ((len(s)- k) >= (len(t)-i)) and (k >= i)):
            a += 1
            for n in range(1,(len(t)-i)):
                if(t[i+n] == s[k+n]):
                    a += 1
                    
    x.append(a)
    a = 0

y = max(x) 

print((len(t) - y))

Submission status: Wrong Answer

Solution code:
S=str(input())
T=str(input())
nums=[]

if T in S:
    print(0)
else:
    S=list(S)
    T=list(T)
    for i in range(len(S)):
        ans=0
        if S[i] in T:
            key=T.index(S[i])
            if len(S)-i>=len(T)-key and i-key>=0:
                for j in range(len(T)):
                    if S[j+i-key]!=T[j]:
                        ans+=1
                nums.append(ans)
    if nums==[]:
        print(len(T))
    else:
        print(min(nums))

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 S.find(i)>=T.find(i) and S[::-1].find(i[::-1])>=T[::-1].find(i[::-1]):
        c=len(T)-len(i)
        ans=min(ans,c)
print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
t = list(input())
b = len(t)
a = 1
tt = ''.join(t)
ans = 0
ss = list(s)
for i in range(len(t),0,-1):

    for j in range(len(t)-i+1):
        tt = ''.join(t[j:j+i])

        if tt in ''.join(ss[j:]):
            print(b-len(tt))
            exit()

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 S.find(T[i:j]) + 1 >= i + 1 and len(S) - S.find(T[i:j]) - 1 >= len(T) - i - 1:
                ans = min(ans, len(T)-len(T[i:j]))
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
c =0
C = [0]
for i in range(len(S)):
  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
      for k in range(len(T) - j-2):
        if S[i + k + 1] == T[j + k +1]:
          c += 1
      else:
        C.append(c)
        c = 0
        break
C.append(c)
print(C)

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

Submission status: Wrong Answer

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

len_s = len(S)
len_t = len(T)

cnt = len_t
for i in range(len_s - len_t):
    c = 0
    for j in range(len_t):
        c += 1 if S[i+j] != T[j] else 0
    cnt = min(c, cnt)
print(cnt)

Submission status: Wrong Answer

Solution code:
import re

S, T = [str(input()) for _ in range(2)]

index_list = []
before_index_list = []
count_list = []

match_count = 0

if T in S:
  print(0)
else:
  index = 0
  counter = 0
  for s in S:
    for m in re.finditer(str(s), str(T)):
      if index >= m.start():
        if m.start() - 1 in before_index_list:
          counter += 1
        else:
          count_list.append(counter)
          counter = 1
      index_list.append(m.start())
    before_index_list = index_list
    index_list = []
    index += 1
  if len(count_list) == 0:
    print(len(T))
  else:
    print(len(T)-max(count_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input("")
t = input("")
ts = ""
j = len(t)
e = []
for a in range(j+1):
  for b in range(j):
    i = 0
    if b < (len(t)-a):
      ts = t[b:(len(t)-a)]
      sf = s.find(ts)
      if sf != -1 and (((sf+len(ts)+a)-1 <= len(s)) and ((sf-b) >= 0)):
        ss = s[sf:sf+len(t)]
        for c in range(len(ts)):
          if ts[c] == ss[c]:
            i += 1
        e.append(len(t)-i)
    else:
      break
if e == []:
  print(len(t))
else:
  print(min(e))

Submission status: Wrong Answer

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

lenS = len(S)
lenT = len(T)
substrings = [(i, j, T[i: j]) for i in range(lenT) for j in range(i + 1, lenT + 1)]

minv = lenT
for i, j, s in substrings:
    if s in S:
        sidx = S.index(s)
        if (sidx >= i) & (sidx + j - i + 1 <= lenS):
            candidate = lenT - (j - i)
            if minv > candidate:
                minv = candidate
print(minv)

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
max_s = 0
max_temp = 0

for s in S:
    for t in T:
        if s == t:
            max_temp = max_temp + 1
        elif max_s < max_temp:
            max_s = max_temp
        else:
            max_temp = 0

print(len(T)-max_s)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

S=input()
T=input()

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

m=0

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

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    t = S()
    s = list(s)
    t = list(t)
    slen = len(s)
    tlen = len(t)
    ans = float("inf")

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

    print(ans)

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n = len(S)

max_count = 0

for i in range(n):
  for j in range(i, n):
    if S[i:j+1] in T[-(n - i) : j + 1]:
      #print("OK", i, j)
      max_count = max(j - i + 1, max_count)
  #print(max_count)
      
print(len(T) - max_count)

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
finish = False
for i in range(len(T)):
    for j in range(i+1):
        A = T[j:j+len(T)-i]
        if (A in S) & (S.find(A) >= j) & (len(S) - (S.find(A)+len(T)-i) >= i-j):
            print(i)
            finish = True
            break
    if finish == True:
        break
else:
    print(len(T))

Submission status: Wrong Answer

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

ans = float('inf')
for i in range(0,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=input()
T=input()

match=0
for i in range(1,len(T)+1):
    tmp=T[:i]
    if(tmp in S):
        match=i

if(match==0):
    for i in range(len(T)):
        if(T[i] in S):
            match=1

print(len(T)-match)

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 and len(S) - S.find(T[i:j]) - 1 >= len(T) - i - 1:
                ans = min(ans, len(T)-len(T[i:j]))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input() 
ans = 0
for i in range(len(t)+1):
  for j in range(len(t)+1):
    #print(i,j)
    if i < j:
      t2 = t[i:j]
      #print(t2)
      if (t2 in s) and ans < j-i and i<=s.find(t2) \
      and len(t)-i <= len(s)-s.find(t2) :
        ans = j-i
        #print(i+len(t2),len(s)-s.find(t2))
        #print(ans)
        #print(len(s),len(t)-i, s.find(t2))
        #print(len(t)-ans)
print(len(t)-ans)

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 > len(T)-i and A > len(T)-i:
        A = len(T)-i 
    M = S.rfind(T[:i])
    if M > len(T)-i and A > len(T)-i:
        A = len(T)-i 
print(A)