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: Accepted

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

ans = 10 ** 5

sl = len(S)
tl = len(T)

for i in range(sl-tl+1):
    cnt = 0
    for j in range(tl):
        if S[i+j] == T[j]:
            continue
        cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
INF=float('inf')
s=input()
t=input()
ls=len(s)
lt=len(t)
S=[]
T=[]
for i in range(ls):
  S.append(s[i])
for j in range(lt):
  T.append(t[j])
ans=INF
for k in range(ls-lt+1):
  cnt=0
  for j in range(lt):
    if S[k+j]!=T[j]:
      cnt+=1
  ans=min(ans,cnt)
  
print(ans)

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(S, T):
    ans = 10000
    for i in range(len(S) - len(T) + 1):
        tmp = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                tmp += 1
        ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    S = input()
    T = input()
    # N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(S, T)

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    ans = len(S)
    for i in range(len(S)-len(T)+1):
        subS = S[i:i+len(T)]
        diff = 0
        for j in range(len(T)):
            if subS[j] != T[j]:
                diff += 1
        ans = min(diff, ans)
        if ans == 0:
            print(ans)
            return
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

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

S = input()
s_n = len(S)
T = input()
t_n = len(T)

ans = float('inf')
for i in range(s_n - t_n + 1):
    cnt = 0
    for j in range(t_n):
        if S[i + j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop, heapify
import math
import itertools as it
from collections import deque 


def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

s = input()
t = input()
mx = 0
for i in range(len(s)-len(t)+1):
    tp = 0
    for j in range(len(t)):        
        if s[i+j] == t[j]:
            tp += 1
    mx = max(mx, tp)
print(len(t)-mx)

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Submission status: Accepted

Solution code:
s = input()
t = input()
n, m = len(s), len(t)

ans = 0
for i in range(n - m + 1):
    match = 0
    for j in range(m):
        if s[i + j] == t[j]:
            match += 1
    ans = max(ans, match)

print(m - ans)

Submission status: Accepted

Solution code:
S=input()
T=input()
N=len(S)
M=len(T)
ans=set()
for x in range(N-M+1):
  count=M
  for i in range(M):
    if S[x+i]==T[i]:
      count-=1
  ans.add(count)
print(min(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    S = input()
    T = input()

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    d = len(S) - len(T)
    t = len(T)
    ans = len(T)
    for s in range(d+1):
        x = len([1 for i in range(t) if S[s+i] != T[i]])
        ans = min(ans, x)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = float('inf')
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
    result = min(result, c)
print(result)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
lens=len(s)
lent=len(t)
l=[]
for i in range(lens-lent+1):
    count=0
    for j in range(lent):
        if s[i+j]!=t[j]:
            count+=1
    l.append(count)
print(min(l))

Submission status: Accepted

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

cnt = 0
maxCnt = 0

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

print(len(T) - maxCnt)

Submission status: Accepted

Solution code:
s=input()
t=input()
n1=len(s)
n2=len(t)
m=1000
for i in range(n1-n2+1):
    x=s[i:i+n2]
    c=0
    for j in range(n2):
        if x[j]!=t[j]:
            c=c+1
    m=min(m,c)
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    slen = len(s)
    tlen = len(t)

    maxlen = 0
    for i in range(slen):
        curlen = 0
        for j in range(tlen):
            if i+j >= slen:
                curlen = -1
                break
            if s[i+j] == t[j]:
                curlen += 1
        maxlen = max(maxlen, curlen)
    print(tlen-maxlen)


main()

Submission status: Accepted

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: Accepted

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

ans = len(t)
n_1 = len(s) - len(t)
n_2 = len(t)

tmp = 0
for i in range(n_1 + 1):
  tmp = 0
  for j in range(n_2):
    if s[i + j] != t[j]:
      tmp += 1
  ans = min(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

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

def check(S, T):
    res = 0
    for i in range(M):
        if S[i] != T[i]:
            res += 1
    return res

ans = INF
for i in range(N-M+1):
    ans = min(ans, check(S[i:i+M], T))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = float("inf")
for i in range(0,ls-lt+1):
  cnt = 0
  for j in range(lt):
    if T[j] != S[i+j]:
      cnt += 1
  ans = min(ans, cnt)
  
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
T = input()
MIS = len(S)
for TS in range(0,len(S)-len(T)+1):
    LS = S[TS:TS+len(T)]
    Count = 0
    for TT in range(0,len(T)):
        if LS[TT]!=T[TT]:
            Count += 1
    MIS = min(MIS,Count)
print(MIS)

Submission status: Accepted

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

ans = 0
for i in range(N-M+1):
  tmp = 0
  for j in range(M):
    if i + j >= N:
      break
    if S[i+j] == T[j]:
      tmp += 1
  ans = max(ans,tmp)
print(M- ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
len_T = len(T)
m = max(sum([1 for s, t in zip(S[i:i+len_T], T) if s == t]) for i in range((len(S) - len_T) + 1))
print(len_T - m)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    def dist(s,t):
        if len(s)>len(t):
            return len(s)
        return sum(s[i]!=t[i] for i in range(len(s)))
    t=input()
    s=input()
    ans=len(s)
    for i in range(len(t)):
        ans=min(ans,dist(s,t[i:]))
        # print(s,t[i:],dist(s,t[i:]))

    print(ans)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
stdstr =lambda: stdin.readline()
stdint =lambda: int(stdin.readline())
stdpr  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
def minimumChar(S1, S2): 
    n, m = len(S1), len(S2) 
    ans = sys.maxsize 
    for i in range(m - n + 1): 
        minRemovedChar = 0
        for j in range(n): 
            if (S1[j] != S2[i + j]): 
                minRemovedChar += 1
        ans = min(minRemovedChar, ans) 
    return ans 
s=si()
p=si()
sol=minimumChar(p,s)
print(sol)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(len(T) - best)

Submission status: Accepted

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

ret = float('inf')
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
  ret = min(ret, c)
  
print(ret)

Submission status: Accepted

Solution code:
S = input()
T = input()
lt = len(T)
ans_min = len(T)
for i in range(len(S)-lt+1):
    s_tmp = S[i: i + lt]
    ans_tmp = 0
    for j in range(lt):
        if s_tmp[j] != T[j]:
            ans_tmp += 1
    ans_min = min(ans_min, ans_tmp)
print(ans_min)

Submission status: Accepted

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)-L+1):
    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: Accepted

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

max_itti=0

for i in range(len(s)-len(t)+1):
    
    ittisuu=0
    
    for j in range(len(t)):
        
        if t[j] == s[i+j]:
            ittisuu += 1
            
            
    max_itti=max(max_itti,ittisuu)  
print(len(t) - max_itti)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
n = len(s)
k = len(t)
ans = float("Inf")
for i in range(n-k+1):
    p = 0
    for j in range(k):
        if s[i+j] != t[j]:
            p += 1
            
    ans = min(ans, p)
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
t = input()
minimum = len(t)
for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      count += 1
  if count < minimum:
    minimum = count
print(minimum)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8


def run():
    S = input()
    T = input()
    ans = INF
    for i in range(len(S) - len(T) + 1):
        part = S[i:i+len(T)]
        count = 0
        for a,b in zip(T, part):
            if a != b:
                count += 1
        ans = min(ans, count)
    print(ans)


if __name__ == "__main__":
    run()

Submission status: Accepted

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+1):
        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: Accepted

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)+1
for i in range(len(S)-len(T)+1):
    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: Accepted

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

print(ans)

Submission status: Accepted

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

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

res = ls

for i in range(ls-lt+1):
    x = s[i:i+lt]
    temp = 0
    for j in range(lt):
        if x[j] ==t[j]:
            pass
        else:
            temp +=1
    res = min(res,temp)
    
print(res)

Submission status: Accepted

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

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

ans = 9999



for n in range(len_S - len_T +1):
  part_S = S[n:n+len(T)]
  cnt = 0
  for t in range(len(T)):
    if T[t] != part_S[t]:
      cnt += 1
  if cnt < ans:
    ans = cnt
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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()
len_S = len(S)
len_T = len(T)
N = len_S-len_T
INF = 10**31
ans = INF
for i in range(N+1):
    cnt = 0
    for j in range(len_T):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ls=len(s)
lt=len(t)
ma=0
for i in range(ls-lt+1):
    a = 0
    for j in range(lt):
        if s[i+j]==t[j]:
            a+=1
    ma=max(a,ma)
print(lt-ma)

Submission status: Accepted

Solution code:
import sys
import itertools
tokens = itertools.chain.from_iterable(map(str.split, sys.stdin))

s = next(tokens)
t = next(tokens)

mn = 999999
for i in range(len(s) - len(t) + 1):
    ss = s[i:i+len(t)]
    sm = sum(1 if a != b else 0 for a, b in zip(ss, t))
    #print(ss, t, sm)
    mn = min(mn, sm)
print(mn)

Submission status: Accepted

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

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

Submission status: Accepted

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 = m
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(res)

Submission status: Accepted

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

ans = float("inf")
for i in range(len(s)):
    count = 0
    if i + len(t) > len(s):
        break

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

def solve():
      input = sys.stdin.readline
      S = input().strip("\n")
      T = input().strip("\n")
      minChange = 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
            minChange = min(minChange, c)
      print(minChange)

      return 0

if __name__ == "__main__":
      solve()

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
ans = float('inf')

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# import sys
# input = sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    t = S()
    ans = inf
    for i in range(len(s)-len(t) + 1):
        diff_cnt = 0
        for j in range(len(t)):
            if i + j >= len(s):
                continue
            if t[j] == s[i+j]:
                continue
            else:
                diff_cnt += 1
        ans = min(ans, diff_cnt)
    print(ans)


main()

Submission status: Accepted

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) + 1):
        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: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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



def getScore(a, b):
    score = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            score += 1
    return score

D = len(S) - len(T) + 1

minScore = 100000000000
for i in range(D):
    Sa = S[i:i+len(T)]
    score = getScore(Sa, T)
    
    if score <= minScore:
        minScore = score
print(minScore)

Submission status: Accepted

Solution code:
S=input()
T=input()
n=len(S)-len(T)+1
ans=10**5
for i in range(n):
    c=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            c+=1

    ans=min(ans,c)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#b
S=input()
T=input()
lt = len(T)
ls=len(S)

ans=10**20
for i in range(ls-lt+1):
    ss = S[i:i+lt]
    cand = sum(ss[j]!=T[j] for j in range(lt))
    
    #print(ss,T,cand)
    ans=min(ans,cand)
print(ans)

Submission status: Accepted

Solution code:
#a,b,c = list(map(int,input().split()))

s = input().rstrip()
t = input().rstrip()

best = 99999999

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
n = len(s)
m = len(t)
mx = 0
for i in range(n-m+1):
    cnt = 0
    for j in range(m):
        if s[i+j] == t[j]:
            cnt += 1
    if cnt > mx:
        mx = cnt
print(m-mx)