TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 'Yes'
def match(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True
for i in range(N-M+1):
  for j in range(N-M+1):
    if not match(i, j):
      ans = 'No'
      break
print(ans)

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 'No'
def match(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True
for i in range(N-M+1):
  for j in range(N-M+1):
    if match(i, j):
      ans = 'Yes'
      break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

wa = len(A[0])
wb = len(B[0])
  
matched = False
for i1 in range(N - M + 1):
  for j1 in range(wa - wb +1):
    cnt = 0
    for i2 in range(M):
      #print(B[i2]," vs ", A[i1+i2][j1:j1+wb])
      if B[i2] == A[i1+i2][j1:j1+wb]:
        cnt += 1
    if cnt == M:
      matched = True
      break
          

if matched:
  print("YES")
else:
  print("NO")
      

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

wa = len(A[0])
wb = len(B[0])
  
matched = False
for i1 in range(N - M + 1):
  for j1 in range(wa - wb +1):
    cnt = 0
    for i2 in range(M):
      #print(B[i2]," vs ", A[i1+i2][j1:j1+wb])
      if B[i2] == A[i1+i2][j1:j1+wb]:
        cnt += 1
    if cnt == M:
      matched = True
      break
          

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
print(list_A)
print(list_B)
k = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
      if any( list_A[v+i][t:t+m]!=list_B[v] for v in range(m)):
        break
      k = "Yes"
print(k)

n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
t = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
    if all(list_A[i][t:t+m+1]==list_B[i][t:t+m+1]):
      print("Yes")

n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
k = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
      if all(list_A[v+i][t:t+m]==list_B[v] for v in range(m)):
        k = "Yes"
        break
print(k)
    

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
N,M = map(int, input().split())
A = []
for i in range(N):
    A.append(input())
B = []
for i in range(M):
    M.append(input())
A = np.array(A)
B = np.array(B)

for i in range(N-M):
    for j in range(N-M):
        if A[i:i+M, j:j+M] == B:
            print('Yes')
            exit()
print('No')

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

for i in range(N-M):
    for j in range(N-M):
        if A[i:i+M][j:j+M] == B:
            print('Yes')
            exit()
print('No')

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

for i in range(N-M+1):
    for j in range(N-M+1):
        tmp = [A[i+k][j:j+M] for k in range(M)]
        if tmp == B:
            print('Yes')
            exit()
print('No')

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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):
    if a[i:i+m][j:j+m] == b[:]:
      print("Yes")
      exit()
print("No")


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):
    new = [a[k][j:j+m] for k in range(i, i+m)]
    if new == b:
      print("Yes")
      exit()
print("No")


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())

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

for i in range(N-M):
  for j in range(N-M):
    try:
      for k in range(i, i+M):
        for l in range(l, l+M):
          if A[i+k][j+k] != B[k][l]:
            raise ""
      else:
        print('Yes')
    except:
      print('No')
      

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

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


def f(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True

def slv():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if f(i, j):
        return 'Yes'
  return 'No'
print(slv())
      


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def solve(n, m, a, b):
  for i in range(n - m + 1):
    for j in range(n - m + 1):
      if a[i:i+m][j:j+m] == b:
        return True
  return False
  

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print('Yes' if solve(n, m, a, b) else 'No')

def solve(n, m, a, b):
  for i in range(n - m + 1):
    for j in range(n - m + 1):
      if [row[j:j+m] for row in a[i:i+m]] == b:
        return True
  return False

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print('Yes' if solve(n, m, a, b) else 'No')

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np

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

sa=n-m+1

for x in range(sa):
    for y in range(sa):

        if na[x:x+m,y:y+m].tolist()==b:
            print("Yes")
print("No")

import numpy as np
import sys
n,m=map(int,input().split())
a= [list(input()) for i in range(n)] 
b= [list(input()) for i in range(m)] 
na=np.array(a)

sa=n-m+1

for x in range(sa):
    for y in range(sa):

        if na[x:x+m,y:y+m].tolist()==b:
            print("Yes")
            sys.exit()
print("No")

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,m = map(int,input().split())
li_a = [list(input()) for _ in range(n)]
li_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):
            if li_a[i+x][j:j+m] != li_b[x][:]:
                break
        else:
            print("Yes")
            exit()
            
print("No")

n,m = map(int,input().split())
li_a = [list(input()) for _ in range(n)]
li_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):
            if li_a[i+k][j:j+m] != li_b[k][:]:
                break
        else:
            print("Yes")
            exit()
            
print("No")

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

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

print('No')


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

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

print('No')


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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")

import sys

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[0])
        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")
            sys.exit()

print("No")

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys

n,m=map(int,input().split())
ln=[list(input()) for i in range(n)]
lm=[list(input()) for i in range(m)]

flg=0
for i in range(n-m+1):
  for j in range(n-m+1):
    if ln[i][j:j+m]==lm[0][0:]:
      flg=1
      for k in range(m-1):
        if ln[i+k+1][j:j+m]!=lm[k+1][0:]:
          flg=0
    if flg==1:
      print("YES")
      sys.exit()
print("NO")
          

import sys

n,m=map(int,input().split())
ln=[list(input()) for i in range(n)]
lm=[list(input()) for i in range(m)]

flg=0
for i in range(n-m+1):
  for j in range(n-m+1):
    if ln[i][j:j+m]==lm[0][0:]:
      flg=1
      for k in range(m-1):
        if ln[i+k+1][j:j+m]!=lm[k+1][0:]:
          flg=0
    if flg==1:
      print("Yes")
      sys.exit()
print("No")
          

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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):
        x=[]
        for k in range(m):
            x.append(a[i+k][j+m])
        if x==b:
            print("Yes")
            exit()
print("No")


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):
        x=[]
        for k in range(m):
            x.append(a[i+k][j:j+m])
        if x==b:
            print("Yes")
            exit()
print("No")


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())
A = []
A_portion = []
B = []
judge = 0

if(N < M):
  print('No')
else:
 for i in range(N):
   a = input() + '?'*(M)
   A.append(list(a))
 for i in range(M):
   list_dummy = list('?'*(len(a)))
   A.append(list_dummy)
  
 for i in range(M):
   b = input()
   B.append(list(b))

 for i in range(N):
  for j in range(M):
   for k in range(M):
    A_portion.append(A[j+k][i:i+M])
   print(j+k,i,i+M-1)
   print(A_portion)
   if(A_portion == B):
     judge = 1
   A_portion = []
    
 if(judge == 1):
   print('Yes')
 else:
   print('No')

N,M = map(int,input().split())
A = []
A_portion = []
B = []
judge = 0

if(N < M):
  print('No')
else:
 for i in range(N):
   a = input() + '?'*(M)
   A.append(list(a))
 for i in range(M):
   list_dummy = list('?'*(len(a)))
   A.append(list_dummy)
  
 for i in range(M):
   b = input()
   B.append(list(b))

 for i in range(N):
  for j in range(N):
   for k in range(M):
    A_portion.append(A[j+k][i:i+M])
   #print(j+k,i,i+M-1)
   #print(A_portion)
   if(A_portion == B):
     judge = 1
   A_portion = []
    
 if(judge == 1):
   print('Yes')
 else:
   print('No')

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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")



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

a=[]
b=[]

for i in range(N):
    a.append(input())

N=0

for i in range(M):
    b.append(input())
    if(b[i] in a[i]):
        N+=1

if(N==M):
    print("Yes")
else:
    print("No")


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, m, *d = open(0).read().split()
n, m = int(n), int(m)
r = range(n - m + 1)
print(["No","Yes"][all(d[n:] == [t[j:j+m] for t in d[i:i+m]] for i in r for j in r)])

n, m, *d = open(0).read().split()
n, m = int(n), int(m)
r = range(n - m + 1)
print(["No","Yes"][all(d[n:] == [t[j:j+m] for t in d[i:i+m]] for i in r for j in r)::2])

n, m, *d = open(0).read().split()
n, m = int(n), int(m)
r = range(n - m + 1)
print(["No","Yes"][any(d[n:] == [t[j:j+m] for t in d[i:i+m]] for i in r for j in r)])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import re
n,m = map(int, input().split())
a = [input().strip() for i in range(n)]
b = [input().strip() for i in range(m)]

mc = n-m+1
ans = False
for ai in range(0, mc):
  if(ans):
    break
  ind = [x.start() for x in re.finditer(b[0], a[ai])]
  for i in ind:
    if(ans):
      break
    for bi in range(0, mc):
      print(bi,a[ai+bi+1][i:i+m], b[bi+1])
      if(a[ai+bi+1][i:i+m] != b[bi+1]):
        break
      if(bi==mc-1):
        ans = True
if(ans):
  print('Yes')
else:
  print('No')

import re
n,m = map(int, input().split())
a = [input().strip() for i in range(n)]
b = [input().strip() for i in range(m)]

mc = n-m+1
ans = False
for ai in range(0, mc):
  if(ans):
    break
  ind = [x.start() for x in re.finditer(b[0], a[ai])]
  if(m==1)and(len(ind)>0):
    ans=True
    break  
  for i in ind:
    if(ans):
      break
    for bi in range(1, m):
      if(a[ai+bi][i:i+m] != b[bi]):
        break
      if(bi==m-1):
        ans = True
        break
if(ans):
  print('Yes')
else:
  print('No')

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
ans = "No"
print(a, b)

for i in range(n - m + 1):
    for j in range(n - m + 1):
        if a[i][j] == b[0][0]:
            c = []
            for k in range(m):
                c.append(a[i + k][j:j + m])
            if c == b:
                ans = "Yes"
print(ans)


n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
ans = "No"

for i in range(n - m + 1):
    for j in range(n - m + 1):
        if a[i][j] == b[0][0]:
            c = []
            for k in range(m):
                c.append(a[i + k][j:j + m])
            if c == b:
                ans = "Yes"
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/B-TempleteMatching.py
#
n, m = map(int, input().split())
a = []
b = []
is_contain = True

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

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

print(a)
print(b)


for i in range(n-m+1):
    for j in range(n-m+1):
        count = 0
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] == b[k][l]:
                    count += 1

        # print(count)
        if count == m*m:
            print("Yes")
            exit()


print("No")




#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/B-TempleteMatching.py
#
n, m = map(int, input().split())
a = []
b = []
is_contain = True

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

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

for i in range(n-m+1):
    for j in range(n-m+1):
        count = 0
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] == b[k][l]:
                    count += 1

        # print(count)
        if count == m*m:
            print("Yes")
            exit()


print("No")


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
## 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')

## ABC 054 b
import sys
from numpy import array as npa

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

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

print('No')

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())
A = [input() for _ in [0]*N]
B = [input() for _ in [0]*M]
endFlg = False
for i in range(N-M):
    for j in range(N-M):
        breakFlg = False
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    breakFlg = True
                    break
        if breakFlg: break
        pass
        else: endFlg = True
    if endFlg: break
if endFlg:print("Yes")
else:print("No")

N,M = map(int,input().split())
A = [input() for _ in [0]*N]
B = [input() for _ in [0]*M]
endFlg = False
for i in range(N-M+1):
    for j in range(N-M+1):
        breakFlg = False
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    breakFlg = True
                    break
            if breakFlg:break
        else:endFlg=True
        if endFlg: break
    if endFlg: break
if endFlg:print("Yes")
else:print("No")

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(0, M - N):
  for j in range(0, M - N):
    if A == B[i:i+N+1][j:j+N+1]:
      flag = True
    if flag:
      break
  if flag:
    break
if flag:
  print("Yes")
else:
  print("No")

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
flag = False
for i in range(0, N - M + 1):
  for j in range(0, N - M + 1):
    if B == [x[j:j+M] for x in A[i:i+M]]:
      flag = True
    if flag:
      break
  if flag:
    break
if flag:
  print("Yes")
else:
  print("No")

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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):
        cnt = 0
        for k in range(m):
            if a[i+k][j:j+m] == b[k]:
                cnt += 1
            if cnt == m:
                print("YES")
                exit()
print("NO")

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):
        cnt = 0
        for k in range(m):
            if a[i+k][j:j+m] == b[k]:
                cnt += 1
            if cnt == m:
                print("Yes")
                exit()
print("No")

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
count = 0
idx = 0
position = []
for b in B:
    if idx == 0 and count == 0:
        for i, a in enumerate(A[:-m]):
            if b in a:
                position.append(a.find(b))
                if a.count(b) > 1:
                    x = a.find(b)
                    for _ in range(a.count(b)-1):
                        x = a.find(b, x)
                        position.append(x)
                count += 1
                idx = i
                break
        if count == 0:
            print('No')
            sys.exit()
    else:
        for i, a in enumerate(A[idx+1:]):
            for p in position:
                if b == a[p:p + m]:
                    break
                print('No')
                sys.exit()
print('Yes')

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        c = [x[j:j+m] for x in a[i:i+m]]
        if c == b:
            flag = 1
            break
print('Yes') if flag == 1 else print('No')

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,m=map(int,input().split())
a= [list(input()) for n in range(n)] 
b= [list(input()) for m in range(m)] 
m1=0
for i in range(n-m+1): 
    for j in range(n-m+1): 
      if b[i][j+k]==a[i][j] for k in range(n-m+1):m1+=1
        if m1==m:print('Yes') and exit()
        else:pass
      else:print('No')

n,m=map(int,input().split())
a= [list(input()) for _ in range(n)] 
b= [list(input()) for _ in range(m)] 
m1=0
for i in range(n-m+1): 
    for j in range(n-m+1): 
      if b[i][j+k]==a[i][j] for k in range(n-m+1):m1+=1
        if m1==m:print('Yes') and exit()
        else:pass
      else:print('No')

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):
        a1 = [a[k][j:j+m] for k in range(i,i+m)]
        if a1 == b:
            print('Yes')
            exit()

print('No')

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

if N == M:
    if A == B:
        print("Yes")
    else:
        print("No")
    exit()
    
for a_i in range(N-M):
    if B[0] in A[a_i]:
        
        start = []
        for a_j in range(N-M+1):
            if B[0] == A[a_i][a_j:M+a_j]:
                start.append(a_j)
        print(start)
        for s in start:
            f = True
            for b_i in range(M):
                
                if B[b_i] != A[a_i+b_i][s:s+M]:
                    f = False
            if f == True:
                print("Yes")
                exit()
print("No")

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

if N == M:
    if A == B:
        print("Yes")
    else:
        print("No")
    exit()

for a_i in range(N-M):
    if B[0] in A[a_i]:
        
        start = []
        for a_j in range(N-M+1):
            if B[0] == A[a_i][a_j:M+a_j]:
                start.append(a_j)
        for s in start:
            f = True
            for b_i in range(M):
                
                if B[b_i] != A[a_i+b_i][s:s+M]:
                    f = False
            if f == True:
                print("Yes")
                exit()
print("No")

Verdicts: Wrong Answer

Accepted