Problem:


Score : 200 points

Problem Statement

Given are two strings S and T.

Let us change some of the characters in S so that T will be a substring of S.

At least how many characters do we need to change?

Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.

Constraints

The lengths of S and T are each at least 1 and at most 1000.

The length of T is at most that of S.

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

Print the minimum number of characters in S that need to be changed.

Sample Input 1

cabacc
abc

Sample Output 1

1

For example, changing the fourth character a in S to c will match the second through fourth characters in S to T.

Since S itself does not have T as its substring, this number of changes - one - is the minimum needed.

Sample Input 2

codeforces
atcoder

Sample Output 2

6



Sample input:
cabacc
abc


Sample output:
1

Submission status: Wrong Answer

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    s = input()
    t = input()
    n = len(s)
    m = len(t)
    ans = inf
    for i in range(n - m):
        # s[i:i+m]
        tmp = m
        for j in range(m):
            if t[j] == s[i + j]:
                tmp -= 1
        ans = min(tmp, ans)
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
n = len(t)
ans = float('inf')
for i in range(len(s)-n):
    tmp = 0
    for j in range(n):
        if t[j]!=s[i+j]:
            tmp += 1
    ans = min(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
#B
s = input()
t = input()
Min = len(t)

for i in range(len(s)-len(t)+1):
    cont = len(t)
    for j in range(len(t)):
        if s[i+j] == t[j]:
            cont -= 1
            
    if cont < Min:
        Min = cont
if len(s) - len(t) == 0:
    Min = 0

print(Min)

Submission status: Wrong Answer

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

c_min=len(t)

for i in range(len(s)+1-len(t)):
    count=len(t)
    for n in range(len(t)):
        if s[i+n] == t[n]:
            count -=1
        elif s[i+n] != t[n]:
            break
    for n in range(len(t)):
        if s[i+len(t)-n-1] ==t[len(t)-n-1]:
            count-=1
        else:
            break
    if count <0:
        count=0
    if count < c_min:
        c_min =count
        
print(c_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    # s, t = input().split()

    s = input()
    t = input()



    first_match = []
    for i, x in enumerate(s):
        if x in t:
            # print(i)
            first_match.append(i)
    
    test2 = []
    for match in first_match:
        try:
            test2.append(s[match:match+len(t)])
        except:
            pass

    if len(test2) == 0:
        print(len(t))

    else:

        test3 = []
        for x in test2:
            count = 0
            for i, el in enumerate(x):
                if el == t[i]:
                    count += 1
            test3.append(count)

        # print(test3)

        test4 = max(test3)

        print(len(t) - test4)

Submission status: Wrong Answer

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

ans = len(T)
f = 0
for i in range(len(T)):
  st = S[f:f+len(T)]
  iti = sum([1 for i,j in zip(st, T) if i == j])
  ans = min(ans, len(T)-iti)
  f += 1
  
print(ans)

Submission status: Wrong Answer

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

print(len(T)-answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
T = input()[::-1]

max_sub = ""
for i in range(len(T)):
  sub = T[:len(T) - i]
  if sub in S:
    max_sub = sub
    break

print(len(T) - len(max_sub))

Submission status: Wrong Answer

Solution code:

S = input()
T = input()

if len(S)>=(len(T)+2):
    countbox=[]
    for n in range(len(S)-2-len(T)+1):
        count =0
        for i in range(len(T)):
            if T[i] != S[i+n+1]:
                count+=1
        countbox.append(count)
    print(min(countbox))
else:
    print(0)

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


def nitti(x, y):
    count = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            count += 1
    return count


S = input()
T = input()


lt = len(T)
res = 0
for i in range(0, len(S)-len(T)+1):
    res = max(res, nitti(S[i:(i+lt)], T))


print(lt-res)

Submission status: Wrong Answer

Solution code:
#B - Substring
S = input()
T = input()
ans = 10**9
for i in range(len(S)-len(T)):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
minr = len(t)
s_t_d = len(s) - len(t)
for i in range(s_t_d):
    cnt = 0
    for ss, ts in zip(s[i:i + len(t)], t):
        if ss != ts:
            cnt += 1
    minr = min(minr, cnt)
print(minr)

Submission status: Wrong Answer

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

s_l = len(s)
t_l = len(t)

max_count = 0
for i in range(0, s_l - t_l + 1):
  count = 0
  for j in range(0, t_l):
    print(i, j)
    if s[i+j] == t[j]:
      count += 1
  if count > max_count:
    max_count = count

diff = t_l - max_count
print(diff)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().decode().rstrip()
t = readline().decode().rstrip()

if t in s:
    print(0)
    exit()
ans = 1

for i in range(1,len(t)):
    if t[:-i] in s:
        break
    elif t[i:] in s:
        break
    else:

        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
s = [ord(x) for x in list(input())]
t = [ord(x) for x in list(input())]
diff = 9999999
sum_t = sum(t)
for i in range(0,len(s)-len(t)):
  subs = s[i:i+len(t)]
  count = 0
  for (x,y) in zip(subs,t):
    if x!= y:
      count=count+1
    if count < diff:
      diff = count
print(diff)

Submission status: Wrong Answer

Solution code:
import bisect
import sys,io
import math
from collections import deque
from heapq import heappush, heappop

input = sys.stdin.buffer.readline

def sRaw():
    return input().decode("utf-8").rstrip("\n").rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    S= sRaw()
    T =sRaw()
    ans = 10*10
    for sidx in range(0,len(S)-len(T)+1):
        score = sum([1 for idx in range(len(T)) if S[sidx+idx]!=T[idx]])
        ans=min(score,ans)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
count=0
min=1000000
for i in range(len(S)):
    count = 0
    if i + len(T) < len(S):
        for j in range(len(T)):
            if T[j] != S[i + j]:
                count += 1
    else:
        break

    if count<min:
        min=count

print(min)

Submission status: Wrong Answer

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

ls = len(S)
lt = len(T)


ans = 1e10

if ls > lt:##Sのほうが長い
    for i in range(ls-lt):
        tmp = S[i:i+lt]
        cnt = 0
        for j in range(lt):
            if tmp[j] != T[j]:
                cnt += 1
        ans = min(ans,cnt)
else:
    for i in range(lt-ls):
        tmp = T[i:i+ls]
        cnt = 0
        for j in range(ls):
            if tmp[j] != S[j]:
                cnt += 1
        ans = min(ans,cnt)

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(len(t)):
    if t[1:(i+1)] in s[i:]:
        ans = i+1

if ans == 0:
    ans = len(t)

print(len(t) - ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

s= inp()
t = inp()

total = -1

for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(i,len(t)+i):
        if s[j] == t[j-i]:
            count += 1
    if count != 0:
      total = max(count,total)

print(len(t)-total)

Submission status: Wrong Answer

Solution code:
input_n = input()
n = str(input_n)

listS = list(n)
#listN = n.split(' ')

input_m = input()
m = str(input_m)

listT = list(m)

min = 1010

for i in range(len(listS) - len(listT)):
    tmp = 0
    for j in range(len(listT)):
        if listS[i + j] != listT[j]:
            tmp += 1
    if tmp < min:
        min = tmp

print(str(min))

Submission status: Wrong Answer

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

m = 0
for tt in range(len(t)):
    ttt = t[tt:]
    # print(ttt)
    if ttt in s[tt:]:
        # print("ok1:", m)
        break
    m += 1

n = 0
for pp in range(len(t)):
    ttt = t[:len(t)-pp]
    # print(ttt, " in ", s[:len(s)])
    if ttt in s[:len(s)-pp]:
        # print("ok2:", n)
        break
    n += 1

print(min(m,n))

Submission status: Wrong Answer

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


def a():
    l = len(T)
    for i in range(l, 0, -1):
        for j in range(0, l-i+1):
            if T[j:j+i] in S[j:]:
                return l-i


print(a())

Submission status: Wrong Answer

Solution code:
def main():
    s = str(input())
    t = list(str(input()))
    num = len(t) - 1
    for i in range(1, len(t)+1):
        moji = "".join(t[0:i])
        if moji in s:
            if num > len(t)-i:
                num = len(t)-i
        
    print(num)
main()

Submission status: Wrong Answer

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

if len(S) == len(T):
    print(0)
else:
    minChangeCounter = 1000000
    for i in range(len(S) - len(T)):
        substr = S[i:i + len(T)]
        changeCounter = 0
        for j in range(len(T)):
            if not substr[j] == T[j]:
                changeCounter += 1
        if changeCounter < minChangeCounter: minChangeCounter = changeCounter
    print(minChangeCounter)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
i = len(T)
sub_str = ''
ans = -1
while i > 0:
    sub_str = T[0:i]
    i = i - 1
    if sub_str in S:
        ans = len(T) - len(sub_str)
        break
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:
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

l,r = t,t
#そのまま
count = 0
if s.count(t) >=1 :
    count = 0
for i in range(1,len(t)+1):
    l = l.lstrip(l[0])
    r = r.rstrip(r[-1])
    if s.count(l) >=1 or s.count(r)>=1:
        count = i
        break
print(count)

Submission status: Wrong Answer

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

max = 0
max_i = 0
ans = len(T)
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 cnt > max:
        max = cnt
        max_i = i
        ans = len(T) - max

print(ans)

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)):
        #print(s[i+j])
        #print(t[j])
        if s[i+j] == t[j]:
            cnt += 1
    #print(cnt)
    ans = min(ans,len(t)-cnt)

print(ans)

Submission status: Wrong Answer

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

max_same = 0
ans = 0

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

Submission status: Wrong Answer

Solution code:
#d,t,s=map(int,input().split())
s=str(input())
t=str(input())
cans=10000
for i in range(len(s)-len(t)):
  ans=0
  for j in range(len(t)):
    if s[i]!=t[j]:
      ans+=1
    i+=1
  cans=min(ans,cans)
print(cans)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

ans = len(T)
for i in range(len(S) - len(T)):
    change = 0
    for j in range(len(T)):
        # print(f'i {i}, j {j}')
        if T[j] != S[i + j]:
            change += 1

    ans = min(ans, change)

print(ans)

Submission status: Wrong Answer

Solution code:
#B - Substring
S = input()
T = input()
ans = 10*9
for i in range(len(S)-len(T)):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
        else:
            pass
    if ans >= count:
        ans = count
    else:
        pass
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,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())
S,T = [S() for _ in range(2)]
num = 0
for i in range(len(S)-len(T)):
    str = S[i:i+len(T)]
    count = 0
    for j in range(len(T)):
        if str[j]==T[j]:
            count += 1
        num = max(num,count)
print(len(T)-num)

Submission status: Wrong Answer

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


def count_diff_chars(s, t):
    """
    文字列s, tの差分がある文字列数を数える
    """
    count = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1
    return count


def count_diff_chars_t(s): return count_diff_chars(s, T)


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


now_min_diff = 1001


for i in range(len_s - len_t):
    s_ = S[i: len_t + i]
    diff_num = count_diff_chars_t(s_)
    now_min_diff = min(diff_num, now_min_diff)

print(now_min_diff)

Submission status: Wrong Answer

Solution code:
S=input().strip()
T=input().strip()
ls = len(S)
lt = len(T)

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

print(x)

Submission status: Wrong Answer

Solution code:
# from math import 

s = input()
t = input()

def distance(s, t):
    assert(len(s) == len(t))
    return len(s) - sum([c1 == c2 for c1, c2 in zip(s, t)])


min_d = len(s)

for i in range(len(s) - len(t)):
    min_d = min(min_d, distance(s[i:i+len(t)], t))

print(min_d)

Submission status: Wrong Answer

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

def count_letter(A,B):
  score=0
  for i in range(len(A)):
    if A[i]==B[i]:
      score+=1
  return score

count_max=0
for i in range(len(S)-len(T)):
  count_max=max(count_max,count_letter(S[i:i+len(T)],T))
print(len(T)-count_max)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
status = 0
if t in s:
  print(0)
else:
  for i in range(1,len(t)):
    t1 = t[i:]
    if t1 in s:
      print(i)
      status += 1
      break
    t2 = t[:(i*-1)]
    if t2 in s:
      print(i)
      status += 1
      break
if status == 0:
  print(len(t))

Submission status: Wrong Answer

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

t_len = len(T)
R = len(S) - t_len
ans = 1000

for i in range(R):
  s_new = S[i : t_len + i]
  count = 0
  for j in range(t_len):
    if s_new[j] != T[j]:
      count += 1
  ans = min(ans, count)

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

l,r = t,t
#そのまま
count = 0

for i in range(1,len(t)+1):
    l = l.lstrip(l[0])
    r = r.rstrip(r[-1])
    if s.count(l) >=1 or s.count(r)>=1:
        count = i
        break
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

maxRes = 0

for i in range(Slen - Tlen):
  res = 0
  for j in range(Tlen):
    if S[i + j] == T[j]:
      res += 1
  maxRes = max(maxRes, res)

ans = Tlen - maxRes

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    S = input()
    T = input()
    for matches in range(len(T), 0, -1):
        for ptr in range(len(T)):
            if ptr+matches > len(T):
                break
            subt = T[ptr:ptr+matches]
            if subt in S[ptr:len(S)-len(T[ptr+matches:])]:
                # print(subt)
                # print(S[:ptr])
                # print(S[ptr:len(S)-len(T[ptr+matches:])])
                # print(S[len(S)-len(T[ptr+matches:]):])
                # # print(ptr)
                # # print(S[:ptr])
                # # print(ptr+matches)
                # # print(S[ptr+matches:])
                
                print(len(T)-matches)
                return
    print(len(T))



    
if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def matcher(s1,s2):
    match=0
    for i in range(len(s1)):
        if(s1[i]==s2[i]):
            match+=1
            
    return match

s = input()
st = input()
mx=0
rangeforloop= len(s)+1 - len(st)
for i in range(rangeforloop):
    if(mx < matcher(s[i:len(st)],st)):
        mx=matcher(s[i:len(st)],st)

ans = len(st)-mx  
print(ans)

Submission status: Wrong Answer

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

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

print(len(T) - res)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
l = len(t)
ans = 0
a = 0
for i in range(len(s) - l + 1):
  ss = list(s[i:i+l])
  for j in range(l):
    if ss[j] ==t[j]:
      ans += 1
    else:
      if a < ans:
        a = ans
        ans = 0
  if a < ans:
    a = ans
  ans = 0
print(l-a)

Submission status: Wrong Answer

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

s_l = len(s)
t_l = len(t)

max_count = 0
for i in range(0, s_l - t_l):
  count = 0
  for j in range(0, t_l):
    if s[i+j] == t[j]:
      count += 1
  if count > max_count:
    max_count = count

diff = t_l - max_count
print(diff)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def find_longest_substr(s1, s2):
    for length in range(len(s2), 0, -1):
        for p0 in range(len(s2) - length + 1):
            substr = s2[p0:(p0 + length)]
            if substr in s1:
                return(substr)
    return ""

s=input()
t=input()
#print(find_longest_substr(s,t))
print(len(t)-len(find_longest_substr(s,t)))

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
kotae=0
while t not in s:
  if t in s:
    print(kotae)
    exit()
  else:
    a=t[:-1]
    b=t[1:]
    kotae+=1
    if a in s[:-1] or b in s[1:]:
      print(kotae)
      exit()
    else:
      t=t[1:-1]
      s=s[1:-1]
      kotae+=1
print(kotae)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(len(S)):
  tmp = 0
  for j in range(len(T)):
    if i + j < len(S):
      if S[i + j] == T[j]:
        tmp += 1
  ans = max(ans, tmp)

print(len(T) - ans)

Submission status: Wrong Answer

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

rev, temp = 0, ''
for ch in T:
  temp += ch
  if temp in S:
    rev = len(temp)

temp = ''
for ch in T[::-1]:
    temp = ch + temp
    if temp in S:
        if len(temp) > rev:
            rev = len(temp)
  
print(len(T)-rev)

Submission status: Wrong Answer

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

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

now = 0

for i in range(slen):
    count=0
    for j in range (tlen):
        if i + j > slen-1:
            continue
        if (s[i+j]) == t[j]:
            count+=1
    if now < count:
        now = count

print(tlen-now)

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
    if count < Min:
        Min = count

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
c = 0
C = [0]
for i in range(len(S)):
  for k in range(len(T)):
    if S[i] == T[k] and i-k >= 1 and i + len(T)-k+1 <= len(S):
      for j in range(len(T)-k):
        if S[i+j] == T[j+k]:
          c += 1
        else:
          C.append(c)
          c = 0
          break
ans = len(T)- max(C)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

s = input()
t = input()

finalans = 0
for i in range(len(s) - len(t) + 1):
    ans = 0
    for j in range(len(t)):
        if (s[i+j] == t[j]):
            pass
        else:
            ans += 1
    finalans = min(finalans, ans)

print(finalans)

Submission status: Wrong Answer

Solution code:
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = 0

s = input()
t = input()
l = len(t)

mx = 0
for idx, _ in enumerate(s[:-l]):
    word = ''
    for i in range(l):
        word += s[idx+i]
    x = 0
    for a, b in zip(word, t):
        if a == b: x += 1
    if x > mx: mx = x

ans = l - mx

print(ans)

Submission status: Wrong Answer

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

lent = len(T)
ans = lent
for i in range(len(S)-lent+1):
    s = S[i:i+lent]
    lev = 0
    lev = sum(map(lambda x: x[0] != x[1], zip(s, T)))
    print(s)
    print(lev)
    if lev == 0:
        ans = 0
      #  break
    elif lev < ans:
        ans = lev
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

s = sys.stdin.readline()
t = sys.stdin.readline()

len_t = len(t)
list_t = list(t)
diff_min = len_t

for start in range(len(s)-len_t):
    list_s_part = list(s[start:start+len_t])
    diff = 0
    for t_item, s_item in zip(list_t, list_s_part):
        if t_item != s_item:
            diff += 1
    if diff < diff_min:
        diff_min = diff

print(diff_min)

Submission status: Wrong Answer

Solution code:
import sys

s = input()
t = input()

finalans = 0
for i in range(len(s) - len(t) + 1):
    ans = 0
    for j in range(len(t)):
        if (s[i+j] == t[j]):
            pass
        else:
            ans += 1
    finalans = min(finalans, ans)

print(ans)

Submission status: Wrong Answer

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