Problem:


Score : 200 points

Problem Statement

Given are two strings S and T.

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

At least how many characters do we need to change?

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

Constraints

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

The length of T is at most that of S.

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

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

Sample Input 1

cabacc
abc

Sample Output 1

1

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

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

Sample Input 2

codeforces
atcoder

Sample Output 2

6



Sample input:
cabacc
abc


Sample output:
1

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()


N = len(S)
M = len(T)

ans = 10**10
for i in range(N-M):
    subS = S[i:i+M]
    temp = 0
    for s,t in zip(subS, T):
        if s != t:
            temp += 1
    ans = min(temp,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    t = input()
    n = len(t)
    ans = 0

    for i in range(len(s) - n):
        cnt = 0
        for a, b in zip(s[i:i + n], t):
            if a == b: cnt += 1
        ans = max(ans, cnt)
    print(n - ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
num = -1
for i in range(len(s)):
    a = s[i:]
    cnt = 0
    for j in range(len(t)):
        if i + j >= len(t):
            continue
        if t[j] == s[i + j]:
            cnt += 1
    num = max(num, cnt)

print(len(t) - num)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


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

    ans = 10000

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

        ans = min(ans, sub)

    print(ans)


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
ans=10000
for i in range(len(s)-len(t)):
    temp=s[i:i+len(t)]
    m=0
    for j,k in enumerate(temp):
        if k!=t[j]: m+=1
    ans=min(ans,m)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
import heapq
import random
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv


def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]


class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h + 2) * (w + 2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid

    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x

    def getgrid(self, x, y):
        return self.grid[y][x]

    def get(self, x, y):
        return self.cost[self.pos(x, y)]

    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return

    def show(self):
        for i in range(self.h + 2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return

    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy


def solve():
    s = getS()
    t = getS()

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

    ans = INF
    for i in range(ls - lt):
        tgt = s[i:i+lt]
        # print(tgt)
        tmp = 0
        for c, d in zip(tgt, t):
            if c != d:
                tmp += 1

        ans = min(ans, tmp)
    print(ans)

if __name__ == "__main__":
    # main()
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7


s=S()
t=S()
ans=0
for i in range(len(s)-len(t)):
    ret=0
    for j in range(len(t)):
        if t[j]==s[i+j]:
            ret+=1
    ans=max(ret,ans)

print(len(t)-ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ls = []
for i in range(len(s) - len(t)):
    ls.append(s[i:i+len(t)])
ans = 10000
for word in ls:
    tmp = 0
    for j in range(len(word)):
        if word[j] != t[j]:
            tmp += 1
    ans = min(ans,tmp)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

S = In.str()
T = In.str()

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

Out.int(ans)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 100000

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

for i in range(n - m + 2):
    temp = s[i:i + m]
    count = 0
    for a, b in zip(temp, t):
        if a != b:
            count += 1
    ans = min(count, ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
nt = len(t)
def check(a,b):
    cnt = 0
    for sa,sb in zip(a,b):
        if sa != sb:
            cnt += 1
    return cnt
ans = 1 << 50
for i in range(nt,len(s)):
    s_p = s[i-nt:i]
    # print(s_p,t)
    ans = min(check(s_p,t),ans)
print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(len(S) - len(T)):
    ansi = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            ansi += 1

    ans = max(ans, ansi)

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    T = input()
    LS = len(S)
    LT = len(T)
    ans = 0
    for i in range(LS-LT):
        tmp = 0
        for s, t in zip(S[i:i+LT],T):
            if s==t:
                tmp += 1
        ans = max(ans, tmp)
    print(LT-ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = len(t)

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

    ans = min(c, ans)

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = len(S)
t = len(T)

ans = 10**9

for i in range(s - t):
    tmp = 0
    for j in range(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()
n = len(s)
m = len(t)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import os
from sys import stdin, stdout
    
    
def solve(tc):
    s = stdin.readline().strip()
    t = stdin.readline().strip()

    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
        ans = min(ans, cnt)
    print(ans)



    
tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Submission status: Wrong Answer

Solution code:

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    T=input()
    N=len(S)
    M=len(T)
    ans=10000
    
    for i in range(N-M):
        temp=0
        for j in range(M):
            if S[i+j]!=T[j]:
                temp+=1
                
        ans=min(ans,temp)
        
    print(ans)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T = input()
    l = len(T)
    m = l
    for i in range(len(S)-l):
        r = 0
        for j in range(l):
            if S[i+j] != T[j]:
                r += 1
        if r < m:
            m = r
    return m
print(main())

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
ans=len(t)
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=float('inf')
for i in range(len(s)-len(t)):
    a=s[i:i+len(t)]
    tans=0
    for i in range(len(t)):
        tans+=(t[i]!=a[i])
    ans=min(ans,tans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
n = len(s)
t = list(input())
m = len(t)
res = n
for i in range(n):
    if i+m > n: break
    cnt = 0
    for j in range(m):
        if s[i+j] != t[j]:
            cnt += 1
    res = min(res, cnt)
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()
L = len(T)
ans = INF

for i in range(len(S)):
    cnt = 0
    for x, y in zip(S[i:i+L], T):
        if x == y:
            cnt += 1
    ans = min(ans, L-cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    S=input()
    T=input()
    min_change = INF
    for i in range(len(S)-len(T)):
        tmp = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                tmp += 1
        min_change = min(min_change,tmp)
    print(min_change)




    
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ret = float('inf')
for i in range(len(S) - len(T)) :
  c = 0
  for j in range(len(T)) :
    if S[i + j] != T[j] :
      c += 1
  ret = min(ret, c)
  
print(ret)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
S = list(input())
T = list(input())
ans=10000000

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

print(ans)

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

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

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
N, M = len(S), len(T)
S += "_" * M
ma = 0
for i in range(N):
    c = 0
    for j in range(M):
        if S[i+j] == T[j]:
            c += 1
    ma = max(ma, c)

print(M - ma)

Submission status: Wrong Answer

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

ans = 10**18
for i in range(len(s)-len(t)):
    temp = 0
    for j in range(len(t)):
        if s[i+j]!= t[j]:
            temp += 1
    ans = min(temp,ans)
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)):
        if t[j] != s[i + j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Wrong Answer

Solution code:

S = input()
T = input()

n = len(S)
m = len(T)
res = n + 1
for i in range(n - m):
    cnt = 0
    for j in range(m):
        cnt += int(S[i + j] != T[j])
    res = min(res, cnt)

print(res)

Submission status: Wrong Answer

Solution code:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    mi = 10**18
    for i in range(ls-lt):
        nm = 0
        for j in range(lt):
            if s[i+j] != t[j]:
                nm += 1
        if nm < mi:
            mi = nm

    print(mi)
    return None

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A = S()
B = S()

NA = len(A)
NB = len(B)

ans = INF
for i in range(NA-NB):
  c = 0
  for j in range(NB):
    if A[i+j] != B[j]:
      c += 1
  ans = min(ans,c)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import *
import re

s = input()
t = input()

lst = list(range(len(t)))

def replace(L):
   a = t
   for i in list(L):
      a = a[:i] + '.' + a[i+1:]
   return a

for i in range(len(t) + 1):
   comb = list(combinations(lst, i))
   for l in comb:
      if 're.Match' in str(type(re.search(replace(l), s))):
         print(i)
         exit()

Submission status: Time Limit Exceeded

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

min_dist = 10**10
for i in range(len(S) - len(T) + 1):
    for k in range(len(T)):
        dist = sum(s != t for s, t in zip(S[i:i + len(T)], T))
        min_dist = min(dist, min_dist)
        if min_dist == 0:
            print(0)
            exit()

print(min_dist)

Submission status: Time Limit Exceeded

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=[z for z, x in enumerate(t) if x == s[i]]
        for q in Q:
            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: Time Limit Exceeded

Solution code:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ
import re

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data)

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

s = S()
t = S()

mask = D(list)
for i in range(2 ** len(t)):
    b = bin(i)[2:].zfill(len(t))
    mask[np.sum([1 if c == '1' else 0 for c in b])].append(b)

sk = sorted(mask.keys(), reverse=True)
for k in sk:
    for m in mask[k]:
        mt = ''.join([x if y == '1' else '.' for x, y in zip(t, m)])
        if re.search(mt, s):
            print(len(t) - k)
            exit()

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
length = len(t)
ori_t = t
processed_t = t
while length >= 0:
    if t in s:
        print(len(ori_t)-len(processed_t))
        break
    else:
        processed_t = processed_t[:-1]
        length = len(processed_t)

Submission status: Time Limit Exceeded

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

max_count = 0
for start_t in range(len(T)):
    for start_s in range(start_t, len(S)):
        if len(S) - start_s < len(T) - start_t:
            break
        if T[start_t] == S[start_s]:
            count = 0

            for i in range(len(T) - start_t):
                if T[start_t+i] == S[start_s+i]:
                    count += 1
            
            max_count = max(max_count, count)

answer = len(T) - max_count
print(answer)

Submission status: Time Limit Exceeded

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

min_count = 100000000

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

if min_count == 100000000:
  print(len(T))
else:
  print(min_count)

Submission status: Time Limit Exceeded

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

min_count = 100000000

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

if min_count == 100000000:
  print(len(T))
else:
  print(min_count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import re
import sys
S = input()
T = input()

if T in S:
    print(0)
else:
    mylist = list(range(len(T)))
    for i in range(1, len(T)+1):
        for v in itertools.combinations(mylist, i):
            tmp_T = list(T)
            for j in range(i):
                tmp_T[v[j]] = "."
                tmp_T2 = "".join(tmp_T)
                # print(tmp_T2)
                # tmp_T[v[j]] = "."
            if re.search(tmp_T2, S):
                print(i)
                # break
                sys.exit()
        # break

    
    # # print(mylist)
    # # for i in range(1, len(T)):

    # print('no')