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

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

#0,0からm,mまでの全てについて、合致するかどうかを全てのパターンでみる
#2*2だとして、3*3なら4個、4*4なら9個
#→差+1個あると考えて良さそう
ok = 1
for i in range(m):
  for j in range(m):
    for k in range(n - m):
      for l in range(n - m):
        if a[i+k][j+l] != b[i][j]:
          ok = 0

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

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
A = []
B = []
for i in range(n):
    A.append([input()])
for i in range(m):
    B.append([input()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 2):
    for i in range(n - m + 2):
        if A[j][i: i + m] == B[0][:]:
            for k in range(m):
                if A[j + k][i: i + m] == B[k][:]:
                    flag = 1
                    continue
                flag = 0
                break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
A = []
B = []
for i in range(n):
    A.append([input()])
for i in range(m):
    B.append([input()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        if A[j][i:] == B[j][:]:
            for k in range(m - 1):
                if A[j + k][i:] == B[j + k][:]:
                    flag = 1
                    continue
                flag = 0
                break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

Submission status: Runtime Error

Solution code:
import sys
n, m = map(int, input().split())
image = []
temp = []
match = False
for i in range(n):
  image.append(input())
for i in range(m):
  temp.append(input())
for i in range(n):
  for j in range(n - m + 1):
    if (temp[0] == image[i][j : j + m]):
      match = True
      for k in range(1, m):
        if ((temp[k] != image[i + k][j : j + m]) | (i + k >= n)):
          match = False
          break
      if (match == True):
        print('Yes')
        sys.exit()
print('No')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
f = False
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0]:
            for k in range(m):
                for l in range(1, m):
                    if a[i+k][j+l] != b[k][l]:
                        f = True
                        break
                if f:
                    break
            if not f:
                print('Yes')
                exit()

print('No')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
f = False
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0]:
            for k in range(m):
                for l in range(1, m):
                    if a[i+k][j+l] != b[k][l]:
                        f = True
                        break
                if f:
                    break
                print('Yes')
                exit()

print('No')

Submission status: Runtime Error

Solution code:
w,h,n=map(int,input().split())
x1=0
y1=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        x1=max(x1,x)
    elif a==2:
        w=min(w,x)
    elif a==3:
        y1=max(y,y1)
    elif a==4:
        h=min(h,y)
print((w-x1)*(h-y1) if w > x1 and h > y1 else 0)

Submission status: Runtime Error

Solution code:
w,h,n=map(int,input().split())
x1=0
y1=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        x1=max(x1,x)
    elif a==2:
        w=min(w,x)
    elif a==3:
        y1=min(y,y1)
    elif a==4:
        h=max(h,y)
print(max((w-x1)*(h-y1),0))

Submission status: Runtime Error

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


for i in range(n-m+1):
    for j in range(n-m)+1:
        flag = 0
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    flag = 1
        if flag == 0:
            print('Yes')
            exit()


print('No')

Submission status: Runtime Error

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

a=[input() for i  in range(N)
b=[input() for i in range(M)]
N=0

if b[i] in a[i]:
    N+=1
    
if(N==M):
    print("Yes")
else:
    print("No")
#コピペです。

Submission status: Runtime Error

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

i = 0
k = 0
ans = 'No'
for k in range(n-m):
    while i + m <= n:
        if a[k][i:i+m:] == b[k]:
            for j in range(m):
                if all()
            ans = 'Yes'
            
        i += 1
print('No')

Submission status: Runtime Error

Solution code:
n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n)]
B = [[int(i) for i in input().split()] for j in range(m)]

a = 0

for i in range(n-m+1):
    for j in range(n-m+1):
        if A[0][0] == B[i][j]:
            for k in range(m):
                for l in range(m):
                    if A[k][l] != B[i+k][j+l]:
                        break
            else:
                a += 1
                continue
            break
if a != 0:
    print(Yes)
else:
    print(No)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
A=[input() for i in range(n)]
B=[input() for i in range(m)]

for i in range(n):
  for j in range(n):
    k=j+m
    if k <= n:
      if A[i][j:k]== B[0]:
        o=1
        for l in range(i+1,i+m):
          if A[l][j:k]!=B[o]:
            break
          else:
            o+=1
        if o==m:
          print('Yes')
          exit()
print('No')

Submission status: Runtime Error

Solution code:
## ABC 054 b
import sys
import numpy as np

n,m = (int(_) for _ in input().split())
a = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]
aa = np.array(a)
bb = np.array(b)

for i in range(n-m+1):
    for j in range(n-m+1):
        if (bb[:, :] == aa[i:i+m, j:j+m]):
            print('Yes')
            sys.exit(0)

print('No')

Submission status: Runtime Error

Solution code:
## ABC 054 B
import sys
n, m = map(int, input().split())

a = [input() for i in range(n)]
b = [input() for j in range(m)]

if(n == m and a == b):
    print('Yes')
    sys.exit(0)
elif(m == 1):
    for i in range(n):
        if(b[0] in a[i]):
            print('Yes')
            sys.exit(0)
    print('No')
    sys.exit(0)

for k in range(n-m):
    idx = []
    for j in range(n-m):
        if (a[k][j:j + m] == b[k]):
            idx.append(j)
            continue
    for id in idx:
        for i in range(k,m):
            if(a[i][id:id+m] == b[i]):
                continue
            else:
                print('No')
                sys.exit(0)
        print('Yes')
        sys.exit(0)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
stdin = open("sample.txt")

n,m = [int(x) for x in stdin.readline().rstrip().split()]
A = []
for i in range(n):
    s = stdin.readline().rstrip()
    A.append(s)
B = []
for i in range(m):
    s = stdin.readline().rstrip()
    B.append(s)

Submission status: Runtime Error

Solution code:
phase = 0
if list_a != list_b:
    for i in range(0, n-m):
        for j in range(0, n-m):
            for k in range(0,m):
                if list_a[i+k][j:j+m] == list_b[k]:
                    if k != m-1:
                        continue
                    else:
                        pass
                else:
                    break
                phase = 1
                print("Yes")
                break
            if phase == 1:
                break
        if phase == 1:
            break
    else:
        print("No")
else:
    print("Yes")

Submission status: Runtime Error

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 j in range(N-M+1):
        t=[k[j:j+m] for k in a[i:i+m]]
        if t==B:
            print('Yes')
            exit()
print('No')

Submission status: Runtime Error

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 j in range(N-M+1):
        t=[k[j:j*m] for k in a[i:i+m]]
        if t==B:
            print('Yes')
            exit()
print('No')

Submission status: Runtime Error

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):
    if B[0] in A[i]:
        if all(B[j] in A[i+j] for j in range(1,min(M,N-i)):
            print('Yes')
            exit(0)
print('No')

Submission status: Runtime Error

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):
    if B[0] in A[i]:
        if all(B[j] in A[i+j] for j in range(1,M)):
            print('Yes')
            exit(0)
print('No')

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[list(input()) for a in range(n)]
b=[list(input()) for a in range(m)]
c=0
for p in range(n-m+1):
  for q in range(n-m+1):
    if b[0]==a[p][q:q+m]:
      for r in range(1,m):
        if b[r]!=a[p+r][q:q+m]:break
       c=1
       break
if c==0:print('No')
else:print('Yes')

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[list(input()) for a in range(n)]
b=[list(input()) for a in range(m)]
c=0
for p in range(n-m+1):
  for q in range(n-m+1):
    if b[0]==a[p][q:q+m]:
      for r in range(n-m+1):
        if b[r]!=a[p+r][q-m+1:q]:pass
        else:break
        c=1
if c==1:print('Yes')
else:print('No')

Submission status: Runtime Error

Solution code:
N, M = (int(i) for i in 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+1):
    if B[0] in A[i]:
        pos = A[i].find(B[j])
        flag = 0
        for j in range(M):
            if A[i+j][pos:pos+M] == B[j]:
                pass
            else:
                flag = -1
                break
        if flag = 0:
            print("Yes")

print("No")

Submission status: Runtime Error

Solution code:
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-m+1):
        for l in range(j,n-m+1):
          if p[k-i][l-j]!=o[k][l]:
            return False
  return True

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

Submission status: Runtime Error

Solution code:
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-m+1):
        for l in range(j,n-m+1):
          if p[k-i][l-i]!=o[k][l]:
            return False
  return True

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

Submission status: Runtime Error

Solution code:
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-1):
        for l in range(j,n-1):
          if p[k-i][l-i]!=o[k][l]:
            return False
  return True

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

Submission status: Runtime Error

Solution code:
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m-1):
  for  j in range(n-m-1):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[i+k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")

Submission status: Runtime Error

Solution code:
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m):
  for  j in range(n-m):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[i+k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")

Submission status: Runtime Error

Solution code:
# input
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 + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if B[k][l] == A[i + k][j + l]:
                    ans += 1
                else:
                    break
            if ans == M * 2:
                print("Yes")
                exit()
            else:
                ans = 0
                break

print('No')

Submission status: Runtime Error

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

img = [input() for i in range(n)]
template = [input() for i in range(m)]

for i in range(n - m + 1):
    if len({v.index(t) for v, t in zip(img[i:i + m], template)}) == 1:
        print("Yes")
        break
else:
    print("No")

Submission status: Runtime Error

Solution code:
[n,m]=[int(i) for i in input().split()]
a=[]
b=""
c=[]
d=""
e=1
#a箱,c箱にそれぞれの画像を用意
for i in range(n):
    b=b+str(input().split())
a.append(b)
for i in range(m):
    d=d+str(input().split())
c.append(d)
print(c)
print(d)
#照合
for i in range(n):
    for j in range(m):
        f=c[j].find(a[i])
        if f!=-1:
            for k in range(m):
                e=e*(a[f:f+m]!=c[f:f+m])
if e==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[i+l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')

Submission status: Runtime Error

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

for i in range(n):
    for j in range(m):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[i+l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')

Submission status: Runtime Error

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

for i in range(n):
    for j in range(n):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[i+l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')

Submission status: Runtime Error

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

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')

Submission status: Runtime Error

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

flag = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if T1[i][j: j + m] == T2[0]:
            k = i
            l = 0
            while k < n - m + 1:
                if T1[k][j:j + m] != T2[l]:
                    break
                k += 1
                l += 1
                if l == m:
                    flag = True


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

Submission status: Runtime Error

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

flag = False
for i in range(n - m):
    for j in range(n - m):
        if T1[i][j: j + m] == T2[0]:
            k = i
            l = 0
            while k < n - m + 1:
                if T1[k][j:j + m] != T2[l]:
                    break
                k += 1
                l += 1
                if k == i + m:
                    flag = True


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

Submission status: Runtime Error

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

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

ans = 'No'
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		if judge(A, B, i, j, M):
			ans = 'Yes'
			break

print ans

Submission status: Runtime Error

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

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

ans = 'No'
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		if judge(A, B, i, j, M):
			ans = 'Yes'
			break

print ans

Submission status: Runtime Error

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

for _ in range(N):
    A_list.append(list(input()))
for _ in range(M):
    B_list.append(list(input()))
  
match_list =[]
for i in range(N-M+1):
    for j in range(N-M+1):
        if B_list[0] == A_list[i][j:(j+M)]:
            match_list.append([i, j])
        else:
            pass

whole_flag = 0
for k in match_list:
    flag =0
    for l in range(M):
        if A_list[k[0]+l][k[1]:k[1]+M] ==B_list[k[0]+l]:
            flag += 1
        else:
            break
            
    if flag == M:
        print("Yes")
        whole_flag += 1
        
if whole_flag == 0:
    print("No")

Submission status: Runtime Error

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

for _ in range(N):
    A_list.append(list(input()))
for _ in range(M):
    B_list.append(list(input()))
  
match_list =[]
for i in range(N-M+1):
    for j in range(N-M+1):
        if B_list[0] == A_list[i][j:(j+M)]:
            match_list.append([i, j])
        else:
            pass

flag =0
for k in match_list:
    flag =0
    for l in range(M):
        if A_list[k[0]+l][k[1]:k[1]+M] ==B_list[k[0]+l]:
            flag += 1
        else:
            break
    
    if flag == M:
        print("Yes")
        break
    
    if flag == M:
        print("Yes")
        break

Submission status: Runtime Error

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

for _ in range(N):
    A_list.append(list(input()))
for _ in range(M):
    B_list.append(list(input()))
  
match_list =[]
for i in range(N-M+1):
    for j in range(N-M+1):
        if B_list[0] == A_list[i][j:(j+M)]:
            match_list.append([i, j])
        else:
            pass

flag =0
for k in match_list:
    flag =0
    for l in range(M):
        print(A_list[k[0]+l][k[1]:k[1]+M])
        print(B_list[k[0]+l])
        
        if A_list[k[0]+l][k[1]:k[1]+M] ==B_list[k[0]+l]:
            flag += 1
        else:
            break
    
    if flag == M:
        print("Yes")
        break

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
i,j = 0,0
start = []
while i<=n-m:
    if b[0] in a[i]:
        start.append(a[i].index(b[0]))
        j += 1
        for k in range(1,m):
            if b[k] in a[i+j]:
                start.append(a[i+j].index(b[k]))
                j += 1
                if not start[0] == start[j-1]:
                    start.clear()
                    j = 0
                break
            else:
                start.clear()
                j = 0
                break
    if len(start)==m:
        break
    i += 1
print('Yes' if len(start)>0 else 'No')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
i,j = 0,0
start = []
while i<=n-m:
    if b[0] in a[i]:
        start.append(a[i].index(b[0]))
        j += 1
        for k in range(1,m):
            if b[k] in a[i+j]:
                start.append(a[i+j].index(b[k]))
                j += 1
            else:
                start.clear()
                j = 0
                break
            if not start[0] == start[j-1]:
                start.clear()
                j = 0
                break
    if len(start)==m:
        break
    i += 1
print('Yes' if len(start)>0 else 'No')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
i,j = 0,0
start = []
while i<n-m:
    if b[0] in a[i]:
        start.append(a[i].index(b[0]))
        j += 1
        for k in range(1,m):
            if b[k] in a[i+j]:
                start.append(a[i+j].index(b[k]))
                j += 1
            else:
                start.clear()
                j = 0
                break
            if (not start[0] == start[j-1]):
                start.clear()
                j = 0
                break
    i += 1
print('Yes' if len(start)>0 else 'No')

Submission status: Runtime Error

Solution code:
import sys
N,M=map(int,input().split())
Ai=[]
Bi=[]
for i in range(N):
    Ai.append(input())
for i in range(M):
    Bi.append(input())
roop=N-M+1
for i in range(roop):
    for j in range(roop):
        #print("")
        flag=1
        for k in range(roop):
            #print(Ai[i+k][j:j+M])
            if(Ai[i+k][j:j+M]!=Bi[k]):
                flag=0
                break;
        if(flag==1):
            print("Yes")
            sys.exit()
print("No")

Submission status: Runtime Error

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

A=[]
for i in range(N):
    a=list(input())
    A.append(a)

B=[]
for i in range(M):
    b=list(input())
    B.append(b)

An=np.array(A)
Bn=np.array(B)

t=0
for i in range(N):
    for j in range(N):
        if Bn in An[i:i+M,j:j+M]:
            t=1
            break

if t==1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())

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

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
            if not flag:
                break
        
        if flag:
            print('Yes')
            exit()

print('No')

Submission status: Runtime Error

Solution code:
def solve(n, m, NUM):
    for i in range(len(m)):
        if n[NUM + i] is not m[i]:
            return -1
    return 1


N, M = [int(i) for i in input().split()]
n_pic = [input() for i in range(N)]
m_pic = [input() for i in range(M)]
num = 0
if M is 1:
    for n in n_pic:
        if -1 is not n.find(m_pic[0]):
            print('Yes')
            exit()
    print('No')
    exit()

for n in range(len(n_pic)):
    for n_len in range(N - M + 1):
        while -1 is not solve(n_pic[n+num], m_pic[num], n_len):
            num += 1
            print(num)
            if num is M:
                print('Yes')
                exit()
        num = 0
print('No')

Submission status: Runtime Error

Solution code:
def solve(n, m, NUM):
    for i in range(len(m)):
        if n[NUM + i] is not m[i]:
            return -1
    return 1


N, M = [int(i) for i in input().split()]
n_pic = [input() for i in range(N)]
m_pic = [input() for i in range(M)]
num = 0
if M is 1:
    for n in n_pic:
        if -1 is not n.find(m_pic[0]):
            print('Yes')
            exit()
    print('No')
    exit()

for n in n_pic:
    for n_len in range(N - M + 1):
        while -1 is not solve(n, m_pic[num], n_len):
            num += 1
        if num is M - 1:
            print('Yes')
            exit()
        num = 0
print('No')

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:

N, M = map(int, input().split())
A = []
for i in range(N):
	A.append(input())
B = []
for i in range(M):
	B.append(input())
t = 0
for i in range(N):
	for j in range(N-M):
		t = 0
		for k in range(M):
			if t:
				break
			for l in range(M):
				if A[i+k][j+l] != B[k][l]:
					t = 1
					break
		else:
			if A[i+k][j+l] == B[k][l]:
				print("Yes")
				exit()
print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import numpy as np


def main():
    # 入力処理
    # M = int(input())
    N, M = map(int, input().split())
    sA = ''.join([input() for i in range(N)])
    sB = ''.join([input() for i in range(M)])
    A = np.array([s for s in sA]).reshape(N,N)
    B = np.array([s for s in sB]).reshape(M,M)

    # アルゴリズム本体
    result = np.zeros((N-M,N-M), dtype=bool)
    for i in range(N-M+1):
        for j in range(N-M+1):
            result[i,j] = (A[i:i+M, j:j+M] == B).all()

    # 出力
    if result.any():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import re

first_line = input().split()
n = int(first_line[0])
m = int(first_line[1])

n_list = []
for i in range(n):
    n_list.append(input())
m_list = []
for i in range(m):
    m_list.append(input())

if m == n:
    if n_list == m_list:
        print("Yes")
    else:
        print("No")
else:
    match_flg = False
    for i in range(0, n - m):
        matchOb = re.match(m_list[0], n_list[i])
        if matchOb:
            start_pos = matchOb.start()
            end_pos = matchOb.end()
            for j in range(0, m):
                if n_list[i + j][start_pos:end_pos] == m_list[j] and j == m - 1:
                    match_flg = True
                elif n_list[i + j][start_pos:end_pos] != m_list[j]:
                    break

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

Submission status: Runtime Error

Solution code:
def main():
    nm = map(int, raw_input().split())
    A = []
    B = []
    flag = False
    for i in range(nm[0]):
        A.append(raw_input())
    for i in range(nm[1]):
        B.append(raw_input())

    for i in range(nm[0]):
        for j in range(nm[0]):
            if j + nm[1] <= nm[0]:
                for k in range(nm[1]):
                    for l in range(nm[1]):
                        if(A[i+k][j+l] == B[k][l]):
                            flag = True
                        else:
                            flag = False
                            break 
                    if flag == False:
                        break
            if flag:
                 break
        if flag:
            break
    if flag:
        return "Yes"
    else:
        return "No"    
print main()

Submission status: Runtime Error

Solution code:
def main():
    nm = map(int, raw_input().split())
    A = []
    B = []
    flag = False
    for i in range(nm[0]):
        A.append(raw_input())
    for i in range(nm[1]):
        B.append(raw_input())

    for i in range(nm[0]):
        for j in range(nm[0]):
            if j + nm[1] <= nm[0]:
                for k in range(nm[1]):
                    for l in range(nm[1]):
                        if(A[i+k][j+l] == B[k][l]):
                            flag = True
                        else:
                            flag = False
                            break 
                    if flag == False:
                        break
            if flag:
                 break
        if flag:
            break
    if flag:
        return "yes"
    else:
        return "no"    
print main()

Submission status: Runtime Error

Solution code:
N, M = map(int, raw_input().split())
imgA = []
imgB = []
for i in range(N):
   imgA += raw_input().split()

for i in range(M):
  imgB += raw_input().split()

for i in range(N - M):
  for j in range(M):
    for k in range(M):
    if (imgA[(i + k) * N + j] != imgB[k * M  + j]): return 'No'

return 'Yes'

Submission status: Runtime Error

Solution code:
for i in xrange(0,n-m+1):
  for j in xrange(0, n-m+1):
    flag = True
    for x in xrange(0, m):
      for y in xrange(0, m):
        if mp[x][y] != np[i+x][j+y]:
          flag = False
          break
      if flag == False:
        break
    if flag:
      print "Yes"
      break
  if flag: break
if flag==False: print "No"