Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02831 (python)

Fixed submission:
A , B = input().split(" ")
num1 = int(A)
num2 = int(B)
def gcd(num1,num2):
    if num1%num2 == 0:
        # Base case
        return num2
    else:
        # Iterative case
        return gcd(num2,num1%num2)
lcm = (num1*num2)//gcd(num1,num2)
print(lcm)

Buggy submission (verdict: Runtime Error):
A, B= input().split(" ")
a = int(A)
b = int(B)
list = []
for x in range (1,a):
  if a%x == 0 and b%x == 0 : list.append(x)
maxDiv = max(list)
c = a/maxDiv
print(int(c*b))
Problem p02933 (python)

Fixed submission:
a = int(input())
S = input()

if a >= 3200:
	print(S)
else:
	print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
S = input()

if a >= 3200:
	print(S)
else:
	print(red)
Problem p03207 (python)

Fixed submission:
S = 0
N = int(input())
P=[]
for num in range(N):
	P.append(int(input()))

P.sort(reverse=True, key=int)
P[0] = P[0]//2

for num in range(N):
	S += P[num]

print(S)

Buggy submission (verdict: Runtime Error):
SUM = 0
N = int(input())
for num in range(N):
	P[num] = int(input())

P.sort(reverse=True)
P[0] = P[0]//2

for num in range(N):
	SUM += P[num]

print(SUM)

Buggy submission (verdict: Runtime Error):
SUM = 0
N = input()
for num in range(N):
	P[num] = input()

P.sort(reverse=True)
P[0] = P[0]/2

for num in range(N):
	SUM += P[num]

print(SUM)
Problem p02773 (python)

Fixed submission:
from collections import Counter
import itertools

n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

cnt_words = Counter(s)

mode_v = cnt_words.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, cnt_words.most_common()
)
m = []
for i in it:
    m.append(i[0])
m.sort()
for item in m:
    print(item)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

d = {}

for item in s:
    if item in d.keys():
        d[item] += 1
    else:
        d[item] = 1

start = time.time()
m = [k for k, v in d.items() if v == max(d.values())]
m.sort()
for item in m:
    print(item)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())

if 1<= a <=9 and 1<= b <= 9:
    print(a*b)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n = int(n/i)
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

l = prime_decomposition(n)
l.append(1)
l.sort()
l.reverse()
a = 1
b = 1

for i in range(len(l)):
    if a <= b:
        a *= l[len(l)-1-i]
    else:
        b *= l[len(l)-1-i]

print(a+b-2)
Problem p02773 (python)

Fixed submission:
from collections import Counter

if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    s_most = Counter(s).most_common()

    ans_list = [s_most[0][0]]
    for i in range(1,len(s_most)):
        if s_most[i][1]==s_most[0][1]:
            ans_list.append(s_most[i][0])
        else:
            break

    ans_list.sort()

    for i in range(len(ans_list)):
        print(ans_list[i])

Buggy submission (verdict: Runtime Error):
if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    s_most = s.most_common()

    print(s_most[0])

    for i in range(1,len(s_most)):
        if s_most[i]==s_most[0]:
            print(s_most[i])
        else:
            break

Buggy submission (verdict: Runtime Error):
import pandas as pd

if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    dict_s=dict()
    dict_s["s"]=s
    df_s = pd.DataFrame(dict_s)

    df_s_grp = df_s.groupby("s").size()
    
    max_size = df_s_grp.max()

    ans_list = df_s_grp[df_s_grp==max_size].index

    for i in range(len(ans_list)):
        print(str(ans_list[i]))

Buggy submission (verdict: Runtime Error):
import pandas as pd

if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    dict_s=dict()
    dict_s["s"]=s
    df_s = pd.DataFrame(dict_s)

    df_s_grp = df_s.groupby("s").size()
    
    max_size = df_s_grp.max()

    ans_list = df_s_grp[df_s_grp==max_size].index

    for i in range(len(ans_list)):
        print(ans_list[i])
Problem p02771 (python)

Fixed submission:
if len(set(input().split())) == 2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
print(sys.stdin)
Problem p02912 (python)

Fixed submission:
from heapq import heapify, heappop, heappush, heappushpop

class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)
      
N,M=map(int,input().split())
L = list(map(lambda s:int(s) * -1,input().split()))
#print(L)
pq = PriorityQueue(L)
import math
for _ in range(M):
  m = pq.pop()
  #print(m)
  pq.push(math.ceil(m / 2))
ANS=0
for _ in range(N):
  k = pq.pop()
  #print(k)
  ANS += k
print(ANS * -1)

Buggy submission (verdict: Runtime Error):
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = M - x
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))
Problem p03041 (python)

Fixed submission:
N,K=map(int,input().split())
S=input()
K=K-1
print(S[0:K]+S[K].lower()+S[K+1:])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
print(S[0:K]+S[K].lower()+S[-K:])
Problem p03107 (python)

Fixed submission:
s=input();print(min(s.count("0"), s.count("1"))*2)

Buggy submission (verdict: Runtime Error):
import re
s=input()
m=0
for i in range(len(s)//2):
  dst = re.sub(r'01|10', "", s)
  dst = re.sub(r'000000111111', "", dst)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m

Buggy submission (verdict: Runtime Error):
import re
s=input()
m=0
for i in range(len(s)/2):
  dst = re.sub(r'01|10', "", s)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m)
Problem p03317 (python)

Fixed submission:
N,K=map(int,input().split())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  while True:
    TMP+=(K-1)
    ANS+=1
    if N <= TMP:
      break
print(ANS)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input.split())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  TMP+=(K-1)
  ANS+=1
  if N <= K:
    break
print(ANS)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input.split())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  TMP=(K-1)
  ANS+=1
  if N <= K:
    break
print(ANS)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input.split())
TMP=K
ANS=1
if N =< K:
  ANS=1
else:
  TMP=(K-1)
  ANS+=1
  if N <= K:
    break
print(ANS)
Problem p03042 (python)

Fixed submission:
def main():
  str = input()
  first = str[:2]
  second = str[2:]
  first = change(first)
  second = change(second)
  f_y = 0; s_y = 0;
  f_y = check_y(first)
  s_y = check_y(second)
  if(f_y == 0 and s_y == 0):
    print("AMBIGUOUS")
  elif(f_y == 0 and s_y == 1):
    print("MMYY")
  elif(f_y == 1 and s_y == 0):
    print("YYMM")
  else:
    print("NA")
    
def change(str):
  if(str[0] == "0"):
    return int(str[1])
  else:
    return int(str)
  
def check_y(num):
  if(num == 0 or num > 12):
    return 1
  else:
    return 0
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
def main():
  str = input()
  first = str[:2]
  second = str[2:]
  first = change(first)
  second = change(second)
  f_y = 0; s_y = 0;
  f_y = check_y(first)
  s_y = check_y(second)
  if(f_y == 0 and s_y == 0):
    print("AMBIGUOUS")
  elif(f_y == 0 and s_y == 1):
    print("MMYY")
  elif(f_y == 1 and s_y == 0):
    print("YYMM")
  elise:
    print("NA")
    
def change(str):
  if(str[0] == "0"):
    return int(str[1])
  else:
    return int(str)
  
def check_y(num):
  if(num == 0 or num > 12):
    return 1
  else:
    return 0
  
if __name__ == "__main__":
  main()
Problem p03104 (python)

Fixed submission:
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def prev_multi(num, multi):
    return math.floor(num / multi) * multi

def next_multi(num, multi):
    return math.ceil(num / multi) * multi


def main():
    A, B = MI()
    if B == 0: return 0
    ans = (math.ceil(B/2) - math.floor(A/2)) % 2
    for i in range(1, math.ceil(math.log2(B)) + 1):
        p = 2**i

        na = next_multi(A, p)
        if (na > B):
            d = 0 if (na / p) % 2 else B - A + 1
        else:
            da = 0 if (na / p) % 2 else na - A
            pb = prev_multi(B, p)
            db = 0 if (pb / p) % 2 == 0 else B - pb + 1
            d = da + db
        ans += d % 2 * p

    return ans

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def prev_multi(num, multi):
    return math.floor(num / multi) * multi

def next_multi(num, multi):
    return math.ceil(num / multi) * multi


def main():
    A, B = MI()
    ans = (math.ceil(B/2) - math.floor(A/2)) % 2
    for i in range(1, math.ceil(math.log2(B)) + 1):
        p = 2**i

        na = next_multi(A, p)
        if (na > B):
            d = 0 if (na / p) % 2 else B - A + 1
        else:
            da = 0 if (na / p) % 2 else na - A
            pb = prev_multi(B, p)
            db = 0 if (pb / p) % 2 == 0 else B - pb + 1
            d = da + db
        ans += d % 2 * p

    return ans

if __name__ == "__main__":
    print(main())
Problem p02771 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
vincent = [A,B,C]
vincent1 = list(set(vincent))
if len(vincent1) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A，B，C = list(map(int, input().split()))
vincent = [A,B,C]
vincent1 = set(vincent)
if len(vincent1) == 2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A，B，C = list(map(str, input().split()))
vincent = [A,B,C]
vincent1 = list(set(vincent))
if len(vincent1) == 2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A，B，C=list(map(int,input().split()))
vincent=[A,B,C]
vincent1=list(set(vincent))
if len(vincent1)==2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A，B，C = list(map(int, input().split()))
vincent = [A,B,C]
vincent1 = list(set(vincent))
if len(vincent1) == 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A，B，C = list(map(int, input().split()))
vincent = [A,B,C]
vincent1 = list(set(vincent))
if len(vincent1) == 2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A，B，C = list(map(int, input().split()))
vincent = str(A) + str(B) + str(C)
vincent1 = list(set(vincent))
if len(vincent1) == 2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A，B，C = list(map(str, input().split()))
vincent = A + B + C
vincent1 = list(set(vincent))
if len(vincent1) == 2:
  print('Yes')
else:
  print('No')
Problem p02835 (python)

Fixed submission:
[A1, A2, A3] = list(map(int,input().split()))
if A1 + A2 + A3 >= 22:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
A1 = int(input())
A2 = int(input())
A3 = int(input())
if A1 + A2 + A3 >= 22:
    print("burst")
else:
    print("win")
Problem p02987 (python)

Fixed submission:
S = str(input())
S1 = list(set(S))
if len(S1) == 2 and S.count(S1[0]) == 2 and S.count(S1[1]) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())
S1 = set(S)
if len(S1) == 2 and S.count(S1[0]) == 2 and S.count(S1[1]) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())
S1 = set(S)
if len(S1) == 2 and S.count(S1[0]) == 2 and S.count(S1[1]):
    print("Yes")
else:
    print("No")
Problem p03011 (python)

Fixed submission:
P, Q, R = list(map(int, input().split()))
x = [P, Q, R]
maxvalue = 0
for i in range(len(x)):
    if x[i] > maxvalue:
        maxvalue = x[i]
print(P + Q + R - maxvalue)

Buggy submission (verdict: Runtime Error):
P, Q, R = list(map(int, input().split()))
x = [P, Q, R]
maxvalue = 0
for i in x:
    if x[i] > maxvalue:
        maxvalue = x[i]
print(P + Q + R - maxvalue)
Problem p03041 (python)

Fixed submission:
N, K = list(map(int, input().split()))
S = str(input())
m = chr(ord(S[K-1]) + 32)
print(S[:K-1] + m + S[K:])

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
S = str(input())
m = chr(ord(S[K-1]) - 32)
print(N[:m] + m + N[m+1:])

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
S = str(input())
m = chr(ord(S[K]) - 32)
print(N[:m] + m + N[m+1:])
Problem p02766 (python)

Fixed submission:
n, r = map(int, input().split())
count = 0
if n == 1:
    print(1)
else:
    while n // r >= r:
        count += 1
        n = n // r
    print(count + 2)

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
count = 0
if n = 1:
    print(1)
else:
    while n // r >= r:
        count += 1
        n = n // r
    print(count + 2)
Problem p02785 (python)

Fixed submission:
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
m_life.sort()
count = 0
for i in range(len(m_life)-hisatu):
    count += m_life[i]
print(count)

Buggy submission (verdict: Runtime Error):
def testA():
    max_num = 0
    for i in range(10 ** 8):
        if max_num < i:
            max_num = i
    return max_num
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
count = 0
if hisatu >= len(m_life):
    print(0)
else:
    while hisatu > 0:
        m_life.remove(testA(m_life))
        hisatu -= 1
    for i in m_life:
        count += i
    print(count)

Buggy submission (verdict: Runtime Error):
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
count = 0
if hisatu >= len(m_life):
    print(0)
else:
    for range(hisatu):
        m_life.remove(max(m_life))
    for i in m_life:
        count += i
    print(count)
Problem p02831 (python)

Fixed submission:
import fractions

a, b = map(int, input().split())
c = fractions.gcd(a, b)
print(a*b//c)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
c = math.gcd(a, b)
print(a*b//c)
Problem p03286 (python)

Fixed submission:
n=int(input())
result=''
if n==0:
    result='0'
while True:
    if n==0:
        break
    if n%2==0:
        n=n/(-2)
        result='0'+result
    else:
        n=(n-1)/(-2)
        result='1'+result
print(int(result))

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==0:
    result=0
result=''
while True:
    if n==0:
        break
    if n%2==0:
        n=n/(-2)
        result='0'+result
    else:
        n=(n-1)/(-2)
        result='1'+result
print(int(result))

Buggy submission (verdict: Runtime Error):
n=int(input())
result=''
while True:
    if n==0:
        break
    if n%2==0:
        n=n/(-2)
        result='0'+result
    else:
        n=(n-1)/(-2)
        result='1'+result
print(int(result))
Problem p03426 (python)

Fixed submission:
h,w,d=(int(i) for i in input().split())
num=[None for i in range(h*w)]
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        num[a[j]-1]=(i,j)
numm=[None for i in range(h*w)]
for i in range(d):
    numm[i]=0
for i in range(d,h*w):
    numm[i]=numm[i-d]+abs(num[i][0]-num[i-d][0])+abs(num[i][1]-num[i-d][1])

q=int(input())
for i in range(q):
    l,r=list(map(int,input().split()))
    print(numm[r-1]-numm[l-1])

Buggy submission (verdict: Runtime Error):
h,w,d=(int(i) for i in input().split())
num=[None for i in range(h*w)]
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        num[a[j]-1]=(i,j)
numm=[None for i in range(h*w)]
for i in range(d):
    numm[i]=0
for i in range(d,h*w):
    numm[i]=numm[i-d]+abs(num[i-1][0]-num[i-d-1][0])+abs(num[i-1][1]-num[i-d-1][1])

q=int(input())
for i in range(q):
    l,r=list(map(int,input().split()))
    print(numm[r]-numm[l])

Buggy submission (verdict: Runtime Error):
h,w,d=(int(i) for i in input().split())
num=[None for i in range(h*w)]
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        num[a[j]-1]=(i,j)
numm=[None for i in range(h*w)]
for i in range(h*w-d):
    numm[i]=abs(num[i+d-1][0]-num[i-1][0])+abs(num[i+d-1][1]-num[i-1][1])
q=int(input())
for i in range(q):
    l,r=list(map(int,input().split()))
    result=0
    while l!=r:
        result+=numm[l]
        l+=d
    print(result)
Problem p02785 (python)

Fixed submission:
n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h,reverse=True)
if n>=k:
	for i in range(k):
		H[i]=0
	print(sum(H))
else: 
	print(0)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h,reverse=True)
for i in range(k):
	H[i]=0
print(sum(H))

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h)
for i in range(k):
 H[n-k+1]=0
print(sum(H))
Problem p02766 (python)

Fixed submission:
n,k = map(int,(input().split(" ")))

import math
a = (int(math.ceil(math.log(n)/math.log(k) )))
if a==0:
  print(1)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
n,k = map(int,(input().split(" ")))

import math
a = (int(math.ceil(math.log(n)/math.log(k) )))
if a==0:
  print(1)
else
  print(a)

Buggy submission (verdict: Runtime Error):
n,k = int(input().split(" "))
import math
print(int(math.ceil(math.log(n)/math.log(k) )))
Problem p03286 (python)

Fixed submission:
n = int(input())
ans=""
while n!=0:
  if n%2==0:
    ans = "0"+ans
  else:
    n-=1
    ans = "1"+ans
  n//=-2  

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

Buggy submission (verdict: Runtime Error):
n = int(input())
ans=""
while n!=0:
  if n%2==0:
    ans = "0"+ans
  else
    n-=1
    ans = "1"+ans
  n//=-2  

if n==0:
  print("0")
else
  print(ans)
Problem p02831 (python)

Fixed submission:
import fractions

a, b = map(int, input().split())

def lcm(x, y):
    return (x * y)//fractions.gcd(x, y)

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
print(lcm(a,b))
Problem p02912 (python)

Fixed submission:
# 最大値を見つけ、それを２で割るをチケットがなくなるまで繰り返す
# 普通にやると、最大値の選定でO(n)、それをチケット数分だけ繰り返すのでO(n*m)。
# 間に合わないので、優先度付きキューを用いる
import math
import heapq

n, m = map(int, input().split())
a = [0] * n
a = list(map(int, input().split()))

a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
    tmp = heapq.heappop(a) * (-1)
    tmp = math.floor(tmp / 2) * (-1)
    heapq.heappush(a, tmp)

print(sum(list(map(lambda x: x*(-1), a))))

Buggy submission (verdict: Runtime Error):
# 最大値を見つけ、それを２で割るをチケットがなくなるまで繰り返す
# 普通にやると、最大値の選定でO(n)、それをチケット数分だけ繰り返すのでO(n*m)。
# 間に合わないので、優先度付きキューを用いる
import math

n, m = map(int, input().split())
a = [0] * n
a = list(map(int, input().split()))

a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
    tmp = heapq.heappop(a) * (-1)
    tmp = math.floor(tmp / 2) * (-1)
    heapq.heappush(a, tmp)

print(sum(list(map(lambda x: x*(-1), a))))
Problem p03804 (python)

Fixed submission:
import numpy as np
N, M = map(int, input().split())

A = []
for i in range(N):
    tmp = input()
    A.append([0 if s=="." else 1 for s in tmp])
B = []
for i in range(M):
    tmp = input()
    B.append([0 if s=="." else 1 for s in tmp])
    
A = np.array(A)
B = np.array(B)

def is_match(a, b):
    return (a==b).all()
flag = False
for i in range(N):
    for j in range(N):
        x_left = i
        x_right = i + M
        y_up = j
        y_under = j + M
        if x_right > N or y_under > N:
            continue
        if is_match(B, A[x_left:x_right, y_up:y_under]):
            flag = True
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = []
for i in range(N):
    tmp = input()
    A.append([0 if s=="." else 1 for s in tmp])
B = []
for i in range(M):
    tmp = input()
    B.append([0 if s=="." else 1 for s in tmp])
    
A = np.array(A)
B = np.array(B)

def is_match(a, b):
    return (a==b).all()
flag = False
for i in range(N):
    for j in range(N):
        x_left = i
        x_right = i + M
        y_up = j
        y_under = j + M
        if x_right >= N or y_under >= N:
            continue
        if is_match(B, A[x_left:x_right, y_up:y_under]):
            flag = True
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
print(A)
# 全探索で間に合う？
def is_match(a, b):
    return (a==b).all()
flag = False
for i in range(N):
    for j in range(N):
        x_left = i
        x_right = i + M
        y_up = j
        y_under = j + M
        if x_right >= N or y_under >= N:
            continue
        if is_match(B, A[x_left:x_right, y_up:y_under]):
            flag = True
if flag:
    print("Yes")
else:
    print("No")
Problem p03805 (python)

Fixed submission:
N, M = list(map(int, input().split(" ")))

graph = [list() for i in range(N+1)]

for i in range(M):
    a, b = list(map(int, input().split(" ")))
    graph[a].append(b)
    graph[b].append(a)
    
def DFS(node, prev, visited):
    visited.append(node)
    if len(visited) == N:
        return 1
    
    res = 0
    for edge in graph[node]:
        if edge == prev:
            continue
        elif edge in visited:
            continue
        res += DFS(edge, prev, visited[:])
        
    return res

print(DFS(1, 0, []))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split(" ")))

graph = [list() for i in range(N+1)]

for i in range(M):
    a, b = list(map(int, input().split(" ")))
    graph[a].append(b)
    graph[b].append(a)
    
def DFS(node, prev, visited):
    visited.append(node)
    if len(visited) == N:
        return 1
    
    res = 0
    for edge in graph[node]:
        if edge == prev:
            continue
        elif edge in visited:
            continue
        res += dfs(edge, node, visited)
        
    return res

print(DFS(1, 0, []))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split(" ")))

graph = [list() for i in range(N+1)]

for i in range(M):
    a, b = list(map(int, input().split(" ")))
    graph[a].append(b)
    graph[b].append(a)
    
def DFS(node, prev, visited):
    visited.append(node)
    if len(visited) == N:
        return 1
    
    res = 0
    for edge in graph[node]:
        if edge == prev:
            continue
        elif edge in visited:
            continue
        res += dfs(edge, node, visited)
        
    return res

print(DFS(1, 0, []))