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

class Image:
    def __init__(self, n):
        self.matrix = [list(input()) for _ in range(n)]
        self.n = n

    def isIncluded(self, a):
        for i in range(a.n):
            for j in range(a.n):
                if a.matrix[i][j] == self.matrix[0][0]:
                    if j+self.n <= a.n and i+self.n <= a.n:
                        template = [a.matrix[i+k][j:j+self.n]
                                    for k in range(self.n)]
                        print(template)
                        if template == self.matrix:
                            return True
        return False


a = Image(n)
b = Image(m)

print("Yes" if b.isIncluded(a) else "No")


n, m = map(int, input().split())

class Image:
    def __init__(self, n):
        self.matrix = [list(input()) for _ in range(n)]
        self.n = n

    def isIncluded(self, a):
        for i in range(a.n-self.n+1):
            for j in range(a.n-self.n+1):
                template = [row[j:j+self.n] for row in a.matrix[i:i+self.n]]
                if template == self.matrix:
                    return True
        return False


a = Image(n)
b = Image(m)

print("Yes" if b.isIncluded(a) 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):
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):
        cnt=0
        if A[i][j:j+M] ==B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    cnt+=1
            if cnt==M-1:
                ans='Yes'
                
print(ans)

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

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):
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

AN=[]
for _ in range(N):
    AN.append(list(input()))
    
print(AN)

AM=[]
for _ in range(M):
    AM.append(list(input()))

print(AM)


# coding: utf-8
# Your code here!
N,M=map(int,input().split())

AN=[]
for _ in range(N):
    AN.append(list(input()))
    
#print(AN)

AM=[]
for _ in range(M):
    AM.append(list(input()))

#print(AM)
for i in range(N-M+1):
    for j in range(N-M+1):
        #print(i,j)
        flag=True
        for k in range(M):
            if AN[i+k][j:j+M]!=AM[k]:
                
                flag=False
        if flag:
            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_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

N, M = map(int, input().split())
A_list=[input()for i in range(N)]
B_list=[input()for i in range(M)]

whole_flag = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = 0
        for k in range(M):
            if B_list[k] == A_list[i+k][j:j+M]:
                flag += 1
            else:
                pass
        if flag == M:
            whole_flag += 1
            
print("Yes" if whole_flag >0 else "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=[""]*N
B=[""]*M
for i in range(N):
  A[i]=input()
for i in range(M):
  B[i]=input()
flag=False
for i in range(N-M)
    if B[0] in A[i]:
      for j in range(1,M):
        if B[j] in A[i+j]:
          if j = M - 1:
            print("Yes")
            exit(0)
          else:
            continue
        else:
          break
          
print("No")

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

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()
  
A_tmp=[""]*M
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      A_tmp[k]=A[j+k][i:i+M]
    if A_tmp==B:
      print("Yes")
      exit(0)

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 = (int(i) for i in input().split())
a = []
b = []
for i in range(N):
    data = list(input())
    a.append(data)
for i in range(M):
    data = list(input())
    b.append(data)

print(a[0])
    
L = N-M

def check(i,j):
    ans=True
    for line in range(L+1):
        for row in range(L+1):
            if (a[i+line][j+row]!=b[line][row]):
                ans=False
    return ans
                
for i in range(L+1):
    for j in range(L+1):
        ans=check(i,j)
        print(ans)


N, M = (int(i) for i in input().split())
a = []
b = []
for i in range(N):
    data = list(input())
    a.append(data)
for i in range(M):
    data = list(input())
    b.append(data)

#N=4
#M=2
#a=[['a','s','a','s'],['a','a','s','s'],['s','a','a','s'],['s','a','a','a']]
#b=[['s','a'],['a','s']]

L = N-M

def check(i,j):
    ans=True
    for line in range(M):
        if (ans==False):
            break
        for row in range(M):
            if (a[i+line][j+row]!=b[line][row]):
                ans=False
                break
    return ans

ans=False
for i in range(L+1):
    if(ans==True):
        break
    for j in range(L+1):
        ansnow=check(i,j)
 #       print(ansnow,i,j)
        if(ansnow==True):
            ans=True
            break
if(ans==True):
    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())
A=[input()for i in range(N)]
B=[input()for i in range(M)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+2):
    if B[0]in A[0] and B[1] in A[1]:
        for j in range(N-M+2):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
    if a==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)]
b=''
a='no'
for i in range(M):
    b+=B[i]
print(b)
for i in range(N-M+1):
    if B[0]in A[i] and B[1] in A[i+1]:
        for j in range(N-M+1):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
            if a==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)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+1):
    if B[0]in A[i] and B[1] in A[i+1]:
        for j in range(N-M+2):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
    if a==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)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+1):
    if B[0]in A[i] :
        for j in range(N-M+1):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
            if a==b:
                print("Yes")
                exit()
print("No") 


Verdicts: Runtime Error

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):
import numpy as np

n,m=map(int,input().split())
a=np.zeros([n,n])
b=np.zeros([m,m])
map_ = {".":1,"#":-1}

for i in range(n):
  temp = list(input())
  temp = [map_[c] for c in temp]
  a[i,:] = np.array(temp)
  
for i in range(m):
  temp = list(input())
  temp = [map_[c] for c in temp]
  b[i,:] = np.array(temp)

flag=False
for i in range(n-m+1):
  for j in range(n-m+1):
    temp_a = a[i:i+m,j:j+m]
    print(temp_a)
    check=np.sum(temp_a*b,axis=1)
    check=np.sum(check,axis=0)
    print(check)
    if check==m*m:
      flag=True
      break
    else:
      pass
if flag:
  print("Yes")
else:
  print("No")

import numpy as np

n,m=map(int,input().split())
a=np.zeros([n,n])
b=np.zeros([m,m])
map_ = {".":1,"#":-1}

for i in range(n):
  temp = list(input())
  temp = [map_[c] for c in temp]
  a[i,:] = np.array(temp)
  
for i in range(m):
  temp = list(input())
  temp = [map_[c] for c in temp]
  b[i,:] = np.array(temp)

flag=False
for i in range(n-m+1):
  for j in range(n-m+1):
    temp_a = a[i:i+m,j:j+m]
    check=np.sum(temp_a*b,axis=1)
    check=np.sum(check,axis=0)
    if check==m*m:
      flag=True
      break
    else:
      pass
if flag:
  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):
import sys
if sys.platform == 'ios':
	sys.stdin = open('input_file.txt')
	

n,m = map(int,input().split())

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

s = [ [0]*m for i in range(m) ]

ans = 0

for i in range(n-m+1):
	for j in range(n-m+1):
		for k in range(m):
			#print(i,j,k)
			s[k] = a[i+k][j:j+m]
		#print(s)
		
		if s == b :
			print(i,j,s)
			ans = ans +1

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


import sys
if sys.platform == 'ios':
	sys.stdin = open('input_file.txt')
	

n,m = map(int,input().split())

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

s = [ [0]*m for i in range(m) ]

ans = 0

for i in range(n-m+1):
	for j in range(n-m+1):
		for k in range(m):
			#print(i,j,k)
			s[k] = a[i+k][j:j+m]
		#print(s)
		
		if s == b :
			#print(i,j,s)
			ans = ans +1

print('Yes' if ans >= 1 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):
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')

def is_equal(i,j,m):
    d = 0
    for k in range(m):
        if a[i+k][0][j:j+m] == b[k][0][::]:
            d = 0
        else:
            return False
    if d == 0:
        return True

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

for i in range(n-m+1):
    ans = 0
    for j in range(n-m+1):
        if is_equal(i,j,m):
            ans =1
            break
    if ans == 1:
        break
if ans == 1:
    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())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1 
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")

N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1
    mc = 0
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")

N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1
    mc = 0
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")

Verdicts: Runtime Error

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 _ in range(n)]
b = [list(input()) for _ in range(m)]

si, sj = 0, 0
c = 0
while si < n - m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            print(ni, nj, i, j)
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
        print()
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 0

print("No")
    

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

si, sj = 0, 0
c = 0
while si <= n - m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
        # print()
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 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 = map(int,input().split())
a=[]
for _ in [0]*n:
  a += [list(input())]
b=[]
for _ in [0]*m:
  b += [list(input())]

print(a,b)

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

n,m = map(int,input().split())
a=[]
for _ in [0]*n:
  a += [list(input())]
b=[]
for _ in [0]*m:
  b += [list(input())]

print(a,b)

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


n,m = map(int,input().split())
a = []
b = []

for _ in range(n):
    a += [list(input())]
for _ in range(m):
    b += [list(input())]

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


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=[]
B=[]

for n in range(N):
    A.append(input())

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

for m in range(M):
    for n in range(N):
        
        
        span =[m.span() for m in re.finditer(B[m], A[n])]
        print(span)
        if span==[]:
            continue
        allgood=False
        
        if M==1:
            print("Yes")
            exit()
        for i in range(n+1, M):
            print((B[i],A[i][span[0][0]:span[0][1]]))
            if (B[i]==A[i][span[0][0]:span[0][1]]):
                allgood=True
                continue
            else:
                allgood=False
                break
        if allgood==True:
            print("Yes")
            exit()

print("No")



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

A=[]
B=[]

for n in range(N):
    A.append(input())

for m in range(M):
    B.append(input())
        
if N<M:
    print("No")
    exit()

for n in range(N):
      
      
      span =[m.span() for m in re.finditer(B[0], A[n])]
      #print(span)
      if span==[]:
          continue
      allgood=False
      for sp in span:
        for i in range(min(M,N)):
            if n+i>=N:
                allgood=False
                break
            #print(n)
            #print((B[i],A[n+i][span[0][0]:span[0][1]]))
            if (B[i]==A[n+i][sp[0]:sp[1]]):
                allgood=True
                continue
            else:
                allgood=False
                break
        if allgood==True:
            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().strip().split())
ns,ms = [],[]
for _ in range(n):
    ns.append(input().strip())
for _ in range(m):
    ms.append(input().strip())

allFlag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if ns[i][j:j+m] == ms[0]:
            Flag = 1
            for k in range(m):
                if ns[i+k][j:j+m]!=ms[k]:
                    Flag = 0
            if Flag:
                print("Yes")
                allFlag = 1
if not allFlag:
    print("No")

n,m = map(int,input().strip().split())
ns,ms = [],[]
for _ in range(n):
    ns.append(input().strip())
for _ in range(m):
    ms.append(input().strip())

allFlag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if ns[i][j:j+m] == ms[0]:
            Flag = 1
            for k in range(m):
                if ns[i+k][j:j+m]!=ms[k]:
                    Flag = 0
            if Flag and not allFlag:
                print("Yes")
                allFlag = 1
if not allFlag:
    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 = []
B = []

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

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

ans = True

for i in range(M):
    if A[i] not in B[i]:
        ans = False
        break

print('Yes' if ans == True else 'No')


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

A = []
B = []

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

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

ans = True

for i in range(M):
    if not A[i] in B[i]:
        ans = False
        break

print('Yes' if ans == True else 'No')


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 = True

for i in range(M):
    if B[i] not in A[i]:
        ans = False
        break

print('Yes' if ans == True else 'No')

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

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 found: break
if not found:
    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 = []
for n in range(N):
    a = input()
    A_list.append(a)

B_list = []
for m in range(M):
    b = input()
    B_list.append(b)

diff = N - m

for i in range(diff):
    is_same = False
    for j in range(diff):
        for b in range(M):
            if B_list[b] == A_list[i][j: j + M]:
                is_same = True
            else:
                is_same = False
                break
        else:
            continue
        break

    if is_same:
        print('Yes')
        exit()

    else:
        continue

print('No')


# 5 3
# ..#..
# ..#.#
# .....
# #..#.
# .....
# ...
# ..#
# #.#




N, M = map(int, input().split())
A_list = []
for n in range(N):
    a = input()
    A_list.append(a)

B_list = []
for m in range(M):
    b = input()
    B_list.append(b)

diff = N - m

for i in range(diff):
    is_same = False
    for j in range(diff):
        for b in range(M):
            if B_list[b] == A_list[i + b][j: j + M]:
                is_same = True
            else:
                is_same = False
                break

        if is_same:
            print('Yes')
            exit()

    else:
        continue

print('No')


# 5 3
# ..#..
# ..#.#
# .....
# #..#.
# .....
# ...
# ..#
# #.#


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

# import re
import math
import collections

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


import sys

# import re
import math
import collections

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


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())
l=[input() for i in range(n)]
ml=[input() for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    for h in range(m):
      if ml[h]!=l[i][j:j+m]:break
    else:print("Yes");exit()
print("No")

n,m=map(int,input().split())
l=[input() for i in range(n)]
ml=[input() for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    for h in range(m):
      if ml[h]!=l[i+h][j:j+m]:break
    else: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())
A = [input() for _ in range(N)]
B = [input() for _ in range(N)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k][l]:
          break
        if A[k][l] == B[k][l] and k == i+M-1 and l == j+M-1:
          ans = 1
    else:
      continue
    break
if ans == 0:
  print("No")
else:
  print("Yes")

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):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k-i][l-j]:
          break
        if A[k][l] == B[k-i][l-j] and k == i+M-1 and l == j+M-1:
          ans = 1
      else:
        continue
      break

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

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)]
r=any(a[i:i+m][j:j+m]==b for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if r else 'No')

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):
        C=[A[i+k][j:j+m] for k in range(m)]
        if B==C:
            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):
N,M=map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

flag=0
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:
      flag=1
      print('!')
print('Yes' if flag==1 else 'No')

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

flag=0
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:
      flag=1
print('Yes' if flag==1 else 'No')

Verdicts: Wrong Answer

Accepted