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()
t = len(T)
for i in range(len(T)):
  b = 0
  for s in range(len(T)):
    if T[s:s+i+1] in S[s:len(S)-s]:
      b += 1
  if b == 0:
    break
print(t-i)

Submission status: Wrong Answer

Solution code:
import re

S=input()
T=input()
ans=len(T)
for i in range(len(T)-2):
	for j in range(i, len(T)):
		#print(T[i:j])
		if T[i:j] in S and T[i:j] !="": 			
			temp=[m.span() for m in re.finditer(T[i:j], S)]
			for _ in range(len(temp)):
				t=temp[_]
				mae,ushiro=t[0],t[1]-1
				#print(T[i:j],i,len(T)-j,mae, ushiro)
				if i<=mae and len(T)-j<=len(S)-ushiro:
					ans=min(ans,len(T)-len(T[i:j]))
					#print(len(T[i:j]))
				
			
			#print(T[i:j],S.find(T[i:j]))
			#print([m.span() for m in re.finditer(T[i:j], S)])

print(ans)

Submission status: Wrong Answer

Solution code:
import re
S = input()
T = input()
ast = []

flag = False
if T in S:
    print(0)
else:
    for i in range(1, len(T) + 1):
        if flag:
            break
        for s in range(len(T) + 1 - i):
            Tc = T
            Tc = Tc.replace(Tc[s:s+i], "."*i)
            if len(re.findall(Tc, S)) != 0:
                print(i)
                flag = True
                break

Submission status: Wrong Answer

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

# t0=time()

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


maxn = 0
if s==t:
    maxn=k
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=list(str(input()))
T=list(str(input()))
nums=[]

if T in S:
    print(0)
else:
    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()

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

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>=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=list(input())
T=list(input())
x=[0]*(len(S)+1)
for i in range(len(S)):
    for j in range(len(T)):
        if T[j]==S[i] :
            if (j-1)>=0 and (i-1)>=0 and T[j-1]==S[i-1]:
                x[i]=x[i-1]+1
            else:
                x[i]=1
print(len(T)-max(x))

Submission status: Wrong Answer

Solution code:

T=input()
S=input()
Tlist=list(T)
Slist=list(S)

TL=len(Tlist)
SL=len(Slist)

c=0
ans=SL

if S in T :
    ans=0
else:
    for i in range(TL-SL):
        for j in range(SL):
            if Tlist[j+i]!=Slist[j]:
                c=c+1
        if ans>c:
            ans=c
        c=0
            
        
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 i - S.find(T[i:j]) <= 0 and len(S) - S.find(T[i:j]) - 1 >= len(T) - i:
                ans = min(ans, len(T)-len(T[i:j]))
print(ans)

Submission status: Wrong Answer

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

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)-(len(t)-a-b)-i)
    else:
      break
if e == []:
  print(len(t))
else:
  print(min(e))

Submission status: Wrong Answer

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

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

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)+1):
  for j in range(len(T)):
    if S[i+j] == T[j]:
      ANS[i] += 1

ans = t- max(ANS)
#print(ANS)
print(ans)

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):
        c=len(T)-len(i)
        ans=min(ans,c)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input()
T = input()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_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 = ans
        if t == s:
            tmp -= 1
    ans = min(ans,tmp)
else:
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
L = len(s)
l = len(t)
p = L-l
ans = l
for i in range(l):
    for j in range(i+1,l+1):
        #print(t[i:j])
        if s[i:j+p].count(t[i:j])>0:
                ans = min(ans,l-len(t[i:j]))
print(ans)

Submission status: Wrong Answer

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

len_S = len(S)
len_T = len(T)

ans = 10*5
for i in range(len_S - len_T+1):
    num = 0
    for j in range(len_T):
        if S[i+j] != T[j]:
            num+=1
    ans = min(ans, num)

print(ans)

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 <= lenS):
            candidate = lenT - (j - i)
            if minv > candidate:
                minv = candidate
print(minv)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

Min = 100000

for i in range(len(S) - len(T) + 1):
    count = 0
    for n in range(len(T)):
        if S[i + n] != T[n]:
            count += 1
    print(count)
    if count < Min:
        Min = count

print(Min)

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[i+j] != T[k+j]:
          count += 1
      if count < min_count:
        min_count = count
        
print(min_count)

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]:
                if v + x < ans:
                    ans = v + x
    print(ans)


if __name__ == '__main__':
    Qb()

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

Submission status: Wrong Answer

Solution code:
import re

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

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

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 0 <= head_idx <= len(S) - len(T):
            return i

        if tail_idx >= i:
            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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque
import re

S=input()
T = input()

num = len(T)

for i in range(num, 0, -1):
    for start in range(num):
        if start + (i-1) >= num:
            break
        s = T[start:start+i]
        result = re.finditer(s,S)
        if result!=None:
            for m in result:
                if m.start() >= start:
                    print(num-i)
                    exit(0)

print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
T=input()
S=input()
Tlist=list(T)
Slist=list(S)

TL=len(Tlist)
SL=len(Slist)

c=0
ans=SL

if S in T :
    ans=0
else:
    for i in range(TL-SL):
        for j in range(SL):
            if Tlist[j+i]!=Slist[j]:
                c=c+1
        if ans>c:
            ans=c
    c=0
                 
print(ans)

Submission status: Wrong Answer

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

a = len(s)
b = len(t)
c = a-b;
min1 = 0;
min2 = 0;
for i in range(c):
  for j in range(b):
    if s[j+i]==t[j]:
      
      min2 += 1
  if min1<min2:
    min1 = min2
  min2 =0
print(b-min1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# t0=time()

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


maxn = 0
if s==t:
    maxn=3
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:
import difflib
s = input()
t = input()
rewrite = 0
if t in s :
    print(rewrite)
    exit()
elif difflib.SequenceMatcher(None, s, t).ratio() == 0 :
    print(len(t))
    exit()
matching = 0
index = 0
for i in range(len(s)-len(t)):
    mat = difflib.SequenceMatcher(None, s[i:], t).ratio()
    if mat > matching:
        matching = mat
        index = i
count = 0
count_i = index
for i in range(len(t)):
    if s[count_i] != t[i]:
        count += 1
    count_i += 1
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

maiores = []
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
            if j == len(t)-1:
                maiores.append(maior)
        else:
            maiores.append(maior)
            maior = 0

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

Submission status: Wrong Answer

Solution code:
import re
S = input()
T = input()
flag = False
if T in S:
    print(0)
else:
    for i in range(1, len(T) + 1):
        if flag:
            break
        for s in range(len(T) + 1 - i):
            Tc = T
            stra = ""
            for k in range(i):
                stra = stra + "."
            Tc = Tc[0:s] + stra + Tc[s+i:]
            if len(re.findall(Tc, S)) != 0:
                print(i)
                flag = True
                break

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

    if flag:
        break


print(len(t)-ans)

Submission status: Wrong Answer

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

    if T in S:
        print(0)
        return
    if len(T) == len(S):
        count = 0
        for t, s in zip(S, T):
            if t != s:
                count += 1
        print(count)
        return

    maxequal = 0
    for i in range(len(S) - len(T)):
        count = 0
        for j in range(len(T)):
            if S[i + j] == T[j]:
                count += 1
            if (count > maxequal):
                maxequal = count
    print(len(T) - maxequal if maxequal > 0 else 0)


def main():
    probB()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

print(len(T)+1)

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

Submission status: Wrong Answer

Solution code:
import sys


def resolve(in_):
    S = next(in_).strip()
    T = next(in_).strip()

    x = 0
    for i in range(len(T)):
        for j in range(i + 1, len(T) + 1):
            # print(T[i:j], i, j)
            v = S.find(T[i:j], i)
            if v != -1:
                # print('', v, len(S) - v - 1, len(T) - i - 1)
                if len(S) - v - 1 > len(T) - i - 1:
                    x = max(x, j - i)
    
    return len(T) - x
    

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

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)
else:
    for i, s in enumerate(list(T)):
        remaining = len(T) - i
        if s in T and S.find(s) + remaining <= len(S):
            ans = len(T) - 1
    if ans != -1:
        print(ans)
    else:
        print(len(T))

Submission status: Wrong Answer

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

for i in range(tl):
    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()
print(tl)

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
L = len(s)
l = len(t)
p = L-l+1
ans = l
for i in range(l):
    for j in range(i+1,l+1):
        #print(t[i:j])
        for k in range(p):
            #print(s[i+k:j+k])
            if t[i:j]==s[i+k:j+k]:
                #print("Y")
                ans = min(ans,l-len(t[i:j]))
print(ans)

Submission status: Wrong Answer

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

mincount=len(T)

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

print(mincount)

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()
    t_r = t[::-1]

    min = len(t)
    for i in range(min):
        if s.find(t[i:]) >= 0 or s.find(t_r[i:]) >= 0:
            min = i
            break

    print(min)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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=input()
T=input()
import re

def x():
    for i in range(len(T),0,-1): # 文字列の長さ
        for j in range(len(T)-i): # T検索の開始位置=その前にある文字数
            t=T[j:i+j]
            for m in re.finditer(t, S):
                p=m.start()
                if p!=-1:
                    if j<=p and len(T)-j-1 <=len(S)-p-1:
                        return i
    return 0
print(len(T)-x())

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):
    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)):
        e.append(len(t)-(len(t)-a-b))
    else:
      break
if e == []:
  print(len(t))
else:
  print(min(e))

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

    if flag:
        break


print(len(t)-ans)

Submission status: Wrong Answer

Solution code:
import sys

s = input()
t = input()
if s == t:
    print(0)
    sys.exit()
for i in range(len(t)):
    for j in range(i):
        if t[j:j + len(t) - i] in s[j: - len(t) + i]:
            print(i)
            sys.exit()
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]:
                    c += 1
            tmp = len(T) - c
            ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
# import sys
# sys.setrecursionlimit(10**7)
# sys.stdin = open('inpy.txt', 'r')
# sys.stdout = open('outpy.txt', 'w')
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def inin():
    return int(input())
def stin():
    return input()
def spin():
    return map(int,stin().split())
def lin():                           #takes array as input
    return list(map(int,stin().split()))
def matrix(n):
    #matrix input
    return [list(map(int,input().split()))for i in range(n)]

################################################
def string2intlist(s):
    return list(map(int, s))

def calculate_sum(a, N): #sum of a to N
    # Number of multiples 
    m = N / a 
    # sum of first m natural numbers 
    sum = m * (m + 1) / 2
    # sum of multiples 
    ans = a * sum
    return ans
def series(N):
    return (N*(N+1))//2

def count2Dmatrix(i,list):
    return sum(c.count(i) for c in list)

def modinv(n,p):
    return pow(n,p-2,p)

def GCD(x, y): 
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y): 
        x, y = y, x % y 
    return x
def LCM (x, y):
    return (x * y) // GCD(x, y)
    
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l
def isprime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
prime=[]
def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
q=[]       
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j
# d = {}
 
"""*******************************************************"""
s = stin()
t = stin()
c,d = 0,0
for i in range(len(t), 0,-1):
    # print(t[:i])
    if t[:i] in s:
        # print(c)
        break
    else:
        c+=1
    # print(t[:i], t[:i] in s)
for i in range(len(t)):
    # print(t[i:])
    if t[i:] in s:
        # print(d)
        break
    else:
        d+=1
# print("ab" in s)
print(min(c, d))

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
S=[]
c=0
for i in range(len(s)):
    if s[i] in t:
        
        p=len(t)-1
        q=t.index(s[i])
        
        if q>i or i-q+p+1>len(s):
            pass
        else:
            s1=s[i-q:i+p-q+1]
           
            c+=1
            count=0
            for j in range(len(s1)):
                
                if s1[j]!=t[j]:
                    count+=1
                else:
                    pass
            S.append(count)
    else:
        pass
if c==0:
    print(len(t))
else:
    print(min(S))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys


def resolve(in_):
    S = next(in_).strip()
    T = next(in_).strip()

    x = 0
    for i in range(len(T)):
        for j in range(i + 1, len(T) + 1):
            # print(T[i:j], i, j)
            v = S.find(T[i:j], i)
            if v != -1:
                # print('', v, len(S) - v - 1, len(T) - i - 1)
                if len(S) - v - 1 >= len(T) - i - 1:
                    x = max(x, j - i)
    
    return len(T) - x
    

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

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 + i):
        if U[j] == S[j]:
            count -= 1
    ans = min(ans, count)
print(ans)

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:18:23 +0900
#


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


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    for i, e in enumerate(t):
        compare_t = t[0:len (t) - i]
        if compare_t in s:
            print(i+len(t) - len(t))
            break
    print(0)

Submission status: Wrong Answer

Solution code:
import re

S = input()
T = input()
k = 0 

# if re.search(T, S):
#     print(0)
# else:
for i in S:
    k +=1
    if re.search(T[0:len(T)-(k+1)], S):
        break
    

print(k)

Submission status: Wrong Answer

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

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

print(len(T))

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
if S.find(T) != -1:
    min = 0
else:
    min = float('inf')
    r = len(S) - len(T)
    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:
import re
S = input()
T = input()
flag = False
if T in S:
    print(0)
for i in range(1, len(T) + 1):
    if flag:
        break
    for s in range(len(T) + 1 - i):
        Tc = T
        stra = ""
        for k in range(i):
            stra = stra + "."
        Tc = Tc[0:s] + stra + Tc[s+i:]
        if len(re.findall(Tc, S)) != 0:
            print(i)
            flag = True
            break

Submission status: Wrong Answer

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


s = input()
t = input()
print(len(t)-len(longestSubstringFinder(s,t)))

Submission status: Wrong Answer

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

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

ans = 1000000
for i in range(ls - lt):
    tmp = s[i:i+lt]
    score = 0
    for j in range(lt):
        if tmp[j] != t[j]:
            score += 1
    ans = min(ans, score)

print(ans)

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:16:20 +0900
#


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


def main():
    S = input()
    T = input()
    ans = 0
    for i in range(len(S)-len(T)+1):
        stack = 0
        ans_tmp = 0
        for j in range(len(T)):
            if T[j] == 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:
import itertools
s = input()
t = input()

ans = 0

A = itertools.combinations(list(range(len(t)+1)),2)
for i in A:
    part = t[i[0]:i[1]]
    #print(part)
    if part in s:
        ans = max(ans, len(part))
        #print(part)
        
print(len(t) - ans)