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()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT + 1):
        d = 0
        for lt in range(LT):
            if S[ls] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))

Submission status: Wrong Answer

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

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

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) + 1):
    s = S[i:i+len(T)]
    if len(s) != len(T):
      continue
    score = sum([1 if s[i]!=T[i] else 0 for i in range(len(s))])
    score_list.append(score)
  print(min(score_list))
elif len(S) == len(T):
  score = sum([1 if S[i]!=T[i] else 0 for i in range(len(S))])
  print(score)

Submission status: Wrong Answer

Solution code:
import numpy as np
s = input()
t = input()
strs = []
t_size = len(t)
for i in np.arange(len(s)-len(t)+1):
    strs.append(s[i:i+t_size])
n = 0
max_n = 0
for ss in strs:
    for i in np.arange(len(t)):
        print(t[i], ss[i])
        if t[i]==ss[i]:
            n += 1
        if max_n < n:
            max_n = n
    n = 0
print(len(t)-max_n)

Submission status: Wrong Answer

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

maiores = []
maiores.append(1)
maior = 0

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


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

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

count = 0
ans = len(T)

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

Submission status: Wrong Answer

Solution code:
from difflib import SequenceMatcher
S = input()
T = input()
s = SequenceMatcher(None, T, S)
print(len(T) - s.find_longest_match(0, len(T), 0, len(S))[2])

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) + 1):
    s = S[i:i+len(T)]
    if len(s) != len(T):
      continue
    score = sum([1 if s[i]!=T[i] else 0 for i in range(len(s))])
    score_list.append(score)
  print(max(score_list))
elif len(S) == len(T):
  score = sum([1 if S[i]!=T[i] else 0 for i in range(len(S))])
  print(score)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    s = input()
    t = input()

    li = set()
    for i in range(len(t)):
        li.add(t[i])
        li.add(t[i:])
        li.add(t[:i])
    for el in sorted(li, key=lambda x: len(x), reverse=True):
        if el in s:
            print(len(t) - len(el))
            return
    print(len(t))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
M = len(S)
N = len(T)

ans = N
diff = M - N

for i in range(diff + 1):
    U = '0' * diff + T
    count = N
    for j in range(N + diff):
        if U[j] == S[j]:
            count -= 1
    ans = min(ans, count)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
  
MAX_CHAR = [26]  
def minChanges(str):   
    n = len(str )  
    if (n > MAX_CHAR[0]):  
        return -1
    dist_count = 0
    count = [0] * MAX_CHAR[0]  
  
    for i in range(n):  
        if (count[ord(str[i]) - ord('a')] == 0) : 
            dist_count += 1
        count[(ord(str[i]) - ord('a'))] += 1
    return (n - dist_count)  
if __name__ == '__main__': 
    str = "aebaecedabbee"
    print(minChanges(str))

Submission status: Wrong Answer

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

# t0=time()

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


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

print(k-maxn)

Submission status: Wrong Answer

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

if S.count(T) > 0:
    print(0)
    exit()

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

Submission status: Wrong Answer

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

cnt = []
for i in range(len(t)):
    for k in range(i + 1, len(t) + 1):
        if t[i:k] in s[i:]:
            cnt.append(k - i)
        else:
            cnt.append(0)
            #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

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) + 1):
    s = S[i:i+len(T)]
    if len(s) != len(T):
      continue
    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))
elif len(S) == len(T):
  score = sum([1 if S[i]!=T[i] else 0 for i in range(len(S))])
  print(score)

Submission status: Wrong Answer

Solution code:
S=list(map(str,input()))
T=list(map(str,input()))
X=[]
Z=0
for I in range(len(S)-len(T)):
    Y=S[I:I+len(T)]
    Z=0
    for J in range(len(T)):
        if Y[J]==T[J]:
            Z=Z+1
    X.append(Z)
if X ==True:
    print(len(T)-max(X))
elif S==T:
    print(0)
else:
    print(len(T))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
s_id = -1
cnt = 1
flg = 0
for i in range(len(T)):
    T1 = T[0:-i - 1]
    if T1 in S and len(T1) != 0:
        s_id = S.rfind(T1)
        flg = 1
        break
    cnt += 1
if not flg:
    cnt = 0
    for i in range(len(T)):
        T1 = T[i:]
        if T1 in S and len(T1) != 0:
            s_id = S.rfind(T1) - 1
            if s_id == -1:
                continue
            else:
                flg = 2
                break
        cnt += 1

if flg == 0 or s_id == -1:
    print(len(T))
else:
    print(cnt)

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) + 1):
    s = S[i:i+len(T)]
    if len(s) != len(T):
      continue
    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))
elif len(S) == len(T):
  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:
def Qb():
    s = input()
    t = input()

    ans = len(t)
    for v in range(len(t)):
        for x in range(len(t) - v):
            z = t[v:len(t) - x]
            if z in s[v:len(s) - x]:
                ans = v + x
                print(ans)
                exit()
    print(ans)


if __name__ == '__main__':
    Qb()

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
flg = False
for i in range(len(T)):
	for j in range(i+1):
		tmpS = S[j:]
		if -i+j < 0:
			tmpS = tmpS[:-i+j]
		#print(tmpS)
		#print(T[j:len(T)-i+j])
		if T[j:len(T)-i+j] in tmpS:
			flg = True
			print(i)
			break
	if flg:
		break
if flg == False:
	print(len(T))

Submission status: Wrong Answer

Solution code:
import re

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

index_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 index_list:
          counter += 1
        else:
          counter = 1
        index_list = []
        index_list.append(m.start())
    index += 1
  
  print(len(T)-counter)

Submission status: Wrong Answer

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

max_sub = ""
for i in range(len(T)):
  for j in range(i+1, len(T)+1):
    sub = T[i:j]
    last_num = len(T) - len(sub) - (i + 1)
    s = S[i:len(S) - last_num]
    if sub in s:
      if len(sub) >= len(max_sub):
        max_sub = sub
  
answer = len(T) - len(max_sub)
print(answer)

Submission status: Wrong Answer

Solution code:
L = input()
S = input()
result = 0

for i in range(len(S)):
    tmp = 0
    for j in L[i:]:
        if i + tmp >= len(S):
            break
        if S[i+tmp] == j:
            tmp += 1
            if result < tmp:
                result = tmp
        else:
            if result < tmp:
                result = tmp
            tmp = 0
print(len(S) - result)

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
r = len(S) - len(T)
if T in S:
    min = 0
else:
    min = float('inf')
    for i in range(r):
        t = 0
        for j, v in enumerate(T):
            t += int(S[i+j] != v)
        if min > t:
            min = t

print(min)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def s():return input()
def mp():return map(int,input().split())
a =s()
b =s()
ans = ""
q,w,r =0,0,0
for i in range(len(b)):
	ans+=b[i]
	if ans in a[w+1:]:
		q+=1
	else:
		w =i
		ans =""
		q =0
	r = max(r,q)
print(len(b)-r)

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) + 1):
    s = S[i:i+len(T)]
    if len(s) != len(T):
      continue
    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()
sl = len(S)
tl = len(T)

for i in range(tl + 1):
    if T[:tl - i] in S[:sl - i]:
        print(i)
        exit()
    elif T[:tl - i] in S[i:sl]:
        print(i)
        exit()
    elif T[i:tl] in S[i:sl] :
        print(i)
        exit()
    elif T[i:tl] in S[:sl - i] :
        print(i)
        exit()

Submission status: Wrong Answer

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

cnt = []
for i in range(len(t)):
    for k in range(i + 1, len(t) + 1):
        if t[i:k] in s[i:]:
            cnt.append(k - i)
        else:
            cnt = [0]
            #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

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

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

print(Tlen-counter)

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-1] 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()
minCount = 100000000
i = 0
while i < len(s):
    countSame = 0
    j = 0
    while j < len(t) and i+j < len(s):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
if len(t) == 0:
  print(0)
print(minCount)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
i = len(T)
ans = -1
while i > 0:
    if ans != -1:
        break
    sub_str = T[0:i]
    r = 0
    while r + len(sub_str) <= len(S):
        sub2 = S[r:r+len(sub_str)]
        r+=1
        if sub_str == sub2:
            print(sub_str)
            ans = len(T) - len(sub_str)
            break
    i-=1
if ans != -1:
    print(ans)
elif set(list(S)) & set(list(T)):
    print(len(T) - 1)
else:
    print(len(T))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


def solve(S, T):
    if S.find(T) >= 0:
        return 0

    for i in range(1, len(T)):
        head = T[:-i]
        tail = T[i:]

        head_idx = S.find(head)
        tail_idx = S.rfind(tail)

        if head_idx >= 0 and head_idx + len(T) <= len(S):
            return i

        if tail_idx >= 0 and tail_idx - i >= 0:
            return i

    return len(T)


def main():
    S = input()
    T = input()
    result = solve(S, T)
    print(result)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

    max_cnt = max(l)
    #print(l)

    ans = min(ans, len_t - max_cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
M = len(S)
N = len(T)

ans = N
diff = M - N

for i in range(diff + 1):
    U = '0' * diff + T
    count = N
    for j in range(N + diff):
        if U[j] == S[j]:
            count -= 1
        ans = min(ans, count)
print(ans)

Submission status: Wrong Answer

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

for i in range(length):
    if t[i:length] in s or t[:length-i] in s:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
sl = len(S)
tl = len(T)

for i in range(tl + 1):
    if T[:tl - i] in S[:sl - i]:
        print(i)
        exit()
    elif T[i:tl] in S[i:sl] :
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
a = input()
b = input()

l = []
for i in range(len(a) - len(b) + 1):
    cnt = 0
    for j in range(len(b)):
        if b[j] == a[i + j]:
            cnt += 1
    l.append(cnt)

print(l)
print(len(b) - max(l))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
import copy
T = copy.deepcopy(t)
nagasa_t=len(t)
count1=0
count2=0
for i in range(nagasa_t):
  if t in s:
    break
  else:
    t= t[:-1]
    count1+=1
    if i == nagasa_t-1:
        count1=nagasa_t
for i in range(nagasa_t):
  if T in s:
    break
  else:
    T = T[1:]
    count2+=1
    if i == nagasa_t-1:
        count2=nagasa_t

print(min(count1,count2))

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
r = len(S) - len(T)
min = float('inf') if T in S else 0
for i in range(r):
    t = 0
    for j, v in enumerate(T):
        t += int(S[i+j] != v)
    if min > t:
        min = t

print(min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
k = len(T)
ans=k-1
lim=0
for i in range(len(S)-len(T)+1):
  for j in range(k):
    #print(i, j, 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:
S = input()
T = input()

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

minv = lenT
for i, s in substrings:
    if s in S:
        candidate = lenT - len(s)
        if S.index(s) >= i:
            if minv > candidate:
                minv = candidate
print(minv)

Submission status: Wrong Answer

Solution code:
import re

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

index_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 index_list:
          print(s, m.start())
          counter += 1
        else:
          print(s, m.start())
          counter = 1
        index_list = []
        index_list.append(m.start())
    index += 1
  
  print(len(T)-counter)

Submission status: Wrong Answer

Solution code:
import re
s = input()
t = input()
ans = len(t)
for i in range(len(t)+1):
    for j in range((len(t))-i+1):
        pattern = "."*j + t[j:j+i] + "." *(len(t)-(i+j))
        if(pattern == "."*len(t)) :
            continue
        r = re.search(pattern, s)
        if r :
            ans = min(ans,len(t)-i)
print(ans)

Submission status: Wrong Answer

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

res = float("inf")
for i in range(len(t)):
    if t[i:] in s:
        res = i
#         print("i:", i)
        break
for j in range(1, len(t) - 1):
    if t[:(-j)] in s:
        res = min(j, res)
#         print("j:", j)
        break
print(res)

Submission status: Wrong Answer

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

ans = []
for i in range(len(t)):
    #print(t[i:])
    if t[i:] in s[i:]:
        break
    for j in range(1,len(t[i:])):
        #print(t[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()
ans = 1001
for i, s in enumerate(S):
    for j, t in enumerate(T):
        if not s == t:
            continue
        if i < j:
            continue
        tmp = 1
        for k in range(1, len(S)-i):
            if i+k > len(S)-1 or j+k > len(T)-1:
                break
            if S[i+k] == T[j+k]:
                tmp += 1
            else:
                ans = min(ans, len(T)-tmp)
                break
print(ans)

Submission status: Wrong Answer

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

max_sub = ""
for i in range(len(T)):
  for j in range(i+1, len(T)+1):
    sub = T[i:j]
    last_num = len(T) - len(sub) - i
    s = S[i:len(S) - last_num]
    if sub in s:
      if len(sub) >= len(max_sub):
        max_sub = sub
  
answer = len(T) - len(max_sub)
print(answer)

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)]:
            maxans = max(maxans, j - i + 1)
print(lenT - maxans)

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
f = s.find(t)
if f < ans and f != -1:
    ans = f
print(ans)

Submission status: Wrong Answer

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

t_substrings=[]
for i in range(len(t)+1):
  for j in range(i):
    t_substrings.append(t[j:i])
  
t_substrings=list(set(t_substrings))
#print(t_substrings)

ans=len(t)
for str in t_substrings:
  num=s.rfind(str)
  num_t=t.rfind(str)
  #print("str",str)
  #print("num",num)
  if num==-1:
    pass
  elif num+len(str)-1>=len(s):
    pass
  elif num_t-num>=0:
    pass
  else:
   # print("##")
    ans=min(len(t)-len(str),ans)
    #print(ans)
  #print("----------------")
print(ans)

Submission status: Wrong Answer

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

for i in range(1, len(T)+1):
    for s in range(i):
        search_str = T[s:s+len(T)-i+1]
#        print(search_str)
        find_index = S.find(search_str)
        if -1 != find_index:
            if find_index >= s and find_index + len(T) <= len(S):
                break

print(i-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
s = input()
t = input()
strs = []
t_size = len(t)
for i in np.arange(len(s)-len(t)+1):
    strs.append(s[i:i+t_size])
n = 0
max_n = 0
for ss in strs:
    for i in np.arange(len(t)):
        if t[i]==ss[i]:
            n += 1
        else:
            n = 0
        if max_n < n:
            max_n = n
print(len(t)-max_n)

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
import copy
T = copy.deepcopy(t)
nagasa_t=len(t)
count1=1
count2=1
for i in range(nagasa_t):
  if t in s:
    break
  else:
    t= t[:-1]
    count1+=1
    if i == nagasa_t-1:
        count1=nagasa_t
for i in range(nagasa_t):
  if T in s:
    break
  else:
    T = T[1:]
    count2+=1
    if i == nagasa_t-1:
        count1=nagasa_t

print(min(count1,count2))

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 t, s in zip(S, T):
            if t != s:
                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()

res = float("inf")
for i in range(len(t)):
    if t[i:] in s:
        res = i
        print("i:", i)
        break
for j in range(1, len(t) - 1):
    if t[:(-j)] in s:
        res = min(j, res)
        print("j:", j)
        break
print(res)

Submission status: Wrong Answer

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

for i in range(length):
    if t in s:
        print(i)
        break
    if t[i:length] in s or t[:length-i] in s:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
r = len(S) - len(T)
min = float('inf')
for i in range(r):
    t = 0
    for j, v in enumerate(T):
        t += int(S[i+j] != v)
    if min > t:
        min = t

print(min)

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    s = list(input())
    t = list(input())

    max_score = 0
    for i in range(0, len(s) - len(t)):
        score = sum([s[i + j] == t[j] for j in range(len(t))])
        if max_score < score:
            max_score = score
    print(len(t) - max_score)

Submission status: Wrong Answer

Solution code:
S=str(input())
T =str(input())
c=len(T)
for i in range(len(S)-len(T)+1):
    count=len(T)
    for n in range(len(T)):
        if S[i+n] == T[n]:
            count -=1
        else:
            break
    for n in range(len(T)):
        if S[i+len(T)-n-1] == T[len(T)-1-n]:
            count -=1
        else:
            break
    if count <0:
        count=0
    
    if count <c:
        c=count
print(c)

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import copy 
s = list(input())
t = list(input())
def check(ss,tt):
  for i in range(len(ss)-len(tt)):
    if ss[i] == tt[0] or ss[i]=="0":
      flg = 0
      for j in range(len(tt)):
        if ss[i+j]==tt[j] or ss[i+j]=="0":
          continue
        flg = 1
        break
      if flg == 0:
        return True
        break
  return False
a = [i for i in range(len(s))]
for i in range(len(s)):
  for pair in itertools.combinations(a,i+1):
    sa = copy.copy(s)
    for j in range(len(pair)):
      sa[pair[j]] = "0"
    if check(sa,t):
      print(i+1)
      sys.exit()

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の開始位置
            if S[j:len(S)-1-(len(T)-i)+j+1].find(T[j:i-1+j+1]) != -1:
                print (len(T)-i)
                sys.exit()

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:
            #print('index', s.index(t[j:j+1]), j)
            ind = s.index(t[j:j+1])
            if ind >= j and len(s) - ind - len(t[j:j+1]) > 0:
                ans = i
                flag = True
                break

    if flag:
        break


print(len(t)-ans)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
y=len(t)
z=len(s)
for i in range(0,(z-y+1)):
    xx=i+y
    s1=s[i:xx]
    ct=0
    yy=y
    for j in range(0,y):
        if(s1[j]==t[j]):
            ct+=1
    z=y-ct
    if(z<yy):
        yy=z
print(yy)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
if T in S:
  print(0)
  exit()
for i in range(len(T)):
  if T[i+1:] in S:
    print(i+1)
    exit()
  elif T[:-1 * (i+1)] in S:
    print(i+1)
    exit()

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:
            #print('index', s.index(t[j:j+1]), j)
            ind = s.index(t[j:j+1])
            if ind >= j and len(s) - ind - len(t[j:j+1]) > 0:
                ans = i
                flag = True
                break

    if flag:
        print('test')
        break


print(len(t)-ans)

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:].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)