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=len(T)
for i in range(0, 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)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    S = in_s()
    T = in_s()

    ns = len(S)
    nt = len(T)

    ans = 10000
    for i in range(ns - nt + 1):

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

res = 10**18

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

print(res)

Submission status: Accepted

Solution code:
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	S = input()
	T = input()
	ans = INF
	N = len(S)
	M = len(T)
	for i in range(N - M + 1):
		text = S[i:i + M]
		val = 0
		for j in range(M):
			if text[j] != T[j]:
				val += 1

		ans = min(ans, val)

	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
# by the authority of GOD   author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    s,t = input().strip(),input().strip()
    fin = 10**10
    for i in range(len(s)-len(t)+1):
        ans = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                ans += 1
        fin = min(fin,ans)
    print(fin)

#Fast IO Region
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")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

'''
Author: andyli
Time: 2020-08-29 19:58:34
'''

import os
from io import BytesIO, IOBase
import sys


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


# region fastio
BUFSIZE = 1048576


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)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = len(T)

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    T = readline().strip()

    ans = INF
    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 ans > tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

INF = 10**18

S = list(map(ord, readline().strip()))
T = list(map(ord, readline().strip()))
N = len(S)
M = len(T)

ans = INF

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T=input()
a=10000
for i in range(len(S)-len(T)+1):
    c=0
    for j in range(len(T)):
        if T[j]!=S[i+j]:
            c+=1
    if c<a:
        a=c
print(a)

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S, T = [input(), input()]

    ns = len(S)
    nt = len(T)

    m = math.inf

    for i in range(ns-nt+1):
        cnt = 0
        for j in range(nt):
            if S[i:i+nt][j] != T[j]:
                cnt += 1
        m = min(m, cnt)

    print(m)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

if __name__ == "__main__":
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = 10**9
    for i in range(N - M + 1):
        cnt = 0
        for j in range(M):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)

Submission status: Accepted

Solution code:
def main():

    S = input()
    T = input()

    min_cnt = float('inf')
    for i in range(len(S)):
        U = S[i:i+len(T)]
        if len(U) == len(T):
            cnt = 0
            for i in range(len(T)):
                if U[i] != T[i]:
                    cnt += 1
            min_cnt = min(min_cnt, cnt)
    return min_cnt

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

ans = 9999
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    cnt = 0
    for a,b in zip(s,T):
        if a!=b:
            cnt += 1
    ans = min(ans,cnt)
print(ans)

Submission status: Accepted

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

res = float('inf')
for i in range(len(s)-len(t)+1):
    tmp_s = s[i:i+len(t)]

    cnt = 0
    for j in range(len(t)):
        if tmp_s[j] != t[j]:
            cnt += 1
    
    res = min(res, cnt)

print(res)

Submission status: Accepted

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

def count_diff2(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

a = 1e9
for i in range(len(s)-len(t)+1):
    le = s[i:i+len(t)]
    a = min(a, count_diff2(le, t))
print(a)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
T = LS2()
a = len(S)
b = len(T)

ans = 10000
for i in range(a-b+1):
    x = 0
    for j in range(b):
        if S[i+j] != T[j]:
            x += 1
    ans = min(ans,x)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 10 ** 9
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:
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = 10**6
    for i in range(N-M+1):
        cur = 0
        for j in range(M):
            if S[i+j] != T[j]:
                cur += 1
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  T=S()
  ans=inf

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

    ans=min(ans,_ans)

  return ans

# main()
print(main())

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = 1000000
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 < ans:
        ans = cnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    S = input()
    T = input()
    mc = 100000
    for i in range(len(S) - len(T) + 1):
        c = 0
        si = S[i:i + len(T)]
        for k in range(len(T)):
            if si[k] != T[k]:
                c += 1
        mc = min(mc, c)
    print(mc)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = input()
b = input()
la = len(a)
lb = len(b)
can = []
for i in range(la-lb+1):
  tmp = 0
  for j in range(lb):
    if b[j] != a[i+j]:
      tmp += 1
  can.append(tmp)
print(min(can))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, -1, mod)


def main():
    s=input()
    t=input()
    ans = inf
    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)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ss = len(s)
tt = len(t)

ans = 1145141919
for i in range(ss-tt+1):
    a = 0
    for j in range(tt):
        if s[i+j] != t[j]:
            a += 1
    ans = min(a,ans)
    
print(ans)

Submission status: Accepted

Solution code:
def diff(u, v):
    ans = 0
    for i in range(len(u)):
        if u[i] != v[i]:
            ans += 1
    return ans

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

Submission status: Accepted

Solution code:
# URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
s = input()
t = input()

sl = len(s)
tl = len(t)

def f(p, q):
    cnt = 0
    for i, j in zip(p, q):
        if i != j:
            cnt +=1
    return cnt

res = 10 ** 100
for i in range(sl - tl + 1):
    ss = s[i:i + tl]
    res = min(res, f(ss, t))
print(res)

Submission status: Accepted

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

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)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(input())[: -1]
T = list(input())[: -1]
res = len(T)
for i in range(len(S) - len(T) + 1):
  t = 0
  for j in range(len(T)): t += S[i + j] == T[j]
  res = min(res, len(T) - t)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 10**10

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = len(S)
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()
Ns = len(S)
Nt = len(T)

ans = 10 ** 18
for i in range(Ns - Nt + 1):
    cnt = 0
    for j in range(Nt):
        if S[i + j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

s=input()
t=input()
ans=INF
for i in range(len(s)-len(t)+1):
    tmp=0
    for x,y in zip(t,s[i:i+len(t)]):
        tmp+=(x!=y)
    ans=min(ans,tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
lens = len(s)
t = input()
lent = len(t)
ans = 9999999
for j in range(lens-lent+1):
	tmp = 0
	for k in range(lent):
		if s[j+k] != t[k]:
			tmp += 1
	ans = min(tmp, ans)
print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    m = 10000
    for i in range(len(S) - len(T) + 1):
        c = 0
        for s, t in zip(S[i:], T):
            if s != t:
                c += 1
        m = min(c, m)
    return m

print(main())

Submission status: Accepted

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

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
from collections import defaultdict as ddic, Counter, deque
import heapq, bisect, itertools
MOD = 10 ** 9 + 7
S=rr(); T=rr()

ans = len(T)
for i in xrange(len(S) - len(T) + 1):
    ham = sum(S[j+i] != T[j] for j in xrange(len(T)))
    ans = min(ans, ham)

print ans

Submission status: Accepted

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

A=len(S)
B=len(T)

M=10**10
for i in range(A-B+1):
    K=0
    for k in range(B):
        K+=(S[i+k]!=T[k])
    M=min(M,K)
print(M)

Submission status: Accepted

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

print(min(sum(c != d for c,d in zip(S[i:i+len(T)],T)) for i in range(len(S)-len(T)+1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
t = ns()

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T)))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
S=[i for i in input()]
T=[j for j in input()]
ans=[]
for i in range(len(S)-len(T)):
  count=0
  new_S=[t for t in S[i:]]
  for j,k in zip(new_S,T):
    if j==k:
      count+=1
  else:
    ans.append(count)
    
print(len(T)-max(ans))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
S, T = input().split("\n")

cnt = []
for i in range(len(S)-len(T)+1):
	mismatch = 0
	for j in range(len(T)):
		if S[i+j] != T[j]:
			mismatch += 1
	cnt.append(mismatch)
	
print(min(cnt))

Submission status: Runtime Error

Solution code:
S, T = input().split("\n")

cnt = []
for i in range(len(S)-len(T)+1):
	
	mismatch = 0
	for j in range(len(T)):
		if S[i+j] != T[j]:
			mismatch += 1
	cnt.append(mismatch)
	
print(min(cnt))

Submission status: Runtime Error

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

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

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
x=[0]*N
y=[0]*N
L=[0]*N

flag = "No"

if N <3:
  flag = "No"

else:

  for i in range(N):
      x[i],y[i] = map(int, input().split())

  for i in range(N):
    if x[i]==y[i]:
      L[i]=1

  #print(L)

  for i in range (N-2):
    #print(i)
    if L[i] == L[i+1] == L[i+2] == 1:
      flag = "Yes"



print(flag)

Submission status: Runtime Error

Solution code:
S=list(input())                                                                                                                                        
T=list(input())                                                                                                                                        
                                                                                                                                                       
T_size = len(T)                                                                                                                                        
                                                                                                                                                       
def match_num(x):                                                                                                                                      
    return T_size - sum([1 for a,t in zip(x, T) if a==t])                                                                                              
                                                                                                                                                       
b=[]                                                                                                                                                   
for i in range(len(S)-T_size):                                                                                                                         
    b.append(match_num(S[i:i+T_size]))                                                                                                                 
                                                                                                                                                       
print(min(b))

Submission status: Runtime Error

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

if T in S:
    ans = 0
else:
    for i in range(1, len(T)):
#         print(T[i:])
#         print(T[:-i])
#         print('--------------')
        if T[i:] in S or T[:-i] in S:
            ans = i
            break
print(ans)

Submission status: Runtime Error

Solution code:
S = str(input())
T = str(input())
lens = len(S)
lent = len(T)
ans = []

for i in range(s-t + 1):
      count = 0
      U = S[i: i+t]
      for i in range(t):
            if U[j] != T[j]:
                count += 1
      ans.append(count)
print(min(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
t = input()
ans = 1001
if len(s)-len(t)==0:
    temp = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            temp+=1
    ans = min(ans, temp)
else:
    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(ans, temp)
print(ans)

Submission status: Runtime Error

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

cnt = 0

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

Submission status: Runtime Error

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

print(result)

Submission status: Runtime Error

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

print(result)

Submission status: Runtime Error

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

print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    mc=min(c)

print(mc)

Submission status: Runtime Error

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

print(min(c))

Submission status: Runtime Error

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

print(min(c))