Problem:


Score : 200 points

Problem Statement

Given are two strings S and T.

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

At least how many characters do we need to change?

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

Constraints

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

The length of T is at most that of S.

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

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

Sample Input 1

cabacc
abc

Sample Output 1

1

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

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

Sample Input 2

codeforces
atcoder

Sample Output 2

6



Sample input:
cabacc
abc


Sample output:
1

Submission status: Wrong Answer

Solution code:
s = input()
len_s  = len(s)
t = input()
len_t = len(t)
for i in range(len_t - 1, 0, -1):
    for j in range(len_t-i+1):
        p = s.find(t[j:j+i])
        if p > -1:
            if p >= j and len_s - p >= len_t - j:
                print(len_t - i)
                exit()
print(len_t)

Submission status: Wrong Answer

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


ans = len(t)
flag = False
for i in range(len(t)+1, 0, -1):
    for j in range(0, len(t)-i+1):
        sb = t[j:j+i]
        if sb in s[j:]:
            ans = len(t)-len(sb)
            flag = True
            break

    if flag:
        break


print(ans)

Submission status: Wrong Answer

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


ans = len(t)
flag = False
for i in range(len(t)+1, 0, -1):
    for j in range(0, len(t)-i+1):
        sb = t[j:j+i]
        if sb in s[j:]:
            ans = len(t)-len(sb)


print(ans)

Submission status: Wrong Answer

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

if T in S:
  print(0)
  quit()

min_len = len(T)
for i in range(len(S)):
  len_ = 0
  for s, t in zip(S[i:], T):
    if s != t:
      len_ += 1
    else:
      pass
  min_len = min(min_len, len_)
print(min_len)

Submission status: Wrong Answer

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

min_len = len(T)
for i in range(len(S)):
  len_ = 0
  for s, t in zip(S[i:], T):
    if s != t:
      len_ += 1
    else:
      pass
  min_len = min(min_len, len_)
print(min_len)

Submission status: Wrong Answer

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

max_len = 0
for i in range(len(S)):
  len_ = 0
  for s, t in zip(S[i:], T):
    if s == t:
      len_ += 1
    else:
      pass
  max_len = max(max_len, len_)
print(len(T) - max_len)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = input()
ls = len(s)
t = input()
l = len(t)
for i in range(l-1, 0, -1):
    for j in range(l):
        if i + j > l:
            pass
        else:
            a = t[j:i+j]
            p = s.find(a)
            if p > -1:
                f = j
                b = l-j-i
                if p >= j and ls-p-i >= l-j-i:
                    print(l-i)
                    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(len(T)+1):
    for k in range(i+1):
        T1=T[k:k+len(T)-i]
        if T1 in S[k:len(S)-i+k]:
            print(i)
            sys.exit()
        
print(len(T))

Submission status: Wrong Answer

Solution code:
s,t=map(str,open(0))

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
for i in range(1, len(t)+1):
  t_part = t[0:i]
  if t_part not in s:
    if i >0 :
      i -=1
    break
print(len(t)-i)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
for i in range(1, len(t)+1):
  t_part = t[0:i]
  if t_part not in s:
    i -= 1
    break
print(len(t)-i)

Submission status: Wrong Answer

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

len_t = len(t)

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

Submission status: Wrong Answer

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

len_t = len(t)

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

Submission status: Wrong Answer

Solution code:
a=b=0
for i in range(len(s:=input())-len(t:=input())):
  for j,c in enumerate(t):b+=(s[i+j]==c)
  a=max(a,b);b=0
print(len(t)-a)

Submission status: Wrong Answer

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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
s=input().rstrip("\n")
t=input().rstrip("\n")
cnt=[0]*len(s)
for i in range(len(s)-len(t)):
    for j in range(len(t)):
        if t[j]==s[i+j]:
            cnt[i]+=1
print(len(t)-max(cnt))

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	s, t = rll()[0], rll()[0]
	m = len(t)
	ans = INF 

	def do(start):
		x = 0
		for i in range(m):
			if start + i >= len(s):
				return INF
			if t[i] != s[start + i]: 
				x += 1
		return x

	for i in range(m):
		ans = min(ans, do(i))
	print(ans)

	stdout.close()

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	s, t = rll()[0], rll()[0]
	m = len(t)
	ans = INF 

	def do(start):
		end = start + m - 1
		if end >= len(s): return INF 
		x = 0
		for i in range(m):
			if t[i] != s[start + i]: 
				x += 1
		return x

	for i in range(m):
		ans = min(ans, do(i))
	print(ans)

	stdout.close()

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n, m = len(S), len(T)
maximum = 0
for i in range(n - m):
    count = 0
    for j in range(m):
        if S[j + i] == T[j]:
            count += 1
    maximum = max(maximum, count)

ans = m - maximum

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cor = 0
ans = 0

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

print(len(t)-ans)

Submission status: Wrong Answer

Solution code:
s = input()
t_list = list(input())
ans = len(t_list)

for start in range(len(s) - len(t_list)):
    diff = 0
    for i in range(len(t_list)):
        if(t_list[i] != s[start + i]):
            diff += 1
        
    ans = min(ans, diff)

print(ans)

Submission status: Wrong Answer

Solution code:
import re
s = input()
t = input()
t_list = list(t)
ans = len(t)

for start in range(len(s) - len(t)):
    diff = 0
    for i in range(len(t)):
        if(t_list[i] != s[start + i]):
            diff += 1
        
    ans = min(ans, diff)

print(ans)

Submission status: Wrong Answer

Solution code:

S=str(input())
T=str(input())
if T in S:
    print(0)

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
s = [str(i) for i in s]
t = [str(i) for i in t]
ans = len(t)

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

print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
ans = 10000
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)

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
s = [str(i) for i in s]
t = [str(i) for i in t]
ans = len(t)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def resolve():
    S = input()
    T = input()
    Min = 1000
    for i in range(len(S) - len(T)):
        C = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                C += 1
        Min = min(Min, C)
    print(Min)
    
resolve()

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))

ans = len(t)

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

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
i = 0
tmp1 = t
tmp2 = t
while len(t) >= i:
  if tmp1 in s:
    print(i)
    break
  elif tmp2 in s:
    print(i)
    break
  tmp1 = tmp1.lstrip(tmp1[0])
  tmp2 = tmp2.rstrip(tmp2[-1])
  i += 1

Submission status: Wrong Answer

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

i = 0
tmp1 = t
tmp2 = t
while len(t) > i:
  if tmp1 in s:
    print(i)
    break
  elif tmp2 in s:
    print(i)
    break
  tmp1 = tmp1.lstrip(tmp1[0])
  tmp2 = tmp2.rstrip(tmp2[-1])
  i += 1

Submission status: Wrong Answer

Solution code:
import math

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

cnt = 0
length = len(T)

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

print(length)

Submission status: Wrong Answer

Solution code:
import math

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

cnt = 0
length = len(T)

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

print(length)

Submission status: Wrong Answer

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

s_l = len(S)
t_l = len(T)

m =10*10
# SとTの長さの差分を取得しSをずらしながら繰り返しを実施
for i in range(s_l - t_l + 1):
  U = S[i:i + t_l]
  c = 0
  for j in range(t_l):
    if (U[j] != T[j]):
      c += 1
  m = min(c,m)

print(m)

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
ans=10**5
for i in range(len(S)-len(T)):
  a=len(T)
  for j in range(len(T)):
    if S[i+j]==T[j]:
      a-=1
  ans=min(ans,a)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num = 10**10

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

Submission status: Wrong Answer

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

num = 0
tmp = 0
idx = 0
for i in range(len(S)):
    for j in range(len(T)):
        if(S[i] == T[j]):
            tmp += 1
        else:
            if(tmp > 0):
                num = max(num, tmp)
                tmp = 0
                break

print(len(T)-num)

Submission status: Wrong Answer

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

ans = 0
if not t in s:
    for i in range(1, len(t)):
        if t[:-i] in s[:-i] or t[i:] in s[i:]:
            ans = i
            break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = len(t)

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

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
ans = 10**10
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 = list(input())
t = list(input())
ans = 10**10
for i in range(len(s)-len(t)):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            continue
        cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Wrong Answer

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

lS = len(S)
lT = len(T)
q = 0

print(S,lS,T,lT)

for i in range(0,lS-lT+1):
    p = 0
    for j in range(0, lT):
        if S[i+j] == T[j]:
            p += 1
    print("p", p, "q", q)
    q = max(q, p)
ans = lT-q
print(ans)

Submission status: Wrong Answer

Solution code:
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


s = input()
t = input()


ans = math.inf 
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(cnt,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import re

s = input()
t = input()
cnt = -1
for i in range(len(t) + 1):
    cnt += 1
    f = "\S{" + str(i) +"}" + t[(i):len(t)]
    b = t[0:len(t) - i] + "\S{" + str(i) + "}"
    if re.search(f, s):
        break
    elif re.search(b, s):
        break

print(cnt)

Submission status: Wrong Answer

Solution code:
import re

s = input()
t = input()
cnt = -1
for i in range(len(t) + 1):
    cnt += 1
    f = "\S{" + str(i) +"}" + t[(i):len(t)]
    b = t[0:len(t) - i] + "\S{" + str(i) + "}"
    if re.search(f, s):
        print("in")
        break
    elif re.search(b, s):
        print("in")
        break

print(cnt)

Submission status: Wrong Answer

Solution code:
import re

s = input()
t = input()

cnt = 0
for i in range(len(t)):
    cnt = i
    f = "\S{" + str(i) +"}" + t[(i):len(t)]
    b = t[0:len(t) - i] + "\S{" + str(i) + "}"
    if re.search(f, s):
        break
    elif re.search(b, s):
        break

print(cnt)

Submission status: Wrong Answer

Solution code:
import re

s = input()
t = input()

cnt = 0
for i in range(len(t)):
    f = "\S{" + str(i) +"}" + t[(i):len(t)]
    b = t[0:len(t) - i] + "\S{" + str(i) + "}"
    if re.search(f, s):
        break
    elif re.search(b, s):
        break

    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
s = input()
t = input()
ans = len(t)

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

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
a=len(s)
t=input()
b=len(t)
mincnt=b
for i in range(a-b):
	count=0
	for j in range(b):
		s1=s[i+j]
		s2=t[j]
		if(s1!=s2):
			count+=1
	if(mincnt>count):
		mincnt=count	
print(mincnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8
s = input()
t = input()
ans = len(t)

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

Submission status: Wrong Answer

Solution code:
S=input();T=input()
N=len(S);M=len(T);fg=0
for j in range(M):
  for i in range(M):
    if T[j:M-i] in S:
      print(i);fg=1;break
  if fg==1:break

Submission status: Wrong Answer

Solution code:
import difflib

s = input()
t = input()

min = 10000

if t in s:
    print(0)
    exit()

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

print(min)

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    t = input()
    ans = 100000000
    
    for i in range(0,len(s)-len(t)+1):
        cnt = 0
        for sub_s, sub_t in zip(s[i:len(t)+i],t):
            if sub_s != sub_t:
                cnt += 1
        if cnt < ans:
            ans = cnt
    print(cnt)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import difflib

s = input()
t = input()

min = 10000

if t in s:
    print(min)
    exit()

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


    
print(min)

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
cnt=0
ans=len(T)

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

Submission status: Wrong Answer

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

ans = len(T)

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

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
for i in range(len(t),0,-1):
    for j in range(0,len(t)-i+1):
        sum=t[j:j+i]
        if sum in s[j:]:
            k=s.find(sum,j)
            if len(s)-k>=len(t)-j:
                print(len(t)-len(sum))
                exit()
print(len(t))

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):
    count=0
    for j in range(t):
        if S[i+j]!=T[j]:
            count+=1
        if count>=ans:
            break
    ans=min(ans,count)
    if ans==0:
        break
print(ans)

Submission status: Wrong Answer

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

num_s = len(s)
num_t = len(t)
ans = len(t)

# Tの各位置において、Sの文字数のうち何個一致しているのか、全数チェック。
# > O(T*S)＞　10**6オーダー

for i in range(num_s):
    end = i + num_t
    if (end > num_s - 1):
        break
    tar_s = s[i:end]
    # print(tar_s)

    count = 0
    for a, b in zip(tar_s, t):
        if (a != b):
            #print('add', a)
            count += 1

    ans = min(ans, count)


print(ans)

Submission status: Wrong Answer

Solution code:
import io
import sys
_INPUT = """\
cabacc
abc
"""
sys.stdin = io.StringIO(_INPUT)

# ABC177
# B Substring
# 文字列sの中に文字列tを作る時、何回修正が必要か？
# 全探索で文字列sを文字列t文字づつ抜き出して
# 一番、不一致文字数が少ないのが答え
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 10000

# ls-lt+1文字列tのlt文字に、後ろが足りないのは探索しない
for i in range(ls - lt + 1):
    score = 0
    U = s[i:i + lt]  # チェック用文字列Uはs[i]からs[i+lt]までの文字列
    for j in range(lt):  # lt文字数分チェックする
        # U文字列とT文字列を1文字目から全文字不一致かチェック
        if U[j] != t[j]:
            score += 1  # 不一致なら1を足す（最後は不一致な文字数がscoreになる）
    ans = min(ans, score)  # ansとscoreの小さい方を返す

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
for i in range(len(t),0,-1):
    for j in range(0,len(t)-i+1):
        sum=t[j:j+i]
        if sum in s[j:]:
            k=s[j:].find(sum)
            if len(s)-(k+j)>=len(t):
                print(sum,j,k)
                print(len(t)-len(sum))
                exit()
print(len(t))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 10 ** 9
num_s = len(s)
num_t = len(t)

# Tの各位置において、Sの文字数のうち何個一致しているのか、全数チェック。
# > O(T*S)＞　10**6オーダー

for i in range(num_s):
    end = min(num_s - 1, i + num_t)
    tar_s = s[i:end]
    # print(tar_s)

    count = num_t
    for a, b in zip(tar_s, t):
        if (a == b):
            #print('add', a)
            count -= 1

    ans = min(ans, count)


print(ans)

Submission status: Wrong Answer

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

ans = float("inf")
flag = False
for i in range(len(s)-len(t)):
    curr = 0
    for j in range(len(t)):
        # if i + j >= len(s):
        #     flag = True
        #     break
        if t[j] != s[i + j]:
            curr += 1
    # if flag:
    #     break
    ans = min(ans, curr)
print(ans)

Submission status: Wrong Answer

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

s_len = len(s)
t_len = len(t)

ans = s_len
for i in range(s_len - t_len + 1):
    c = 0
    for j in range(t_len):
        if s[i+j] == t[j]:
            c += 1
    ans = max(ans, c)
print(t_len - ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
Ans = [0]
l = len(t)
for i in range(l):
    for j in range(l-i):
        if t[i:i+j] in s[i:len(s)-i]:
            Ans.append(j)
print(l-max(Ans))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
Ans = [0]
l = len(t)
for i in range(l):
    for j in range(i, len(s)-(l-i-1)):
        ans = 0
        if s[j] == t[i] and i != l-1:
            ans += 1
            for k in range(1,l-i):
                if j + k == len(s)-1:
                    break
                else:
                    if s[j+k] == t[i+k]:
                        ans += 1
                    else:
                        Ans.append(ans)
                        break
print(len(t)-max(Ans))

Submission status: Wrong Answer

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

ans = len(t)

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

    ans = min(ans, diff)

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
ans=100000
if len(s)<len(t):
	print(0)
else:
	for i in range(len(s)):
		if s[i]==t[0]:
			k=i+1;
			anss=0
			for j in range(1,len(t)):
				if k<len(s) and t[j]!=s[k] :
					anss+=1
				k+=1
			if anss>0:
				ans=min(ans,anss)

	print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
ans=100000
if len(s)<len(t):
	print(0)
else:
	for i in range(len(s)):
		if s[i]==t[0]:
			k=i+1;
			anss=0
			for j in range(1,len(t)):
				if k<len(s) and t[j]!=s[k] :
					anss+=1
				k+=1
			ans=min(ans,anss)

	print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 10000

# ls-lt+1文字列tのlt文字に、後ろが足りないのは探索しない
for i in range(ls-lt+1): 
    score = 0
    U = s[i:i + lt]  # チェック用文字列Uはs[i]からs[i+lt]までの文字列
    for j in range(lt):  # lt文字数分チェックする
        # U文字列とT文字列を1文字目から全文字不一致かチェック
        if U[j] != t[j]:
            score += 1  # 不一致なら1を足す（最後は不一致な文字数がscoreになる）
        ans = min(ans, score)  # ansとscoreの小さい方を返す

print(ans)

Submission status: Wrong Answer

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



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

Submission status: Wrong Answer

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

s = input()
st = input()
mx=10**9

rangeforloop= len(s)+1 - len(st)

for i in range(rangeforloop):
    if(mx> matcher(s[i:len(st)],st)):
      mx=matcher(s[i:len(st)],st)

ans = mx  
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
l = len(T)
min = l
max = 0
count = len(S) - l - 1
i = 0
while (i < count):
    i += 1
    c = 0
    for j in range(l):
        if S[i + j] == T[j]:
            c += 1
    if max < c:
        max = c
        min = l - max
print(min)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
for i in range(len(t),0,-1):
    for j in range(0,len(t)-i+1):
        sum=t[j:j+i]
        if sum in s[j:]:
            k=s[j:].find(sum)
            if len(s)-k>=len(t):
                print(len(t)-len(sum))
                exit()
print(len(t))

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
mic = len(T)
if T in S:
  print(0)
else:
  for i in range(len(S)-len(T)):
    counter = 0
    for l in range(len(T)):
      if T[l] != S[i+l]:
        counter+=1
    mic = min(mic,counter)
  print(mic)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
S = input()
T = input()
mic = len(T)
if T in S:
  print(0)
else:
  for i in range(len(S)-len(T)):
    counter = 0
    for l in range(len(T)):
      if T[l] != S[i+l]:
        counter+=1
    mic = min(mic,counter)
  print(mic)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
S = input()
T = input()
lT = len(T)
if T in S:
  print(0)
else:
  for i in range(lT):
    for li in range(i+2):
      if T[i+li:lT-i-1+li] in S[i+li]:
        print(i+1)
        break
    else:
      continue
    break

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans = float('inf')
for start in range(len(S) - len(T)):
    ans = min(ans, sum(s != t for s, t in zip(S[start:], T)))
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans=float('inf')
for start in range(len(S) - len(T)):
    ans = min(ans, sum(s != t for s, t in zip(S, T)))
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
S = input()
T = input()
lT = len(T)
if T in S:
  print(0)
else:
  for i in range(lT):
    for li in range(i+2):
      if T[i+li:lT-i-1+li] in S:
        print(i+1)
        break
    else:
      continue
    break

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans=float('inf')
for start in range(len(S) - len(T)):
    ans = min(ans, sum(s != t for s, t in zip(S[start:start + len(T)], T)))
print(ans)

Submission status: Wrong Answer

Solution code:

S = input()
T = input()

def count_diff(Sp):
    cnt = 0
    for i in range(len(Sp)):
        if T[i] != Sp[i]:
            cnt += 1
    return cnt

saved_cnt = 1001

for i in range(len(S) - len(T)):
    Sp = S[i:i+len(T)]
    
    cnt = count_diff(Sp)
    
    saved_cnt = min(saved_cnt, cnt)
    
print(saved_cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

s = np.array([ord(x) for x in input()])
t = np.array([ord(x) for x in input()])

tlen = len(t)
res = tlen
for i in range(len(s)-tlen):
    tmp = s[i:i+tlen] - t
    c = tlen - list(tmp).count(0)
    res = min(res, c)
    if res == 0:
        break
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import Counter

s = np.array([ord(x) for x in input()])
t = np.array([ord(x) for x in input()])

tlen = len(t)
res = 1000
for i in range(len(s)-tlen):
    tmp = s[i:i+tlen] - t
    c = tlen - list(tmp).count(0)
    res = min(res, c)
    if res == 0:
        break
print(res)

Submission status: Wrong Answer

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

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

print(len(t) - cor)

Submission status: Wrong Answer

Solution code:
S=str(input())
T=str(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)