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

Fixed submission:
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
c = []
for i in range(h):
  a = input()
  c.append(a)
  
from collections import deque

d = [[-1] * w for i in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

que = deque([])
for i in range(h):
  for j in range(w):
    if c[i][j] == '#':
      que.append((i,j,0))
      d[i][j] = 0

ans = 0
while que:
  p = que.popleft()
  for i in range(4):
      nw = p[1] + dx[i]
      nh = p[0] + dy[i]
      if 0 <= nw < w and 0 <= nh < h and d[nh][nw]==-1:
          que.append((nh,nw,p[2]+1))
          d[nh][nw] = p[2]+1
          ans = max(ans,p[2]+1)

print(ans)

Buggy submission (verdict: Runtime Error):
h,w,n = map(int,input().split())
r,c = map(int,input().split())
sd = {'L':0,'R':0,'U':0,'D':0}
td = {'L':0,'R':0,'U':0,'D':0}
s = input()
t = input()
ans = 'YES'
for i in range(n):
  sd[s[i]] += 1
  if max(1,r-td['U'])+sd['D'] > h or min(h,r+td['D'])-sd['U'] < 1 or max(1,c-td['L'])+sd['R'] > w or min(w,c+td['R'])-sd['L'] < 1:
    ans = 'NO'
    break
  if t[i] == 'L' and s[i] == 'R':
    sd['R'] -= 1
  if t[i] == 'R' and s[i] == 'L':
    sd['L'] -= 1
  if t[i] == 'D' and s[i] == 'U':
    sd['U'] -= 1
  if t[i] == 'U' and s[i] == 'D':
    sd['D'] -= 1
  else:
    td[t[i]] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
h,w,n = map(int,input().split())
r,c = map(int,input().split())
sd = {'L':0,'R':0,'U':0,'D':0}
td = {'L':0,'R':0,'U':0,'D':0}
s = input()
t = input()
ans = 'YES'
for i in range(n):
  sd[s[i]] += 1
  if max(1,r-td['D'])+sd['U'] > h or min(h,r+td['U'])-sd['D'] < 1 or max(1,c-td['L'])+sd['R'] > w or min(w,c+td['R'])-sd['L'] < 1:
    ans = 'NO'
    break
  td[t[i]] += 1
print(ans)
Problem p03253 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
  
n,m = map(int,input().split())
chk = factorization(m)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) 
  
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

mod = 10**9+7
ans = 1
for i in chk:
  ans *= comb(i[1]+n-1,i[1],mod)
  ans %= mod
if m == 1:
  ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
  
n,m = map(int,input().split())
chk = factorization(m)
#print(chk)
def make_array_for_comb(N, mod=10**9+7):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod=10**9+7):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

mod = 10**9+7
fact, fact_inv = make_array_for_comb(n,mod)
ans = 1
for i in chk:
  ans *= comb(i[1]+n-1,i[1],mod)
  ans %= mod
if m == 1:
  ans = 1
print(ans)
Problem p03465 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
b &= 2**(s+1)-2**((s-1)//2)
while True:
  t = b&(-b)
  #print(i,t,b)
  if (s+1)//2 <= t.bit_length()-1 <= s:
    print(t.bit_length()-1)
    break
  b ^= t

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 0
for i in a:
  b |= b<<i
  b |= 1<<i
  
def all_bit_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8) 
    x = x + (x >> 16) 
    x = x + (x >> 32) 
    return x & 0x0000007f
  

l = all_bit_count(b)
for i in range((l+1)//2):
  t = b&(-b)
  b ^= t
  
print(t.bit_length()-1)
Problem p03804 (python)

Fixed submission:
n,m = [int(i) for i in input().split()]
a = []
for i in range(n):
	array = input()
	a.append(array)
b = []
for i in range(m):
	line = input()
	b.append(line)
ans = 'No'
for i in range (n-m+1):
	for j in range(n-m+1):
		Ans = ans
		if a[i][j:j+m] == b[0]:
			#print(i,j)
			for k in range(m):
				if not a[i+k][j:j+m] == b[k]:
					ans = Ans
					break
				else:
					ans = 'Yes'
					#print(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = [int(i) for i in input().split()]
a = []
for i in range(n):
	array = input()
	a.append(array)
b = []
for i in range(m):
	line = input()
	b.append(line)
ans 'No'
for i in range (n-m+1):
	for j in range(n-m+1):
		Ans = ans
		if a[i][j:j+m] == b[0]:
			print(i,j)
			for k in range(m):
				if not a[i+k][j:j+m] == b[k]:
					ans = Ans
					continue
				else:
					ans = 'Yes'
					print(ans)
					break
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
a = []
for i in range(N):
	array = input()
	a.append(array)
b = []
for i in range(M):
	line = input()
	b.append(line)
for i in range(N-M):
	for j in range(N-M):
		ans = 'Yes'
		for n in range(M):
			for m in range(M):
				if a[i+n][j+m] == b[n][m]:
					pass
					#print(i,j,n,m)
				else:
					ans = 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
a = []
for i in range(N):
	array = input()
	a.append(array)
b = []
for i in range(M):
	line = input()
	b.append(line)
for i in range(N-M):
	for j in range(N-M):
		ans = 'Yes'
		for n in range(M):
			for m in range(M):
				if a[i+n][j+m] == b[n][m]:
					pass
					print(i,j,n,m)
				else:
					ans = 'No'
print(ans)
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
    c=i
    if i%k==0:
        print("OK")
        break
if c%k!=0:
    print("NG")

Buggy submission (verdict: Runtime Error):
k=int(input())
a,b=map(int,input().split())
for i in range(a,b):
    c=i
    if i%k==0:
        print("OK")
        break
if c%k!=0:
    print("NG")
if k==1:
    print("OK")
Problem p02819 (python)

Fixed submission:
X=int(input())
while True:
    for x in range(2,X):
        if X%x==0:
            break
    else:
        print(X)
        break
    X+=1

Buggy submission (verdict: Runtime Error):
X=int(input())
while True:
    for x in range(2,X):
        if X%x==0:
            break
    else:
        print(x)
        break
    X+=1
Problem p02836 (python)

Fixed submission:
s=input()
count=0
for i in range(len(s)//2):
    if s[i]!=s[-i-1]:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
S=input()
count=0
for i in range(len(s)//2):
    if s[i]!=s[-(i-1)]:
        count+=1
print(count)
Problem p02881 (python)

Fixed submission:
n=int(input())
move=10**12
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        move=min(move,n//i+i-2)
print(move)

Buggy submission (verdict: Runtime Error):
n=int(input())
L=[]
for i in range(int(n**0.5)+1):
    for j in range((n)):
        if i*j==n:
            L.append(i+j-2)
print(min(L))

Buggy submission (verdict: Runtime Error):
n=int(input())
L=[]
for i in range(n):
    for j in range((n)):
        if i*j==n:
            L.append(i+j-2)
print(min(L))
Problem p02831 (python)

Fixed submission:

def gcd(a, b):
    while b != 0:
        t = b
        b = a % b
        a = t
    return a

def lcm(a, b):
    return abs(a*b) / gcd(a, b)

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

print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
from math import gcd

def lcm(a, b):
    return abs(a*b) / gcd(a, b)

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

print(int(lcm(a, b)))
Problem p02629 (python)

Fixed submission:
N = int(input())
alphabet = [chr(i) for i in range(97, 97+26)]

n = 1
s = 26
for i in range(1,12):
    if N <= s:
        n = i
        break
    else:
        s += 26**(i+1)
        
s = 0
for i in range(1,n):
    s += 26**i
    
N = N - s - 1
if N == 0:
    Ans = ""
    for _ in range(n):
        Ans += "a"
else:
    L = [0 for _ in range(n)]
    i = 1
    while N > 0:
        L[-i] = N%26
        N = N//26
        i +=1
    
    Ans = ""
    for x in L:
        Ans += alphabet[x]
print(Ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
alphabet = [chr(i) for i in range(97, 97+26)]

n = 1
s = 26
for i in range(1,12):
    if N <= s:
        n = i
        break
    else:
        s += 26**(i+1)
        
s = 0
for i in range(1,n):
    s += 26**i
    
N = N - s - 1
if N == 0:
    Ans = ""
    for _ in range(n):
        Ans += "a"
else:
    while N > 0:
        L.append(N%26)
        N = N//26
    
    Ans = ""
    for x in reversed(L):
        Ans += alphabet[x]
print(Ans)
Problem p03013 (python)

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

a = [int(input())-1 for _ in range(M)]
T = 1
for i in range(M-1):
    if a[i]+1 == a[i+1]:
        T = 0
        break
if T == 0:
    print(0)
else:
    if N == 1:
        if M==0:
            print(1)
        else:
            print(0)
    else:
        L = [0 for _ in range(N)]
        for i in range(M):
            L[a[i]] = -1
        if L[0] == -1:
            L[1] = 1
        else:
            L[0] = 1
            if L[1] != -1:
                L[1] = 2
        for i in range(2,N):
            if L[i] != -1:
                if L[i-2] == -1:
                    L[i] = L[i-1]%1000000007
                elif L[i-1] == -1:
                    L[i] = L[i-2]%1000000007
                else:
                    L[i] = (L[i-1]+L[i-2])%1000000007
        print(L[-1])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]

T = 1
for i in range(M-1):
    if a[i]+1==a[i+1]:
        T = 0
        break
if T == 0:
    print(0)
else:
    if N==1:
        print(1)
    elif N == 2:
        print(2)
    else:
        L = [0 for _ in range(N)]
        if 0 in a:
            L[0] = 0
            L[1] = 1 
        else:
            L[0] = 1
            if 1 in a:
                L[1] = 0
            else:
                L[1] = 2
        for i in range(2,N):
            S = i-2 in a
            T = i-1 in a
            U = i in a
            if U:
                L[i] = 0
            elif T:
                L[i] = L[i-2]%1000000007
            else:
                if S:
                    L[i] = L[i-1]%1000000007
                else:
                    L[i] = (L[i-1]+L[i-2])%1000000007
    print(L[-1])
Problem p03327 (python)

Fixed submission:
N = input()

if len(N)<=3:
  print("ABC")
else:
  print("ABD")

Buggy submission (verdict: Runtime Error):
N = input()

if len(N)<=3:
  print("ABC")
else:
  print("ABD)
Problem p02753 (python)

Fixed submission:
s = input()

if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()

if s == "AAA" or s -- "BBB":
    print("No")
else:
    print("Yes")
Problem p02766 (python)

Fixed submission:
import math
 
s = input().split()
n, k = int(s[0]), int(s[1])
 
ans = int(math.log(n, k) + 1.0)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

s = input().split()
n, k = int(s[0]), int(s[1])

ans = int(fractions.log(n, k) + 1.0)
print(ans)
Problem p02819 (python)

Fixed submission:
n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(n**0.5) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)

Buggy submission (verdict: Runtime Error):
# import math
import fractions

n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(fractions.sqrt(n)) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
l = [1, 2, 3]
l.remove(a)
l.remove(b)
print(l[0])

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
l = [1, 2, 3]
l.remove(a)
l.remove(b)
print(l[0])
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)
f2=a*b//f
print(f2)

Buggy submission (verdict: Runtime Error):
import math

s = input().split()
a, b = int(s[0]), int(s[1])


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


print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

s = input().split()
a, b = int(s[0]), int(s[1])


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


print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

s = input().split()
a, b = int(s[0]), int(s[1])


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


print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

s = input().split()
a, b = int(s[0]), int(s[1])


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


print(lcm(a, b))
Problem p02623 (python)

Fixed submission:
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M,K = LI()
A = LI()
B = LI()
accumulate_A = [0]+list(itertools.accumulate(A))
accumulate_B = [0]+list(itertools.accumulate(B))
ans,j = 0,M
for i in range(N+1):
    if accumulate_A[i]>K:
        break
    while accumulate_A[i]+accumulate_B[j]>K:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M,K = LI()
A = LI()
B = LI()
accumulate_A = list(itertools.accumulate(A))
accumulate_B = list(itertools.accumulate(B))
ans,j = 0,M-1
for i in range(N):
    if accumulate_A[i]>K:
        break
    while accumulate_A[i]+accumulate_B[j]>K:
        j -= 1
    ans = max(ans,i+j+2)
print(ans)
Problem p02629 (python)

Fixed submission:
import string,sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
abc = string.ascii_lowercase
def main(N):
    if N<=26:
        return abc[N-1]
    if N%26==0:
        return main(N//26-1)+abc[-1]
    return main(N//26)+abc[N%26-1]
print(main(N))

Buggy submission (verdict: Runtime Error):
import string,sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
abc = string.ascii_lowercase
def main(N):
    if N<=26:
        return abc[N-1]
    if N%26==0:
        return abc[N//26-2]+'z'
    return main(N//26)+abc[N%26-1]
print(main(N))
Problem p02699 (python)

Fixed submission:
def LI(): return list(map(int,input().split()))
S,W = LI()
print('unsafe' if W>=S else 'safe')

Buggy submission (verdict: Runtime Error):
import itertools
S = input()
anskouho_set = set()
mod3 =[]
for x in S:
    mod3.append(int(x)%3)
mod3_accumulate = [x%3 for x in list(itertools.accumulate(mod3))]
ans = 0
for i in range(3):
    temp = []
    if i==0:
        temp.append(0)
    for j,x in enumerate(mod3_accumulate):
        if x==i:
            temp.append(j)
    for k in range(len(temp)):
        for l in range(k+1,len(temp)):
            if temp[l]-temp[k]>=4:
                anskouho_set.add((temp[k],temp[l]))
            if temp[l]+1-temp[k]>=4:
                anskouho_set.add((temp[k]+1,temp[l]))
for x in anskouho_set:
    if int(S[x[0]:x[1]+1])%2019==0:
        ans += 1
print(ans)
Problem p02729 (python)

Fixed submission:
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,M = LI()
if N <= 1:
    n = 0
else:
    n = math.factorial(N)//((math.factorial(N-2))*(math.factorial(2)))
if M <= 1:
    m = 0
else:
    m = math.factorial(M)//((math.factorial(M-2))*(math.factorial(2)))
print(n+m)

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
A = LI()
_123 = [0]*N
_123count = [0]*N
for x in A:
    _123[x-1] += 1
_123copy = copy.copy(_123)
_123copy.sort(reverse=True)
_count = {}
for i,x in enumerate(_123copy):
    if x==0:
        break
    if x==1:
        _123count[i] = 0
    elif i!=0 and _123copy[i]==_123copy[i-1]:
        _123count[i] = _123count[i-1]
    else:
        _123count[i] = math.factorial(x)//((math.factorial(x-2))*(math.factorial(2)))
        _count[x] = _123count[i]
_sum = sum(_123count)
for x in A:
    temp = _123[x-1]-1
    if temp<=0:
        print(_sum)
    elif temp==1:
        print(_sum-1)
    else:
        if (temp+1) in _count:
            tempminus = _count[temp+1]
        else:
            tempminus = math.factorial(temp+1)//((math.factorial(temp-1))*(math.factorial(2)))
            _count[temp+1] = tempminus
        if (temp) in _count:
            tempplus = _count[temp]
        else:
            tempplus = math.factorial(temp)//((math.factorial(temp-2))*(math.factorial(2)))
            _count[temp] = tempplus
        print(_sum-tempminus+tempplus)
Problem p02819 (python)

Fixed submission:
import math
def main(X):
    if X <= 3:
        return X
    SosuuFlg = False
    while SosuuFlg == False:
        max_search = int(math.sqrt(X)+1) if math.sqrt(X) % 1 == 0 else math.ceil(math.sqrt(X))
        for i in range(2, max_search):
            if X % i == 0:
                break
        else:
            SosuuFlg = True
            return X
        X += 1
        
X = int(input())
print(main(X))

Buggy submission (verdict: Runtime Error):
import math
def main(X):
    max_search = min(101, (math.sqrt(X)+1 if math.sqrt(X) % 1 == 0 else math.ceil(math.sqrt(X))))
    if X <= 3:
        return X
    SosuuFlg = False
    while SosuuFlg == False:
        for i in range(2, max_search):
            if X % i == 0:
                break
        else:
            SosuuFlg = True
            return X
        X += 1
        
X = int(input())
print(main(X))
Problem p02835 (python)

Fixed submission:
list1 = [int(e) for e in input().split()]
sum = 0
for num in list1:
    sum += num

if sum >= 22:
    print ('bust')
else:
    print ('win')

Buggy submission (verdict: Runtime Error):
list1 = [int(e) for e in input().split()]
sum = 0
for num in list1:
    sum += num

if sum >= 22:
    print 'bust'
else:
    print 'win'
Problem p02836 (python)

Fixed submission:
#lang:reverse.py

result = 0
str = input()
#文字数
str_length = len(str)
rev_str = str[::-1]
count = 0

if str_length % 2 == 1:
    count = (str_length -1)/2
else:
    count = str_length / 2


for i in range(int(count)):
    if str[i] != rev_str[i] :
        result = result + 1

print(result)

Buggy submission (verdict: Runtime Error):
#lang:reverse.py

result = 0
str = input()
#文字数
str_length = len(str)
rev_str = str[::-1]
count = 0

if str_length % 2 == 1:
    count = (str_length -1)/2
else:
    count = str_length / 2


for i in range(count):
    if str[i] != rev_str[i] :
        result = result + 1

print(result)

Buggy submission (verdict: Runtime Error):
lang:reverse.py
result = 0
str = input()
--文字数
str_length = len(str)
rev_str = str[::-1]
count = 0

if str_length % 2 == 1:
    count = (str_length -1)/2
else:
    count = str_length / 2


for i in range(count):
    if str[i] != rev_str[i] :
        result = result + 1

print(result)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >=3200:
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Buggy submission (verdict: Runtime Error):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in range(N-1)]
px = [LI() for _ in range(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in range(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])
Problem p03013 (python)

Fixed submission:
def main(N,M,a):
    dp = [-1]*N
    dp[0] = 1
    if N != 1:
        dp[1] = 2
    for i in a:
        if i == 1:
            dp[0] = 0
            dp[1] = 1
        else:
            dp[i-1] = 0
    for i in range(2,N):
        if dp[i] != 0:
            dp[i] = dp[i-1] + dp[i-2]
    return dp[-1]
N,M = map(int, input().split())
a = list(int(input()) for i in range(M))

print(main(N,M,a) % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
a = set([I() for _ in range(M)])
dp = [0]*(N+1) #1_indexed
dp[1] = 0 if 1 in a else 1
dp[2] = 0 if 2 in a else (1+dp[1])
for i in range(3,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
a = set([I() for _ in range(M)])
dp = [0]*(N+1) #1_indexed
dp[1] = 0 if 1 in a else 1
dp[2] = 0 if 2 in a else 1 +dp[1]
for i in range(3,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
print(dp[-1])

Buggy submission (verdict: Runtime Error):
def main(N,M,a):
    dp = [-1]*N
    dp[0] = 1
    dp[1] = 2
    for i in a:
        if i == 1:
            dp[0] = 0
            dp[1] = 1
        else:
            dp[i-1] = 0
    for i in range(2,N):
        if dp[i] != 0:
            dp[i] = dp[i-1] + dp[i-2]
    return dp[-1]
N,M = map(int, input().split())
a = list(int(input()) for i in range(M))

print(main(N,M,a) % 1000000007)
Problem p03250 (python)

Fixed submission:
ABC = list(map(int,input().split()))
ABC.sort(reverse= True)
print(int(str(ABC[0])+str(ABC[1])) +ABC[2])

Buggy submission (verdict: Runtime Error):
import collections,math,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ans = 1
def prime_factor(num):
    prime_factor = collections.defaultdict(int)
    for i in range(2,int(num**0.5)+1):
        while num%i==0:
            prime_factor[i] += 1
            num //= i
    if num>1:
        prime_factor[num]=1
    return prime_factor
for v in prime_factor(M).values():
    ans *= math.factorial(v+N-1)//math.factorial(v)//math.factorial(N-1)
    ans %= 10**9+7
print(ans)