Problem:


Score : 200 points

Problem Statement

You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.

A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.

Also, the given images are binary images, and the color of each pixel is either white or black.  

In the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.

The image A is given as N strings A_1,...,A_N.

The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).

Similarly, the template image B is given as M strings B_1,...,B_M.

The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  

Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.  

Constraints

1≦M≦N≦50 

A_i is a string of length N consisting of # and ..

B_i is a string of length M consisting of # and ..

Input

The input is given from Standard Input in the following format:

N M
A_1
A_2
:  
A_N
B_1
B_2
:  
B_M

Output

Print Yes if the template image B is contained in the image A. Print No otherwise.

Sample Input 1

3 2
#.#
.#.
#.#
#.
.#

Sample Output 1

Yes

The template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.

Sample Input 2

4 1
....
....
....
....
#

Sample Output 2

No

The template image B, composed of a black pixel, is not contained in the image A composed of white pixels.



Sample input:
3 2
#.#
.#.
#.#
#.
.#


Sample output:
Yes

Submission status: Wrong Answer

Solution code:

def matching(A, B, N, M) :
  for i in range(N - M) : 
    for j in range(N - M) :
      match = 0
      for m in range(M) :
        if A[m][i : M + i] != B[m] :
          break
        match += 1
    if match == M : 
      return True
  return False
      
          
N, M = tuple(map(int, input().split()))
A = list()
B = list()

for i in range(N) :
  A.append(input())
  
for i in range(M) :
  B.append(input())
  
if matching(A, B, N, M) :
  print('Yes')
else : 
  print('No')

Submission status: Wrong Answer

Solution code:
def matching(A, B, N, M) :
  match = 0
  for i in range(N - M) : 
    for j in range(N - M) :
      for m in range(M) :
        if A[m][i : M + i] != B[m] :
          break
        match += 1
    if match == M : 
      return True
  return False
      
          
N, M = tuple(map(int, input().split()))
A = list()
B = list()

for i in range(N) :
  A.append(input())
  
for i in range(M) :
  B.append(input())
  
if matching(A, B, N, M) :
  print('Yes')
else : 
  print('No')

Submission status: Wrong Answer

Solution code:
N,M=list(map(int,input().split()))
l=[list(input()) for i in range(N)]
mini=[list(input()) for i in range(M)]
mini="".join(sum(mini,[]))
for i in range(N-M+1):
   for j in range(N-M+1):
      let=""
      for k in range(i,M+i):
         let+="".join(l[k][j:j+M])
   if mini == let:
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

cnt = 0
if A < B:
    print('No')
    sys.exit()
else:
    for i in range(N):
        for j in range(M):
            if B[j] in A[i]:
                cnt+=1
                flag = True
            else:
                cnt = 0
                flag = False
            if cnt == M:
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

cnt = 0
if A < B:
    print('No')
    sys.exit()
else:
    for i in range(N):
        for j in range(M):
            if B[j] in A[i]:
                cnt+=1
                flag = True
            else:
                cnt = 0
                flag = False
        if cnt == M:
            break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

cnt = 0
if A < B:
    print('No')
    sys.exit()
else:
    for i in range(N):
        for j in range(M):
            print("A[i]:",A[i])
            print("B[j]:",B[j])
            if B[j] in A[i]:
                cnt+=1
                flag = True
            else:
                cnt = 0
                flag = False
        if cnt == M:
            break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

def comp(i, j):
    for x in range(m):
        for y in range(m):
            if a[i+x][j+y] != b[x][y]:
                return False
    return True

ans = 'No'
for i in range(n-m):
    for j in range(n-m):
        if comp(i, j):
            ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n, m = ns()
    matA = [list(input()) for _ in range(n)]
    matB = [list(input()) for _ in range(m)]

    a = np.array(matA)
    b = np.array(matB)

    for i in range(n - m + 1):
        for j in range(n - m + 1):
            if np.all(a[j:j + m, i:i + m] == b):
                print("Yes")
                # exit(0)

    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n, m = ns()
    matA = [list(input()) for _ in range(n)]
    matB = [list(input()) for _ in range(m)]

    a = np.array(matA)
    b = np.array(matB)

    for i in range(n - m):
        for j in range(n - m):
            if np.all(a[j:j + m, i:i + m] == b):
                print("Yes")
                exit(0)

    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]

c=0
k=0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m]==b[k]:
            c+=1
            k+=1
            break
        else:
            c=0
            k=0
    if c==m:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
lista=[]
for i in range(n):
    lista.append(input())
listb=[]
for i in range(m):
    listb.append(input())
ans=0
num1=n-m+1
for i in range(num1):
    yn=0
    for j in range(num1):
        for k in range(m):
            str1=lista[i+k]
            if listb[k]!=str1[j:j+m]:
                yn=1
                break
        if yn==1:
            break
        else:
            ans=1
            break
    if ans==1:
        break
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [""] * n
b = [""] * m

for i in range(n):
    a[i] = input()

for i in range(m):
    b[i] = input()

for i in range(n):
    for j in range(n):
        if i + m >= n or j + m >= n:
            continue
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    flag = False
        if flag is True:
            print("Yes")
            exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 13:15:13 2020

@author: NEC-PCuser
"""

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(input())

for i in range(M):
    B.append(input())

result = "No" 
for i in range(N - M):
    for j in range(N - M):
        for k in range(M):
            for l in range(M):
                if (A[i + k][j + l] != B[k][l]):
                    break
            else:
                continue
            break
        else:
            result = "Yes"
            break

print(result)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
    for h in range(N-M+1):
        cnt = 0
        for k in range(M):
            for j in range(M):
                if A[i+k][h+j] != B[k][j]:
                    cnt += 1
        if cnt == 0:
            break
if cnt == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
    for h in range(N-M+1):
        cnt = 0
        for k in range(M):
            for j in range(M):
                if A[i+k][i+j] != B[k][j]:
                    cnt += 1
        if cnt == 0:
            break
if cnt == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


for i in range(N-M+1):
    cnt = 0
    for k in range(M):
        for j in range(M):
            if A[i+k][i+j] != B[k][j]:
                cnt += 1
    if cnt == 0:
        break
if cnt == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


for i in range(N-M+1):
    cnt = 0
    for k in range(M):
        for j in range(M):
            if A[i+k][i+j] != B[k][j]:
                cnt += 1
                break
    if cnt == 0:
        break
if cnt == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
  num = list(map(int,input().split()))
  n=num[0]
  m=num[1]
  a = [input() for i in range(n)]
  b = [input() for i in range(m)]

  flg=0
  
  for i in range(0 , n):
    while n-i >= m and a[i].find(b[0])!=-1:
      ##print("while",a[i])
      start=a[i].find(b[0])
      for j in range(1 , m):
        ##print("i=",i)
        ##print("j=",j)
        ##print("a[i+j]=",a[i+j])
        if a[i+j][start:start+m]!=b[j]:
          break
        if j==m-1:
          flg=1
      if flg==1:
        break
      a[i]=a[i][a[i].find(b[0])+1:]
    if flg==1:
        break
        
  if flg==1:
    print("Yes")
  else:
    print("No")

main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
pic = [list(input()) for _ in range(N)]
template = [list(input()) for _ in range(M)]

'''
for _ in pic:
    print("".join(_))

for _ in template:
    print("".join(_))
'''


def ifIncluded(start_position, pic, template):
    for t in range(M):
        for y in range(M):
            if not template[t][y] == pic[start_position[0] + t][start_position[1]+y]:
                return False
    return True


for t in range(N - M):
    for y in range(N - M):
        start_position = [t, y]
        if ifIncluded(start_position, pic, template):
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ans = 0

for i in range(n-m+1):
	for j in range(n-m+1):
		if a[i][j:j+m+1]==b[0]:
			ans = 1
			for k in range(1,m):
				if a[i+k][j:j+m+1] != b[k]:
					ans = 0
			if ans == 1:
				break

if ans==1:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
#B
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for x in range(n-m):
    for y in range(n-m):
        for i in range(m):
            if b[i] != a[y+i][x:x+m]:
                break
        else:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for _ in range(n):
    a = list(input())
for _ in range(m):
    b = list(input())
result = []

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            result.append(a[j+k][i:i+m])
        if b == result:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for x in range(n):
    a = list(input())
for y in range(m):
    b = list(input())
 
for i in range(n-m+1):
  for j in range(n-m+1):
    
    for k in range(m):
      if a[i+k][j:j+m] != b[k]:
        break
    else:
      print('Yes')
      exit()
 
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for i in range(n):
    a = list(input())

for j in range(m):
    b = list(input())

for x in range(n-m+1):
    for y in range(n-m+1):
        for z in range(m):
            if a[x+z][y:y+m] != b[z]:
                break
            else:
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = []
B = []

for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())

for i in range(N- M):
  C = []
  for j in range(M):
    C.append(A[j][i:i+ M])
  if(B == C):
    print("Yes")
    break
else:
  print("No")

Submission status: Wrong Answer

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

N, M = MAP()

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


flg = 1
for i in range(N-M):
	for j in range(N-M):
		for k in range(M):
			if A[i+k][j:j+M] != B[k]:
				break
		else:
			print("Yes")
			exit()
else:
	print("No")

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
big_image_ls = [0] * n
small_image_ls = [0] * m
for i in range(n):
    a = input()
    big_image_ls[i] = a
for i in range(m):
    b = input()
    small_image_ls[i] = b

diff = n-m
include = False
for up_y in range(diff):
    for left_x in range(diff):
        same = True
        for y in range(up_y, up_y+m):
            for x in range(left_x,left_x+m):
                if small_image_ls[y-up_y][x-left_x] != big_image_ls[y][x]:
                    same = False
        if same:
            include = True
if include:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
a_mat = [input() for _ in range(n)]
b_mat = [input() for _ in range(m)]

contain = False
for i in range(n-m):
    for j in range(n-m):
        ok = True
        for k in range(m):
            if not ok:
                break
            for l in range(m):
                if a_mat[i+k][j+l] != b_mat[k][l]:
                    ok = False
                    break
        if ok:
            contain = True
            break
if contain:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# ACB054A
import sys
n, m = map(int, input().split())
N = []
M = []
for i in range(n):
    N.append(input())
for i in range(m):
    M.append(input())

for i in range(n-m+1):
    if M[0] in N[i]:
        for j in range(1, m):
            if M[j] not in N[i+j]:
                continue
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
def check(s,t):
    for i in range(s,s+M):
        for j in range(t,t+M):
            if A[i][j] != B[i-s][j-t]:
                return False
    return True


N,M = map(int,input().split())

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M):
    for j in range(N-M):
        if check(i,j):
            print("Yes")
            exit()

print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# from collections import defaultdict, deque
from math import log10, sqrt, ceil
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    
    n, m = [int(x) for x in input().split()]
    a = []
    for i in range(n):
        a.append(input())
    b = []
    for i in range(m):
        b.append(input())

    ok = 0
    for i in range(n - m):
        for j in range(n - m):
            f = 1
            for x in range(m):
                for y in range(m):
                    if a[i+x][j+y] != b[x][y]:
                        f = 0
            ok |= f


    if ok:
        print("Yes")
    else:
        print("No")
        




t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)
100000007
"""

Submission status: Wrong Answer

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    def compare(s_list, t_list):
        assert(len(s_list) == len(t_list))
        assert(len(s_list[0]) == len(t_list[0]))
        assert(len(s_list) == len(s_list[0]))
        size = len(s_list)
        for i in range(size):
            if s_list[i] != t_list[i]:
                return False
        return True

    def contain(A, B, n, m):
        diff = n - m
        for i in range(diff):
            for j in range(diff):
                new_A = [s[j:n-diff+j] for s in A[i:n-diff+i]]
                if compare(new_A, B):
                    return True
        return False


    n, m = mi()
    A = [input() for _ in range(n)]
    B = [input() for _ in range(m)]
    print('Yes') if contain(A, B, n, m) else print('No')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flag = False  
for i in range(n-m+1):
    flag = True
    for k in range(n-m+1):
        for j in range(i,i+m):
            if a[j][k:k+m]!=b[j-i]:
                flag = False
                break
        if not flag:
            break
    if flag:
        break
#print(i,k,flag)        
print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flag = False  
for i in range(n-m+1):
    flag = True
    for k in range(n-m+1):
        for j in range(i,i+m):
        
            if a[j][k:k+m]!=b[j-i]:
                flag = False
                break
        if flag:
            break
    if flag:
        break
#print(i,k,flag)        
print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
from itertools import product
n, m = list(map(int, input().split()))
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
for i, j in product(range(n - m + 1), range(n - m + 1)):
    if all([A[i + k][j:j + m + 1] == B[k] for k in range(m)]):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

flag = True
for i in range(n):
    for j in range(n):
        if i + m > n and j + m > n:
            a[i : i + m][j : j + m] == b
            print('Yes')
            flag = False
            break
if flag:
	print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

for i in range(n):
    for j in range(n):
        if i + m > n and j + m > n:
            a[i : i + m][j : j + m] == b
            print('Yes')
            break
else:
	print('No')

Submission status: Wrong Answer

Solution code:
#入力
n,m = map(int,input().split())
a_list = [input() for nesya in range(n)]
b = [input() for motsu in range(m)]

#二重ループによりN*NからM*Mの正方形を取り出す(j行目i列目)
for i in range(n-m+1):
  for j in range(n-m+1):
    #j~j+m-1行目のi~i+m-1列目をリスト型にする
    s = [(a_list[k])[i:i+m] for k in range(j,j+m)]
    #テンプレート(問題文)と一致しているか
    if b == s:
      #一致していたら終わる
      break
    #違ったら続ける

#判定
if b == s:
  #含んでいた
  print('Yes')
else:
  #含んでいなかった
  print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = map(int, input().split())
A = np.array([[i for i in input()] for j in range(N)])
B = np.array([[i for i in input()] for j in range(M)])

found = False
for i in range(N-M+1):
    for j in range(N-M+1):
        P = A[i:i+M,j:j+M]
        if (P == B).all():
            print("Yes")
            found = True
            break
if not found:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = map(int, input().split())
A = np.array([[i for i in input()] for j in range(N)])
B = np.array([[i for i in input()] for j in range(M)])

found = False
for i in range(N-M):
    for j in range(N-M):
        P = A[i:i+M,j:j+M]
        if (P == B).all():
            print("Yes")
            found = True
            break
if not found:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
N, M = map(int, readline().split())
A = [readline().rstrip() for _ in range(N)]
B = [readline().rstrip() for _ in range(M)]

for i in range(N-M+1):
    x = A[i].find(B[0])
    if x != -1 and all(A[j].find(B[j-i]) == x for j in range(i+1, i+M)):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
ans = "No"

for i in range(n - m + 1): #列のシフト分
    for j in range(n - m + 1): #行のシフト分
        for k in range(m): #bの列番号
            print(b[k], a[i + k][j:j + m])
            if b[k] != a[i + k][j:j + m]:
                break
            if k == m - 1 and b[k] == a[i + k][j:j + m]:
                ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())

A = np.array([[1 if i == "#" else 0 for i in input()] for _ in range(N)])
B = np.array([[1 if i == "#" else 0 for i in input()] for _ in range(M)])

if N < M:
    print("No")
elif N == M:
    if np.all(A == B):
        print("Yes")
    else:
        print("No")
else:
    for i in range(N - M): # 横移動
        for j in range(N - M): # 縦移動
            if np.all(A[i: M + i, j: M + j]== B):
                print("Yes")
                exit()
print("No")

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

a = list()
for i in range(n):
    line = input()
    a.append(line)

b = list()
for i in range(m):
    line = input()
    b.append(line)

ans = str()
for a_line in range(n - m + 1):
    count = a[a_line].count(b[0])
    if count == 1:
        line, row = a_line, a[a_line].find(b[0])
        for j in range(1, m):
            found_row = a[a_line + j].find(b[j])
            if row != found_row:
                ans = "No"
                break
        else:
            ans = "Yes"
            break
        continue
    elif count > 1:
        line = a_line
        formar_row = -1
        for counter in range(count):
            formar_row = a[a_line].find(b[0], formar_row + 1)
            row = formar_row
            for j in range(1, m):
                found_row = a[a_line + j].find(b[j])
                if row != found_row:
                    ans = "No"
                    break
            else:
                ans = "Yes"
                break
            continue
        else:
            ans = "No"
            continue
        break
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, input().split())

A = [list(sys.stdin.readline().strip()) for _ in range(N)]
B = [list(sys.stdin.readline().strip()) for _ in range(M)]


def check(y, x):
    for i in range(y, y + M):
        if A[i][x:x + M] != B[i - y]:
            return False
    return True


for i in range(N - M):
    for j in range(N - M):
        if A[i][j] == B[0][0]:
            if check(i, j):
                print("Yes")
                exit()

print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
be_included = False

for i in range(N - M + 1):
    for j in range(N - M + 1):
        tmp = [A[k][j:j+M] for k in range(M)]
        if tmp == B:
            be_included = True
            break
    if be_included:
        break

if be_included:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=[[0]*N]*N
B=[[0]*M]*M
for _ in range(N):
    A[_]=list(input())
for _ in range(M):
    B[_]=list(input())
clear=False
flag=False
for i in range(N-M):
    for j in range(N-M):
        cnt=0
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l]==B[k][l]:
                        cnt+=1
                        if cnt==M**2:
                            clear=True
                            flag=True
                            break
                else:
                    flag=True
                    break
            if flag:
                break
        if clear:
            break
        else:
            flag=False
            cnt=0
    if clear:
        break

if clear:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    n, m = map(int, input().split())
    As = [list(input()) for _ in range(n)]
    Bs = [list(input()) for _ in range(m)]

    As_arr = np.array(As)
    Bs_arr = np.array(Bs)
    ans = 0
    for i in range(n-m+1):
        for j in range(n-m+1):
            xs, xe = i, i+m
            ys, ye = j, j+m
            if np.all(As_arr[ys:ye, xs:xe] == Bs_arr):
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N,M=map(int,input().split())

amat=[]
for _ in range(N):
  amat.append([x=="." for x in input()])
bmat=[]
for _ in range(M):
  bmat.append([x=="." for x in input()])
#print(amat)
#print(bmat)

for i in range(N-M):
  for j in range(N-M):
    isTemplate=True
    for k1 in range(M):
      for k2 in range(M):
        if amat[k1+i][k2+j]!=bmat[k1][k2]:
          isTemplate=False
          break
      if not isTemplate:
        break
    else:
      print("Yes")
      sys.exit(0)
else:
  print("No")