Problem p03804 (python)

Fixed submission:
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
for y in range(n-m+1):
    for z in range(n-m+1):
        count = 0
        for p in range(m):
            if b[p] == a[y+p][z:(z+m)]:
                count += 1
                if count == m:
                    print("Yes")
                    exit()
            else:
                count = 0
print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
for y in range(n-m+1):
    for z in range(n-m):
        count = 0
        for p in range(m):
            if b[p] == a[y+p][z:(z+m)]:
                count += 1
                if count == m:
                    print("Yes")
                    exit()
            else:
                count = 0
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
for y in range(n-m+1):
        #print(y)
    for z in range(n-m+1):
        count = 0
        for p in range(m):
            if b[p] == a[y+p][z:(z+m)]:
                count += 1
                    #print("if")
                    #print(count)
                if count == m:
                    print("Yes")
                    exit()
            else:
                count = 0
                    #print("else")
                    #print(count)
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
count = 0
for x in range (m):
    #print(x)
    for y in range(n-m+1):
        #print(y)
        for z in range(n-m+1):
            for p in range(m):
                if b[x+p] == a[y+p][z:(z+m)]:
                    count += 1
                    #print("elif")
                    #print(count)
                    if count == m:
                        print("Yes")
                        exit()
                else:
                    count = 0
                    #print("else")
                    #print(count)
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
count = 0
for x in range (m):
    #print(x)
    for y in range(n-m+1):
        #print(y)
        for z in range(n-m+1):
            if b[x] == a[y][z:(z+m)]:
                for p in range(m):
                    if b[x+p] == a[y+p][z:(z+m)]:
                        count += 1
                        if count == m-1:
                            print("Yes")
                            exit()
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
count = 0
for x in range (m):
    #print(x)
    for y in range(n-m):
        #print(y)
        for z in range(n-m):
            if b[x] == a[y][z:(z+m)]:
                for p in range(m):
                    if b[x+p] == a[y+p][z:(z+m)]:
                        count += 1
                        if count == m-1:
                            print("Yes")
                            exit()
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
count = 0
for x in range (m):
    #print(x)
    for y in range(n-m):
        #print(y)
        for z in range(n-m):
            if b[x] == a[y][z:(z+m)]:
                for p in range(m):
                    if b[x+p] == a[y+p][z:(z+m)]:
                        count += 1
                        if count == m:
                            print("Yes")
                            exit()
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
count = 0
for x in range (m):
    #print(x)
    for y in range(n):
        #print(y)
        for z in range(n-m):
            #print(z)
            for p in range(m):
                #print(p)
                if b[x+p] == a[y+p][z:(z+m)]:
                    count +=1
                    if count == m:
                        print("Yes")
                        exit()
else:
    print("No")