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: Runtime Error

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

s_len =len(s)
t_len =len(t)
count = 0
ans = []



for i in range(s_len - t_len):
    for j in range(t_len):
        if s[i:t_len + i][j] != t[j]:
            count += 1
    ans.append(count)
    count = 0

min_ans = min(ans)
print(min_ans)

Submission status: Runtime Error

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

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



for i in range(s_len - t_len):
    for j in range(t_len):
        if s[i:t_len][j] != t[j]
            count += 1
    print(count)

Submission status: Runtime Error

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

res = []
cnt = 0
for i in range(len(S)-len(T)):
  s = S[i:i+len(T)]
  cnt = 0
  for j,k in zip(s,T):
    if j != k:
      cnt += 1
  res.append(cnt)

print(min(res))

Submission status: Runtime Error

Solution code:
from numba import njit


@njit
def main():
    s = input()
    t = input()
    ans = 1000

    for i in [1, 2, 3]:
        ans += 1
    
    print(ans)
        
    
main()

Submission status: Runtime Error

Solution code:
from numba import njit

def dis(a, b):
  d = 0
  for ai, bi in zip(a, b):
    if ai == bi:
      continue
      d += 1
      return d

@njit
def main():
    s = list(input())
    t = list(input())
    lt = len(t)
    ls = len(s)
    ans = 1000

    for i in prange(ls-lt+1):
        ans = 1
    
    print(ans)
        
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from numba import njit

def dis(a, b):
  d = 0
  for ai, bi in zip(a, b):
    if ai == bi:
      continue
      d += 1
      return d

@njit
def main():
    s = list(input())
    t = list(input())
    lt = len(t)
    ls = len(s)
    ans = 1000

    for i in prange(ls-lt+1):
        ans = min(ans, dis(s[i:i+lt], t))
    
    print(ans)
        
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from numba import njit

@njit(cache = True)
def dis(a, b):
  d = 0
  for ai, bi in zip(a, b):
    if ai == bi:
      continue
      d += 1
      return d

@njit
def main():
    s = list(input())
    t = list(input())
    lt = len(t)
    ls = len(s)
    ans = 1000

    for i in prange(ls-lt+1):
        ans = min(ans, dis(s[i:i+lt], t))
    
    print(ans)
        
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
t = input()
maxi = 0 
for i in range(len(s)):
    maxG = 0
    print(s[i:len(t)+i])
    if len(s[i:len(t)+i]) >= len(t):
        for l, j in zip(s[i:len(t)+i], t):
            if l == j:
                maxG += 1
        maxi = max(maxi, maxG)
     else:
      	break
print(len(t)-maxi)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    count = 0
    for i in range(len(t)):
        if s[start:end][i] != t[i]: count += 1
    if start + len(t) == len(s): return min(count, min_changes)
    else: return min(count, f(s, t, start+1, end+1))

print(f(s, t, start, end))

Submission status: Runtime Error

Solution code:
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    if start + len(t) == len(s):
        count = 0
        for i in range(len(t)):
            if s[start:end][i] != t[i]: count += 1
        return min(count, min_changes)
    return min(f(s, t, start+1, end+1), min_changes)

print(f(s, t, start, end))

Submission status: Runtime Error

Solution code:
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    if start + len(t) == len(s):
        count = 0
        for i in range(len(t)):
            if s[start:end][i] != t[i]: count += 1
        return min(count, min_changes)
    return f(s, t, start+1, end+1)

print(f(s, t, start, end))

Submission status: Runtime Error

Solution code:
s,t=open(0)
print(min(sum(a!=b for a,b in zip(s[i:],t[:-1]))for i in range(len(s)-len(t))))

Submission status: Runtime Error

Solution code:

input = sys.stdin.readline

S = input()
T = input()

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

Submission status: Runtime Error

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

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 パターンあります

for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, cur)

print(ans)

Submission status: Runtime Error

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

t_l = len(t)
diff_min = 999999999

def diff_str(s1, s2):
    diff_c = 0
    for j in range(len(seq)):
        if s1[j] != s2[j]:
            diff_c += 1
    return diff_c

if len(s) == len(t):
    diff_min = diff_str(s, t)

for i in range(len(s)-t_l):
    seq=s[i:i+t_l]
    diff_c = diff_str(seq, t)
    if diff_c < diff_min:
        diff_min = diff_c


print(diff_min)

Submission status: Runtime Error

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

# ans = []
# for i in range(len(t)):
#     # print(t[i:])
#     # print(s[i:])
#     if t[i:] in s[i:]:
#         break
#     for j in range(1,len(t[i:])):
#         # print(t[i:][:-j])
#         # print(s[i:][:-j])
#         if t[i:][:-j] in s[i:][:-j]:
#             ans.append(i+j)
#             break
# if t in s:
#     print(0)
# elif len(ans) == 0:
#     print(len(t))
# else:
#     print(min(ans))
ans = len(t)
for i in range(len(s)-len(t)):
    dif = 0
    for j in range(len(t)):
        if t[j] != s[i:i+len(t)][j]:
            diff += 1
    ans = min(dif,ans)

print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


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


def main():
    # sys.setrecursionlimit(1000000)
    sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
S = input()
T = input()
A = len(T)  
for i in range(len(S)):
    diff = 0
    for j in range(len(T)):
        if T[j] != S[i + j]:
            diff = diff +1;
    A = min(A,diff)
print(A)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
minCount = 100000000
i = 0
while i < len(s) and i + j < len(s):
    countSame = 0
    j = 0
    while j < len(t):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)

Submission status: Runtime Error

Solution code:
def minimumChar(S,T): 
    n, m = len(S), len(T) 
    ans = sys.maxsize 
    for i in range(m - n + 1): 
        minRemovedChar = 0
        for j in range(n): 
            if (S[j] != T[i + j]): 
                minRemovedChar += 1
        ans = min(minRemovedChar, ans) 
    return ans 
      
S=input()
T=input()

print(minimumChar(S, T))

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
if H == 1:
  print(1)
if W == 1:
  print(1)
if H * W == 1:
  print('1')
a = H * W
b = a // 2
if b != a / 2:
  b += 1
if H != 1 and W != 1:  
  print(b)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
if H == 1 :
  print('1')
if W == 1:
  print('1')
if H * W == 1:
  print('1')
a = H * W
b = a // 2
if b != a / 2:
  b += 1
if H != 1 and W != 1:  
  print(b)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
if H == 1 or W == 1:
  print('1')
a = H * W
b = a // 2
if b != a / 2:
  b += 1
if H != 1 and W != 1:  
  print(b)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
n, m = len(s), len(t)
print(min(sum(si != ti for si, ti in zip(s[i: i+m], t)) for i in range(n-m)))

Submission status: Runtime Error

Solution code:
s = input()
t = list(input())
t_test = "".join(t)

import re

def wild(x):
    for i in range(len(t_test)):
        t2 = []
        for item in t:
            item_mod = item.replace(t[i],".")
            t2.append(item_mod)
        t_test2 = "".join(t2)
        find = re.findall(t_test2, s)
        if find == []:
            continue
        else:
            break
    if find != []:
        return True
    return False

ans = 0
check = False
if t_test in s:
    pass
else:
    while check == False:
        check = wild()
        ans += 1

print(ans)

Submission status: Runtime Error

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

ans = len(s)

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: Runtime Error

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

ans = len(s)

for s_start 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: Runtime Error

Solution code:
s = input()
t = input()
l1 = len(s)
l2 = len(t)
i = 0
li = []
while i<l1:
    if s[i] == t[0]:
        h = 0
        k = i
        ct = 0
        while h < l2:
            if s[k] != t[h]:
                ct += 1
            k+=1
            h+=1
        li.append(ct)
        if h == 0:
            i = k
        else:
            i = k - 1
    i += 1
if li == []:
    ans = 0
    for i in range(l2):
        if s[i] != t[i]:
            ans += 1
    print(ans)
else:
    print(min(li))

Submission status: Runtime Error

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

ans = len(s)

for s_start 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: Runtime Error

Solution code:
S = input()
T = input()
ans = float("INF")
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(cnt)

Submission status: Runtime Error

Solution code:
S = input()
T = input()
ans = float("INF")
for i in range(len(S)):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(cnt)

Submission status: Runtime Error

Solution code:
S,T=open(0).read().split()
def main():
    for i in range(1,len(T)+1):
        for j in range(i+1):
            print(T[j:(len(T)-i+j)], S[j:(len(S)-i+j)])
            if T[j:(len(T)-i+j)] in S[j:(len(S)-i+j)]:
                return i
                break
if T in S:
    print(0)
else:
    print(main())

Submission status: Runtime Error

Solution code:

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

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

resolve()

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
array = [0. for i in range(len(S))]
count = 0
p = []
for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j] and i >= j:
            count += 1
            p.append(j)
            array[i] += count
            break
        else:
            count = 0
arr = [0. for i in range(len(p))]
c = 0
for k in range(len(p)-1):
    if p[k]+1 == p[k+1]:
        c += 1
        arr[k+1] += 1
    else:
        c = 0
print(int(len(T)-max(arr)-1))

Submission status: Runtime Error

Solution code:
N = int(input())
array = list(map(int,input().split()))
ans = 0
kuso = sum(array)
for i in range(N-1):
  kuso -= array[i]
  ans += array[i]*kuso  
print( ans%(10**9+7) )

Submission status: Runtime Error

Solution code:
N = int(input())
array = list(map(int,input().split()))
ans = 0
a = sum(array)
for i in range(N-1):
  a -= array[i]
  ans += array[i]*a  
print( ans%(10**9+7) )

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
p = []
for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j] and i >= j:
            p.append(j)
            break
arr = [0. for i in range(len(p))]
c = 0
for k in range(len(p)-1):
    if p[k]+1 == p[k+1]:
        c += 1
        arr[k+1] += 1
    else:
        c = 0
print(int(len(T)-max(arr)-1))

Submission status: Runtime Error

Solution code:
n=int(input())
array=list(map(int,input().split()))
ans=0
s=sum(array)
  for j in range(n-1):
    s -= array[i]
    ans += array[j]*s
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
n=int(input())
array=list(map(int,input().split()))
ans=0;
s=sum(array)
  for j in range(n-1):
    s -= array[i]
    ans += array[j]*s
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
n=int(input())
array=list(map(int,input().split()))
ans=0;
s=sum(array)
  for j in range(n):
    s -= array[i]
    ans += array[j]*s
print(ans%(10**9+7))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
array=list(map(int,input().split()))
ans=0;
for i in range(n-1):
  j=i+1
  for j in range(n):
    ans=array[j]*array[i]
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
S=input()
T=input()
s=len(S)
t=len(T)
max_count=0

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

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if t != s:
            print(1)
            sys.exit()

    lens = len(s)
    lent = len(t)

    res = []
    for i1 in range(lent):
        for i2 in range(i1+1, lent+1):
            end = lens - (lent - i2)
            if t[i1:i2] in s[i1:end]:
                res.append(lent - len(t[i1:i2]))
            print(i1, i2, t[i1:i2],s[i1:end], res)
    if res:
        r = min(res)
        print(r)
    else:
        print(lent)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
array=list(map(int,input().split()))
ans=0;
for i in range(n-1):
  j=i+1
  for j in range(n):
    ans=a[j]*a[i]
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:

def main():
    S = input()
    T = input()
    # Sのi文字目をTの先頭として，それらの文字列の一致度を見る．

    st = {}
    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
        st.add(cnt)
    print(len(T) - max(st))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline.strip()
S = input()
T = input()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=int(0)
count=0
for i in range(N):
    for j in range(i+1,N):
        count += A[i]*A[j]
t=count%(10**9+7)
print(t)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
max_length = 0
# for i in range(len(t)):
#     for j in range(i, len(s)):
#         if t[i] == s[j]:
#             length = 0
#             for k in range(min(len(t)-i, len(s)-j)):
#                 if t[i+k] == s[j+k]:
#                     length += 1
#             for l in range(1, i+1):
#                 if t[i-l] == s[j-l]:
#                     length += 1
#             if length > max_length:
#                 max_length = length
# print(len(t)-max_length)
# for i in range(len(t)):
#     for j in range(i+1, len(t)):
#         t_part = t[i:j]
#         if (t_part in s[i:] and j-i > max_length):
#             max_length = j-i

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

Submission status: Runtime Error

Solution code:
s = input()
t = input()
max_length = 0
# for i in range(len(t)):
#     for j in range(i, len(s)):
#         if t[i] == s[j]:
#             length = 0
#             for k in range(min(len(t)-i, len(s)-j)):
#                 if t[i+k] == s[j+k]:
#                     length += 1
#             for l in range(1, i+1):
#                 if t[i-l] == s[j-l]:
#                     length += 1
#             if length > max_length:
#                 max_length = length
# print(len(t)-max_length)
# for i in range(len(t)):
#     for j in range(i+1, len(t)):
#         t_part = t[i:j]
#         if (t_part in s[i:] and j-i > max_length):
#             max_length = j-i

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

Submission status: Runtime Error

Solution code:
import sys


def resolve(in_):
    S = next(in_).strip()
    T = next(in_).strip()

    x = 0
    for i in range(len(S)):
        if len(S) - i < len(T):
            break
        v = 0
        for x, y in zip(S[i:], T)
            if x == y:
                v += 1
            x = max(x, len(T) - v)
    
    return x
    

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import re
s = input()
t = input()
if t in s:
    print(0)
else:
    s_length = len(s)
    t_length = len(t)
    s_substart = 0
    all_s=[]
    for i in s:
        all_s.append(s[s_substart:s_substart + t_length])
        s_substart += 1
        if s_substart + t_length > s_length:
            break
    stoissyo = len(re.finditer(t,all_s))
    print(t_length - max(stoissyo))

Submission status: Runtime Error

Solution code:
s = input()
t = input()
ls = []
for i in range(len(t)):
    for j in (range(1,len(t)+1)): 
        t_a = t[-(i+j):]
        if s.find(t_a) == -1:
          continue
        else:
          ls.append(len(t) - len(t_a))
print(min(ls))

Submission status: Runtime Error

Solution code:
from sys import stdin

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

def strpair(str,n):
    arr = []
    for i in range(0,len(str)-n+1):
        arr.append(str[i:i+n])
    return arr




def count(s,t):
    # if s.count(t) >= 1:
    #     return 0
    arr = []
    count = 0
    for i in range(1,len(t)+1):
        arr = strpair(t,len(t)-i)
        print(arr)
        for a in arr:
            if s.count(a) >=1 :
                return i
print(count(s,t))

Submission status: Runtime Error

Solution code:
s = input()
t = input()
count=10000000000
COUNT=0
for j in range(len(s)-len(t)+2):
    for i in range(len(t)):
        if not t[i]==s[j]:
            COUNT+=1
    count=min(count,COUNT)
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if s in t:
            print(0)
            sys.exit()
        else:
            print(1)
            sys.exit()

    lent = len(t)
    lens = len(s)
    res = []
    for i1 in range(lent):
        tmp1 = t[i1:]
        for i2 in range(lent, i1, -1):
            end = lens - (lent - i2)
            if t[i1:i2] in s[i1:end]:
                res.append(i1 + (lent - i2))

    r = min(res)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

S_max=max(S)
print(t-S_max)

Submission status: Runtime Error

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

cnt1 = 0
if len(s) == len(t):
    for i in range(len(t)):
        if s[i] != t[i]:
            cnt1 += 1
print(cnt1)
else:
    cnt = []
    for i in range(len(t)):
        for k in range(i + 1, len(t) + 1):
            if t[i:k] in s[i:]:
                cnt.append(k - i)
                print(t[i:k], s[i:], k-i)
            else:
                cnt.append(0)
                #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

Submission status: Runtime Error

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

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

cnt = len_t
c = 0

if len_s == len_t:
    c = 0
    for i in range(len_s):
        if S[i] != T[i]:
            c += 1
        cnt = min(c, cnt)

for i in range(len_s - len_t):
    c = 0
    for j in range(i, i +len_t):
        if S[i] != T[i-len_t]:
            c += 1
        cnt = min(c, cnt)

print(cnt)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
counts = list()
for i in range(len(t)):
    count = len(t)
    kari_count = len(t)
    j = i
    for j in range(len(s)):
    #    if((len(s) - j) == (len(t) - i )):
    #        break
        if(j < i):
            continue
        elif(t[i] == s[j]):
            kari_count = i 
            for k in range(len(t) - i):
                if(t[i + k] == s[j + k]):
                    continue
                else:
                    kari_count += 1
        elif(kari_count < count):
            count = kari_count
        else:
            continue
    counts.append(count)
print(min(counts))

Submission status: Runtime Error

Solution code:
S, T = input().split()
 
n = len(S) - len(T) + 1
moji = len(T)
 
for a in range(n):
  count = 0 
  for b in range(len(T)):
    if S[a+b] != T[b]:
      count += 1
  if count < moji:
    moji = count
    
print(moji)

Submission status: Runtime Error

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

if(t in s):
    print(0)

result = []
for i in range(len(s) - len(t)):
    result.append(len(t))
    for j in range(len(t)):
        if(s[i+j] == t[j]):
            result[i] -= 1

print(min(result))

Submission status: Runtime Error

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

if t in s:
    print(0)
else:
    def recursive_find(target, find):
        if len(find) == 1:
            return ''
        sliced = find[:-1]
        if sliced in target:
            return sliced
        else:
            recursive_find(target, sliced)

    result = recursive_find(s, t)
    if result is None:
        result = ''

    # 後ろ1文字だけにマッチするパターン
    chr_final = t[-1:]
    if chr_final in s:
        if s.find(chr_final) == len(t) - 1:
            flg = True

    if flg:
        print(len(t) - 1)
    else:
        count = len(t) - len(result)
        if count == 0:
            count = len(t)
        print(count)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
for i in range(len(t)):
    for j in reversed(range(1,len(t)+1)): 
        t_a = t[i:i+j]
        print(t_a)
        if s.find(t_a) == -1:
          continue
        else:
          print(len(t) - len(t_a))
          break
    else:
        continue
    break

Submission status: Runtime Error

Solution code:
s = input()
t = input()
n = 0
a = 0
b = 1
for i in s:
    if i == t[a]:
        a += 1
        b = a
    else:
        a = 0
print(len(t) - b)

Submission status: Runtime Error

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

cnt=0
ans=0

b=[0]*len(S)
a=[0]*len(S)
for i in range(len(S)):
    cnt = 0
    for j in range(len(T)):
        cnt = 0
        #print(S[i],T[j])
        if S[i]==T[j]:
            cnt+=1
            if j != len(T):
                for k in range(j+1,len(T)-j-2):
                    if S[i+k]==T[j+k]:
                        cnt+=1
                    else:
                        b[i]=cnt
                        break
            b[i]=cnt
            a[i]=j

for i in range(len(a)):
    if a[i]==a.index(a[i]):
        c = a.index(a[i])
        ans = b[c]
        break
        
print(len(T)-ans)

Submission status: Runtime Error

Solution code:
s = input()
t = input()
ans = 0
mans = 0
fans = []
k = 0
prev = 0
for i in range(len(t)):
    for j in range(k,len(s)):
        if(t[i] == s[j]):
            m = i+1
            l = j+1
            while(m < len(t)):
                if(t[m] != s[l] and (len(s)-l >= len(t)-m)):
                    mans = len(t)-m
                    fans.append(ans+mans)
                    break
                m += 1
                l += 1
    ans += 1
    k += 1
if(len(fans) == 0):
    print(len(t))
else:
    #print(fans)
    #print(ans)
    print(min(fans))

Submission status: Runtime Error

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

result = []
for i in range(len(s) - len(t)):
    result.append(len(t))
    for j in range(len(t)):
        if(s[i+j] == t[j]):
            result[i] -= 1

print(min(result))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

for i in range(len(T)):
  if i == 0:
    if T[:len(T)-i] in S:
      print(0)
  else:
    if T[:len(T)-i] in S and S[len(T)-i+1] != T[:len(T)-i]:
      print(i)

Submission status: Runtime Error

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

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

cnt = len_t
c = 0

if len_s == len_t:
    for j in range(len_t):
        if S[j] != T[j]:
            c += 1
            cnt = min(c, cnt)
else:
    for i in range(len_s - len_t):
        c = 0
        for j in range(i, i+len_t):
            if S[j] != T[j]:
                c += 1
                cnt = min(c, cnt)
    
print(cnt)

Submission status: Runtime Error

Solution code:
S, T = input().split()
 
n = len(S) - len(T) + 1
moji = len(T)
 
for a in range(n):
  count = 0 
	for b in range(len(T)):
      if S[a+b] != T[b]:
        count += 1
  if count < moji:
    moji = count
    
print(moji)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int, input().split()))
p,S = 0,0
for i in range(N-1):
    ap = A.pop(0)
    AA = sum(A)
    aa = ap*AA
    a = aa%1000000007
    S += a
p = S%1000000007
print(p)

Submission status: Runtime Error

Solution code:
import random, string
def randomname(n):
   randlst = [random.choice(string.ascii_letters + string.digits) for i in range(n)]
   return ''.join(randlst)
S = input()
T = input()
l = len(T)
L = len(S)
before = randomname(l)
after = randomname(l)
for i in range(l):
   before[i] = '.'
   after[i] = '.'
S = before + S + after
max_ans = -1
for i in range(L+l+1):
   for j in range(l):
      ans = 0
      if T[j] == S[i + j]:
         ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

Submission status: Runtime Error

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

Tlist=list(T)
Slist=list(S)

TL=len(Tlist)
SL=len(Slist)

c=0
ans=SL
i=0
j=0

if S in T :
    ans=0
else:
    for i in range(TL-SL+1):
        for j in range(SL+1):
            if Tlist[j+i]!=Slist[j]:
                c=c+1
        if ans>c:
            ans=c
        c=0
            
        
print(ans)

Submission status: Runtime Error

Solution code:
n = input()
m = input()
lst = []
if m in n:
    print(0)
else:
    for i in range(len(n) - len(m)):
        count = 0
        for j in range(i, len(m) + i):
            if n[j] != m[j-i]:
                count += 1
        lst.append(count)
    print(min(lst))

Submission status: Runtime Error

Solution code:
import numpy as np
S = input()
T = input()

if len(S)==0:
    print(0)
else:
    tmp = np.zeros(len(T))

    i=0
    flg=True

    while flg:
        for j in range(i, len(T)):
            if T[i:j+1] in S:
                tmp[i] = j+1-i
        i = max(i + int(tmp[i]),i+1)
        if i >= len(T)-1:
            flg=False

    tmp = np.array(tmp, dtype=int)
    i = np.argmax(tmp)
    j = tmp[i]
    s = S.find(T[i:i+j])
    if s - i >= 0 and s - i + len(T) <= len(S):
        print(len(T)-int(np.max(tmp)))
    else:
        l=0
        for k in range(len(T)):
            if S[s+k] == T[k]:
                l+=1
        print(len(T)-l)