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

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][j]==b[k][l]:
                    count+=1
        if count==M*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):
        count=0
        for k in range(M):
            for l in range(M):
                if a[i][j]!=b[k][l]:
                    break
                else:
                    count+=1
        if count==M*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):
        count=0
        for k in range(M):
            for l in range(M):
                if a[i+k][j+l]!=b[k][l]:
                    break
                else:
                    count+=1
        if count==M*M:
            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):
# input
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if B[k][l] == A[i + k][j + l]:
                    ans += 1
                else:
                    break
            if ans == M * 2:
                print("Yes")
                exit()
            else:
                ans = 0
                break

print('No')

import numpy as np

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

A_arr = np.array(A)
B_arr = np.array(B)

for i in range(N - M + 1):
    for j in range(N - M + 1):
        if np.array_equal(A_arr[i:i + M, j:j + M], B_arr):
            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):
import sys
N, M = map(int,input().split())
A,B=[],[]
for i in range(N):
    array = list(input().split())
    A.append(array)
for j in range(M):
    array = input().split()
    B.append(array)

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')
            sys.exit()
print('No')

import sys
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')
            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):
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

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

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

def check():
    for i in range(n):
            for j in range(n):
                if i + m <= n and j + m <= n:
                    aa = []
                    for k in range(m):
                        aa.append(a[i + k][j : j+m])
                    if aa == b:
                        return 'Yes'
    return 'No'

print(check())

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

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


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

al = np.array([list(input()) for _ in range(a)])
bl = np.array([list(input()) for _ in range(b)])

flg  = False
for i in range(a - b + 1):
    for j in range(a - b + 1):
        if(al[i:i+b,j:j+b] == bl).all():
            flg = True
            
print('Yes' if flg else 'No')



import numpy as np
a,b = [int(i) for i in input().split()]

al = np.array([list(input()) for _ in range(a)])
bl = np.array([list(input()) for _ in range(b)])

flg  = False
for i in range(a - b + 1):
    for j in range(a - b + 1):
        if(al[i:i+b,j:j+b] == bl).all():
            flg = True
            
print('Yes' if flg 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 = [input() for _ in range(N)]
B = [input() for _ in range(M)]

c = []

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:
            print('Yes')
            break
if B!=c:print('No')


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

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

c = []

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:
            print('yes')
            break
if B!=c:print('No')



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

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

c = []

d = 0

for i in range(N-M+1):
    if d==1:break
    for j in range(N-M+1):
        c = [A[i+k][j:j+M] for k in range(M)]
        if B==c:
            d = 1
            break
if d==1:print('Yes')
else: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):
n, m = map(int, input().split())
a = ['']*n
b = ['']*m
for i in range(n):
  a[i] = str(input())
for i in range(m):
  b[i] = str(input())
for i in range(n-m+2):
  c = a[0:m]
  for j in range(n-m+2):
    d = [e[j:j+m] for e in c]
    print(d)
    if b == d:
      print('Yes')
      exit()
else:
  print('No')

n, m = map(int, input().split())
a = ['']*n
b = ['']*m
for i in range(n):
  a[i] = str(input())
for i in range(m):
  b[i] = str(input())
for i in range(n-m+2):
  c = a[i:i+m]
  for j in range(n-m+2):
    d = [e[j:j+m] for e in c]
    if b == d:
      print('Yes')
      exit()
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):
s = input()  # "3 2"
n, m = s.split()  # ("3", "2")
n = int(n)  # 3
m = int(m)  # 2

a = []
for i in range(0, n):
    a.append(input())

b = []
for i in range(0, m):
    b.append(input())

def same(a, b, i, j):
    for k in range(0, len(b)):
        if a[i + k][j:j + len(b)] != b[k]:
            return False
    return True

print("a, b: {}, {}".format(a, b))

is_same = False
for i in range(0, n - m + 1):
    for j in range(0, n - m + 1):
        if same(a, b, i, j):
            is_same = True
            break
    else:
        continue
    break

print("Yes" if is_same else "No")


s = input()  # "3 2"
n, m = s.split()  # ("3", "2")
n = int(n)  # 3
m = int(m)  # 2

a = []
for i in range(0, n):
    a.append(input())

b = []
for i in range(0, m):
    b.append(input())

def same(a, b, i, j):
    for k in range(0, len(b)):
        if a[i + k][j:j + len(b)] != b[k]:
            return False
    return True

is_same = False
for i in range(0, n - m + 1):
    for j in range(0, n - m + 1):
        if same(a, b, i, j):
            is_same = True
            break
    else:
        continue
    break

print("Yes" if is_same 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 _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())

res = False
for sy in range(N - M + 1):
    for dy in range(M):
        y = sy + dy
        ok = True
        for i in range(N - M + 1):
            a = A[y][i:i + M]
            ok = ok and a == B[dy]
        res = res or ok
print("Yes" if ok else "No")

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

res = False
for sy in range(N - M + 1):
    for sx in range(N - M + 1):
        ok = True
        for dy in range(M):
            y = sy + dy
            a = A[y][sx:sx + M]
            ok = ok and a == B[dy]
        res = res or ok
print("Yes" if res 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())
data = []
for i in range(N):
  data.append(input())
input_data=[]
for i in range(M):
  input_data.append(input())
flag_1 = False
for i in range(N - M + 1):
  for j in range(N - M + 1):
    if flag = False
    for k in range(M):
      for l in range(M):
        if data[i+k][j+l] != input_data[k][l]:
          flag = True
    if flag:
      flag_1 = True

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




N, M = map(int, input().split())
data = []
for i in range(N):
  data.append(input())
input_data=[]
for i in range(M):
  input_data.append(input())
flag_1 = False
for i in range(N - M + 1):
  for j in range(N - M + 1):
    flag = True
    for k in range(M):
      for l in range(M):
        if data[i+k][j+l] != input_data[k][l]:
          flag = False
    if flag:
      flag_1 = True

if flag_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):
from itertools import product

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

for i, j in product(range(n - m + 1), repeat=2):
    print(i,j)
    if all(a[i + k][j:] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')


from itertools import product

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

for i, j in product(range(n - m + 1), repeat=2):
    print(i,j)
    if all(a[i + k][j:j + m] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')


from itertools import product

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

for i, j in product(range(n - m + 1), repeat=2):
    if all(a[i + k][j:j + m] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    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):
n,m=map(int,input().split());a,b,ans=[input()for i in range(n)],[input()for i in range(m)],"No"
for i in range(n-m+1):
  for j in range(n-m+1):
    c=[(a[i])[j:j+m]for k in range(m)]
    if b==c:ans="Yes"
print(ans)

n,m=map(int,input().split());a=[input()for i in range(n)];b=[input()for i 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 _ in range(n)]
b = [input() for _ in range(m)]

def main():

    for i in range(n-m+1):
        for j in range(n-m+1):
            if match(i, j):
                print("yes")
                exit()
    
    print("no")

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

    return True

if __name__ == "__main__":
    main()

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

def main():

    for i in range(n-m+1):
        for j in range(n-m+1):
            if match(i, j):
                print("Yes")
                exit()
    
    print("No")

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

    return True

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 = [int(i) for i in input().split()]

def init_img(n):
    return [[0 if j == "#" else 1 for j in input()] for i in range(n)]

img = init_img(n)

tmp_img = init_img(m)

flg = False

for i in range(n):
    if flg:
        break

    for j in range(n):
        count = 0
        for k in range(m):
            if img[i+k][j:j+m] == tmp_img[k]:
                count += 1

        if count == 3:
            flg = True

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


n, m = [int(i) for i in input().split()]

def init_img(n):
    return [[0 if j == "#" else 1 for j in input()] for i in range(n)]

img = init_img(n)

tmp_img = init_img(m)

flg = False

for i in range(n):
    if flg:
        break

    if i+m > n:
        break

    for j in range(n):
        count = 0
        if j+m > n:
            break
        
        for k in range(m):
            if img[i+k][j:j+m] == tmp_img[k]:
                count += 1

        if count == m:
            flg = True

if flg:
    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):
#include <string>


using namespace std;

const int nmax = 50;
const int mmax = 50;
char N_sq[nmax][nmax], M_sq[mmax][mmax];


bool judge_match(int x, int y, int M){
	for(int i=0;i<M;i++){
		for(int j=0;j<M;j++){
			if(N_sq[y+i][x+j] != M_sq[y+i][x+j]) return false;
		}
	}
	return true;
}


int main(void){
	int N,M;

	cin >> N >> M;
	bool exist = false;

	for(int y=0;y < N;y++){
		for(int x;x < N;x++){
			cin >> N_sq[y][x];
		}
	}

	for(int y=0;y < M;y++){
		for(int x;x < M;x++){
			cin >> M_sq[y][x];
		}
	}

	for(int y=0;y <= N - M;y++){
		for(int x=0;x <= N - M;x++){
			if(judge_match(x, y, M)) exist=true;
		}
	}

	if(exist)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}

import sys

count = 0
N_list = []
M_list = []
for line in sys.stdin:
    line = line.rstrip("\n")
    if count == 0:
        line = line.split(" ")
        N = int(line[0])
        M = int(line[1])
    elif count <= N:
        N_list.append(line)
    else:
        M_list.append(line)
    count+=1
    
    
def judge_match(N_l, M_l):
    slide_count = len(N_l[0]) - len(M_l[0]) + 1
    count = 0
    for j in range(slide_count):
        count = 0
        for i in range(len(N_l)):
            if N_l[i][j:j+len(M_l[0])] == M_l[i]:
                count += 1
                if count == len(M_l):
                    return count
    return count

m_count = 0
for i in range(len(N_list)):
    m_count = judge_match(N_list[i:i+len(M_list)], M_list)
    if m_count == len(M_list):
        print("Yes")
        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 = [''] * N
B = [''] * M
for i in range(N):
    A[i] = input()
for i in range(M):
    B[i] = input()

match_cnt = 0
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True
        for y in range(M):
            for x in range(M):
                print(A[y + i][x + j], B[y][x])
                if A[y + i][x + j] != B[y][x]:
                    flag = False
        if flag:
            match_cnt += 1

if match_cnt > 0:
    print('Yes')
else:
    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()

match_cnt = 0
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True
        for y in range(M):
            if A[y + i][j:j + M] != B[y]:
                flag = False
        if flag:
            match_cnt += 1

if match_cnt > 0:
    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

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

cl = [[] for i in range(n - m + 1)]
for i in range(n - m + 1):
    for j in range(m):
        if not a[i].find(b[j]) == -1:
            cl[i].append(j)
print(cl)
for cs in cl:
    if cs == [0]:
        print("Yes")
        sys.exit()
for ci in cl:
    if ci == list(range(m)) * (n - m):
        print("Yes")
        sys.exit()

print("No")


import sys

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

cl = [[] for i in range(n - m + 1)]
for i in range(n - m + 1):
    for j in range(m):
        if not a[i].find(b[j]) == -1:
            cl[i].append(j)

if n == m and cl == [[0]]:
    print("Yes")
    sys.exit()
else:
    print("No")
    sys.exit()

for cs in cl:
    if cs == [0]:
        print("Yes")
        sys.exit()
for ci in cl:
    if ci == list(range(m)) * (n - m):
        print("Yes")
        sys.exit()

print("No")


from itertools import product as prd

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


c = n - m + 1
ans = [list(map(lambda l: l[j:j+m], a[i:i+m])) == b for i, j in prd(range(c), range(c))]
print("Yes" if any(ans) 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):
a,b = map(int,input().split())
li1 = [input() for i in range(a)]
li2 = [input() for i in range(b)]
#print(li1,li2)
for i in range(a-b+1):
    for j in range(a-b+1):
        flag = True
        for k in range(b):
            if li1[i+k][j:j+b] != li2[k]:
                flag = False
                break
        if flag:
            print("Yes")
            
print("No")

a,b = map(int,input().split())
li1 = [input() for i in range(a)]
li2 = [input() for i in range(b)]
#print(li1,li2)
for i in range(a-b+1):
    for j in range(a-b+1):
        flag = True
        for k in range(b):
            if li1[i+k][j:j+b] != li2[k]:
                flag = False
                break
        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 = [int(x) for x in input().split()]
img_a = [input() for _ in range(n)]
img_b = [input() for _ in range(m)]

found = False
for a in range(n - m + 1):
    border = 0
    isok = True
    while isok and not flag:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   # if not substring in string.
                isok = False
                break

        else: # if not loop broken.
            ans = "Yes"
            found = True
            break
    if found:
        break
else: # if not 'found==True' even after last loop, then it means B is not in A.
    ans = "No"
        
print(ans)

import sys
import numpy as np

n, m = map(int, sys.stdin.readline().split())
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(n)], dtype='U1')
B = np.array([list(sys.stdin.readline().rstrip()) for _ in range(m)], dtype='U1')

def main():
    
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            if np.all(A[i:i+m, j:j+m] == B):
                return 'Yes'
    return 'No'

if __name__ == '__main__':
    ans = main()
    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):
import sys
n,m=map(int,input().split())
a=[]
b=[]
for x in range(n):
    a.append(input())
for y in range(m):
    b.append(input())
for z in range(n-m+1):
    k=0
    l=0
    for w in range(n-m+1):
        if (a[w])[z:z+m]==b[k]:
            l+=1
            k+=1
            if l==m:
                print('Yes')
                sys.exit()
        print(a[w][z:z+m])
else:
    print('No')

import sys
n,m=map(int,input().split())
a=[]
b=[]
for x in range(n):
    a.append(input())
for y in range(m):
    b.append(input())
for z in range(n-m+1):
    k=0
    l=0
    for w in range(n-m+1):
        if (a[w])[z:z+m]==b[k]:
            l+=1
            k+=1
            if l==m:
                print('Yes')
                sys.exit()
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 numpy as np

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

bl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M,j:j+M] == B).all():
            bl = True

answer = 'Yes' if bl else 'No'
print(answer)
print(A,B)

import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
ans="No"
bl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M,j:j+M] == B).all():
            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):
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])
for i in range(N):
    for j in range(N):
        check = A[i:i+M,j:j+M]
        print(check)
        if (check == B).all():
            print("Yes")
            exit()
print("No")


import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])
for i in range(N):
    for j in range(N):
        check = A[i:i+M,j:j+M]
        if check.shape != (M,M):
            continue
        if (check==B).all():
            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 i in range(n)]
b = [input() for i in range(m)]


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


print('No')


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


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


print('No')


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=[]
for i in range(n):
  a.append(input())
b=[]
for i in range(m):
  b.append(input())

res=0
for i in range(0,n-m+1):
  keep=0
  for j in range(i,i+m):
    if b[j-i] in a[j]:
      keep+=1
  if keep==m:
    print("Yes")
    res=1
    break
if res=0:
  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())

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


Verdicts: Runtime Error

Accepted