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 = [[i for i in input()] for _ in range(n)]
b = [[i for i in input()] for _ in range(m)]
com = True
for h in range(n-m+1):
    for w in range(n-m+1):
        for hi in range(m):
            for wi in range(m):
                print(a[h+hi][w+wi], b[hi][wi])
                if a[h+hi][w+wi] != b[hi][wi]:
                    com = False
        if com:
            print("Yes")
            exit()
        else:
            com = True
print("No")

n, m = map(int, input().split())
a = [[i for i in input()] for _ in range(n)]
b = [[i for i in input()] for _ in range(m)]
com = True
for h in range(n-m+1):
    for w in range(n-m+1):
        for hi in range(m):
            for wi in range(m):
                if a[h+hi][w+wi] != b[hi][wi]:
                    com = False
        if com:
            print("Yes")
            exit()
        else:
            com = True
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]=list(map(int,input().split()))
alist=[]
blist=[]
counter=0
for i in range(n):
    alist.append(list(input()))
for i in range(m):
    blist.append(list(input()))
clist=[]
for i in range(n-m):
    for j in range(n-m):
        for k in range(m):
            kari=[]
            for l in range(m):
                kari.append(alist[i][j+l])
            clist.append(kari)
        
        if blist==clist:
            counter=1
            break

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

[n,m]=list(map(int,input().split()))
alist=[]
blist=[]
counter=0
for i in range(n):
    alist.append(list(input()))
for i in range(m):
    blist.append(list(input()))
clist=[]
if n!=m:
    for i in range(n-m):
        for j in range(n-m):
            for k in range(m):
                kari=[]
                for l in range(m):
                    kari.append(alist[i+k][j+l])
                clist.append(kari)
            
            if blist==clist:
                counter=1
                break
            clist=[]

else:
    if alist==blist:
        counter=1

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

Verdicts: Wrong Answer

Accepted
Problem: You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.   A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.   Also, the given images are binary images, and the color of each pixel is either white or black.  In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel.   The image A is given as N strings A_1,...,A_N.   The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).   Similarly, the template image B is given as M strings B_1,...,B_M.   The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.

Submission attempts (in order):
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
lena = len(an[0])
lenb = len(bn[0])
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        print([a[j:diff+j] for a in an[i:diff+i]])
        if [a[j:diff+j] for a in an[i:diff+i]] == bn:
            flag = True
            break
    else:
        continue
    break
print('Yes' if flag else 'No')


n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        if [a[j:m+j] for a in an[i:m+i]] == bn:
            flag = True
print('Yes' if flag 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 = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

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

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


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

for i in range(n-m+1):
    for j in range(n-m+1):
        p = []
        for k in range(m):
            p.append(a[i:i+m][k][j:j+m])
        if p == b:
            exits = True

print('Yes' if exits 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)]
lenB = M**2
flg=False

def check(i, j):
    cnt=0
    for k in range(M):
        for l in range(M):
            if A[i+k][i+j] == B[k][l]:
                cnt += 1
    if cnt==M**2:
        return True
    
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            flg = check(i, j)
            
ans='Yes' if flg else 'No'
print(ans)

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

def check(i, j):
    cnt=0
    for k in range(M):
        for l in range(M):
            if A[i+k][j+l] == B[k][l]:
                cnt += 1
    if cnt==M**2:
        return True
    
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            flg = check(i, j)
            if flg:
                break
    if flg:
        break
            
ans='Yes' if flg else 'No'
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):
N, M = map(int, input().split())

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

def func():
  for i in range(N-M):
    for j in range(N-M):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

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

    



using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  char A[50][50], B[50][50];
  for(int i=0; i<N; ++i) scanf("%s", &A[i][0]);
  for(int i=0; i<M; ++i) scanf("%s", &B[i][0]);
  for(int Ay=0; Ay<=N-M; ++Ay)for(int Ax=0; Ax<=N-M; ++Ax)
      if([&](int x, int y){
        for(int i = 0, j = 0; i < M; i+= j >= M ? j=0,1 :j++,0)
          if(A[x+i][y+j] != B[i][j]) return 0;
        return 1;
      }(Ax, Ay))
      {
        cout << "Yes" << endl;
        return 0;
      }
  cout << "No" << endl;
  return 0;
}


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

f = lambda x: 1 if x == "#" else 0
A = [list(map(f, input())) for _ in range(N)]
B = [list(map(f, input())) for _ in range(M)]

def func():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

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


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.   A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.   Also, the given images are binary images, and the color of each pixel is either white or black.  In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel.   The image A is given as N strings A_1,...,A_N.   The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).   Similarly, the template image B is given as M strings B_1,...,B_M.   The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.

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


n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for i in a:
  for j in b:
    if j not in a:
      print("No")
      exit()
print("Yes")


n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
ans = "Yes"
for i in a:
  for j in b:
    if j not in i:
      ans = "No"
print(ans)


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

f = True
for i in range(n - m + 1):
    for j in range(n - m + 1):
        #check
        for x in range(m):
            for y in range(m):
                if a[x + i][y + j] != b[x][y]:
                    f = False

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


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

ans = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        #check
        f = True
        for x in range(m):
            for y in range(m):
                if a[x + i][y + j] != b[x][y]:
                    f = False

        if f:
            ans = True

if ans:
    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 _ in range(N)]
B=[input() for _ in range(M)]

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


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

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


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

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


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

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


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):
n,m=map(int,input().split())

pic1=[]
pic2=[]

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

for j in range(m):
    pic2.append(input())

#print(pic1)
#print(pic2)

ans="No"

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 pic1[i+k][j+l]!=b[k][l]:
                    flag=False

            if not flag:
                break
        if flag:
            print("Yes")
            exit()

print("No")



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

pic1=[]
pic2=[]

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

for j in range(m):
    pic2.append(input())

#print(pic1)
#print(pic2)

ans="No"

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 pic1[i+k][j+l]!=pic2[k][l]:
                    flag=False

            if not flag:
                break
        if flag:
            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):
h,w = map(int, input().split())
S = ['.' + input() + '.' for _ in range(h)]
S.insert(0,'.'*(w+2))
S.append('.'*(w+2))

for r in range(1, h+1):
    for c in range(1, w+1):
        if S[r][c] == '#':
            print('#', end='')
            continue
        else:
            count = 0
            count += S[r-1][c-1:c+2].count('#')
            count += S[r][c-1:c+2].count('#')
            count += S[r+1][c-1:c+2].count('#')
            print(count, end='')
    print()

import sys

def solve():
    n,m = map(int, sys.stdin.readline().split())
    A = [sys.stdin.readline().rstrip() for _ in range(n)]
    B = [sys.stdin.readline().rstrip() for _ in range(m)]
    for r in range(n-m+1):
        for c in range(n-m+1):
            X = []
            for i,a in enumerate(A[r:r+m]):
                if a[c:c+m] != B[i]:
                    break
            else:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    solve()

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 os

def is_same(a, b):
    for i in range(len(a)):
        if a[i] != b[i]:
            return False
    return True

N, M = list(map(lambda x: int(x), sys.stdin.readline().strip().split(" ")))

A = []
B = []

for _ in range(N):
    A.append(sys.stdin.readline().strip())

for _ in range(M):
    B.append(sys.stdin.readline().strip())

it = N - M + 1

for i in range(it):
    for j in range(it):
        if is_same(A[i:i+M][j:j+M], B):
            print("Yes")
            sys.exit(0)
print("No")

import sys
import os

def is_same(a, b):
    for i in range(len(a)):
        if a[i] != b[i]:
            return False
    return True

N, M = list(map(lambda x: int(x), sys.stdin.readline().strip().split(" ")))

A = []
B = []

for _ in range(N):
    A.append(sys.stdin.readline().strip())

for _ in range(M):
    B.append(sys.stdin.readline().strip())

it = N - M + 1

for i in range(it):
    for j in range(it):
        a = list(map(lambda x: x[j:j+M], A[i:i+M]))
        if is_same(a, B):
            print("Yes")
            sys.exit(0)
print("No")

Verdicts: Wrong Answer

Accepted
Problem: You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.   A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.   Also, the given images are binary images, and the color of each pixel is either white or black.  In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel.   The image A is given as N strings A_1,...,A_N.   The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).   Similarly, the template image B is given as M strings B_1,...,B_M.   The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.

Submission attempts (in order):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
flag = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        if [r[j: j+M] for r in A[i: i+M]] == B:
            flag = True
            break
    if flag:
        break
print('YES' if flag else 'NO')

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
flag = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        if [r[j: j+M] for r in A[i: i+M]] == B:
            flag = True
            break
    if flag:
        break
print('Yes' if flag 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):
#!/usr/bin/env python3

import itertools


def judge(n, m, fig_a, fig_b):
    for dr, dc in itertools.product(range(n - m + 1), repeat=2):
        g = itertools.product(range(m), repeat=2)
        if all(fig_a[r0 + dr][c0 + dc] == fig_b[r0][c0] for r0, c0 in g):
            return True
    return False


def main():
    n, m = (int(x) for x in input().split())
    fig_a = [[c == "#" for c in input()] for _ in range(n)]
    fig_b = [[c == "#" for c in input()] for _ in range(m)]
    print("YES" if judge(n, m, fig_a, fig_b) else "NO")


if __name__ == '__main__':
    main()


#!/usr/bin/env python3

import itertools


def judge(n, m, fig_a, fig_b):
    for dr, dc in itertools.product(range(n - m + 1), repeat=2):
        g = itertools.product(range(m), repeat=2)
        if all(fig_a[r0 + dr][c0 + dc] == fig_b[r0][c0] for r0, c0 in g):
            return True
    return False


def main():
    n, m = (int(x) for x in input().split())
    fig_a = [[c == "#" for c in input()] for _ in range(n)]
    fig_b = [[c == "#" for c in input()] for _ in range(m)]
    print("Yes" if judge(n, m, fig_a, fig_b) else "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())
a=[]
b=[]
c=0
for i in range(n):
    a.append(input())
for j in range(m):
    b.append(input())
for m in range(len(a)):
    if a[m].find(b[0])!=-1:
        print(1)
        for l in range(len(b)-1):
            if m+l+2>len(a):
                break
            if a[m+l+1][(a[m].find(b[0])):(a[m].find(b[0]))+len(b[l+1]):]!=b[l+1]:
                break
            c+=1
            print(c)
        if c==len(b)-1:
            print("Yes")
            exit()
print("No")
            

n,m=map(int,input().split())
a=[]
b=[]
c=0
for i in range(n):
    a.append(input())
for j in range(m):
    b.append(input())
for m in range(len(a)):
    if a[m].find(b[0])!=-1:
        for l in range(len(b)-1):
            if m+l+2>len(a):
                break
            if a[m+l+1][(a[m].find(b[0])):(a[m].find(b[0]))+len(b[l+1]):]!=b[l+1]:
                break
            c+=1
        if c==len(b)-1:
            print("Yes")
            exit()
print("No")
            

Verdicts: Wrong Answer

Accepted
Problem: You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.   A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.   Also, the given images are binary images, and the color of each pixel is either white or black.  In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel.   The image A is given as N strings A_1,...,A_N.   The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).   Similarly, the template image B is given as M strings B_1,...,B_M.   The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.

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

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


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

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


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 i in range(n):
   a.append(input())

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

def func(base, target):
       for i in range(n-m+1):
        check = base[i:i+m]
        for j in range(n-m+1):
            check2 = [line[j:j+m] for line in check]
            if check2 == target:
                return print('Yes')
    return print('No')

func(a,b)


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

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

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

def func(base, target):
   for i in range(n-m+1):
      check = base[i:i+m]
      for j in range(n-m+1):
         check2 = [line[j:j+m] for line in check]
         if check2 == target:
            return print('Yes')
   return print('No')

func(a,b)


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())
x='No'
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
def c(i,j):
  global m,global a, global b
  for k in range(m):
    for l in range(m):
      if b[k][l]!=a[i+k][j+l]:
        return 0
  return 1
for i in range(n-m+1):
  for j in range(n-m+1):
    if c(i,j)==1:
      x='Yes'
      break
print(x)

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

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

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

print('No')


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

for x in range(n-m+1):
    for y in range(n-m+1):
        for i in range(m):
            if b[i] != a[y+i][x:x+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().split())

a_list = []
b_list = []
ans = "No"

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

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

for i in range(n-m+1):
    for j in range(n-m+1):
        match = True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][l+j] != b_list[k][l]:
                    match = False
        if match:
            ans = "True"
            break

print(ans)


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

a_list = []
b_list = []
ans = "No"

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

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

for i in range(n-m+1):
    for j in range(n-m+1):
        match = True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][l+j] != b_list[k][l]:
                    match = False
        if match:
            ans = "Yes"
            break

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.   A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.   Also, the given images are binary images, and the color of each pixel is either white or black.  In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel.   The image A is given as N strings A_1,...,A_N.   The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).   Similarly, the template image B is given as M strings B_1,...,B_M.   The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.

Submission attempts (in order):
N,M = int(input())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
for i in range(N-M+1):
    for k in range(N-M+1):
        p = 1
        for j in range(i,i+M):
            a = A[j][k:k+M]
            b = B[j-i][k+M]
            if a != b:
                p = 0
        ans += 1
print(ans)

N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
flag = 0
for i in range(N-M+1):
    for k in range(N-M+1):
        p = 1
        for j in range(i,i+M):
            a = A[j][k:k+M]
            b = B[j-i]
            if a != b:
                p = 0
                break
        if p == 1:
            flag = 1
        

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):
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
a = [i for i in range(n+1)]
b = [i for i in range(m+1)]
for i in range(1,n+1):
    a[i] = list(input())
for i in range(1,m+1):
    b[i] = list(input())
ans = True

for x in range(1,len(a[1])-len(b[1]) + 1 + 1):
    for y in range(1,len(a)-len(b) + 1 + 1):
        for ax in range(1,m+1):
            for ay in range(m):
                if a[ax][ay] != b[ax][ay]:
                    ans = False
                    break
            else:
                ans = True

print(ans)


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

ans = False

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

if n == m:
    match = 0
    for k in range(m):
        for l in range(m):
            if a[k][l] == b[k][l]:
                match += 1
    if match == m * m:
        ans = True

if ans:
    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):
icase=0
if icase==0:
    n,m=map(int,input().split())
    a=[""]*n
    for i in range(n):
        a[i]=input()
    b=[""]*m
    for i in range(m):
        b[i]=input()
#    n,m=3,2
#    a=['#.#', '.#.', '#.#']
#    b=['#.', '.#']
    for ni in range(n-m+1):
        for nj in range(n-m+1):
            yn=""
            for im in range(m):
                print(a[ni+im][nj:nj+m],b[im])
                if a[ni+im][nj:nj+m]!=b[im]:
                    yn="NG"
                    break
            if yn=="NG":
                continue
            if yn=="":
                yn="OK"
                break
        if yn=="OK":
            break
        else:
            continue
    if yn=="OK":
        print("Yes")
    else:
        print("No")

icase=0
if icase==0:
    n,m=map(int,input().split())
    a=[""]*n
    for i in range(n):
        a[i]=input()
    b=[""]*m
    for i in range(m):
        b[i]=input()
#    n,m=3,2
#    a=['#.#', '.#.', '#.#']
#    b=['#.', '.#']
    for ni in range(n-m+1):
        for nj in range(n-m+1):
            yn=""
            for im in range(m):

                if a[ni+im][nj:nj+m]!=b[im]:
                    yn="NG"
                    break
            if yn=="NG":
                continue
            if yn=="":
                yn="OK"
                break
        if yn=="OK":
            break
        else:
            continue
    if yn=="OK":
        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())
N_ = []
M_ = []
for i in range(N):
  N_.append(input())
  
for i in range(M):
  M_.append(input())

for i in range(N-M+1):
  count = 0
  for j in range(N-M+1):
    for k in range(M):
        if N_[i][j:j+M+1] == M_[k]:
          count = count + 1
    if count == M:
      break
  else:
      continue
  break
if count == M:
  print('Yes')
else:
  print('No')

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

for i in range(N-M+1):
  count = 0
  for j in range(N-M+1):
    for k in range(M):
      if N_[i][j:j+N+1] == M_[k]:
        count = count + 1
    if count == M:
      break
if count == M:
  print('Yes')
else:
  print('No')

N,M = map(int,input().split())
N_ = []
M_ = []
for i in range(N):
  N_.append(list(input()))
  
for i in range(M):
  M_.append(list(input()))

for i in range(N-M+1):
  for j in range(N-M+1):
    count = 0
    for p in range(M):
        for q in range(M):
          if N_[i+q][j+p] == M_[p][q]:
            count = count + 1
    if count == M*M:
      break
  else:
      continue
  break
if count == M*M:
  print('Yes')
else:
  print('No')

Verdicts: Wrong Answer

Wrong Answer

Accepted