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

Fixed submission:
A = []
N,M = list(map(int,input().split()))
if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print("1" + "0"*(N-1))
        exit()
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    try:
        if N == len(str_i):
            for j,k in A:
                if str_i[int(j)-1] == k:
                    pass
                else:
                    break
            if str_i[int(j)-1] == k:
                print(i)
                exit()
    except IndexError:
        print("-1")
        exit()
print("-1")

Buggy submission (verdict: Runtime Error):
A = []
N,M = list(map(int,input().split()))
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    try:
        if N == len(str_i):
            for j,k in A:
                if str_i[int(j)-1] == k:
                    pass
                else:
                    break
            if str_i[int(j)-1] == k:
                print(i)
                exit()
    except IndexError:
        print("-1")
        exit()
print("-1")

Buggy submission (verdict: Runtime Error):
A = []
N,M = list(map(int,input().split()))
for i in range(M):
    A.append(list(input().split()))
for i in range(10 ** N):
    str_i = str(i)
    if N == len(str_i):
        for j,k in A:
            if str_i[int(j)-1] == k:
                pass
            else:
                break
        if str_i[int(j)-1] == k:
            print(i)
            exit()
print("-1")
Problem p02780 (python)

Fixed submission:
N,M=list(map(int,input().split()))
l_n=list(map(int,input().split()))
k=[]
j=0
for i in range(1,1001):
   j+=i
   k.append(j/i)
l_n=[k[l_n[i]-1] for i in range(N)]
ans=sum(l_n[0:M])
sum_n=ans
for i in range(N-M):
   sum_n+=l_n[i+M]
   sum_n-=l_n[i]
   ans=max(ans,sum_n)
print(ans)

Buggy submission (verdict: Runtime Error):
N,V = list(map(int,input().split()))
from collections import deque
listA = list(map(int,input().split()))
listB = deque()
max_number = 0
total = 0
for i in range(N-V+1):
    listB.append(sum(listA[i:i+V]))
max_number = listB.index(max(listB))
for i in listA[max_number:max_number+V]:
    total += (1+i) * (i/2) / i
print(total)

Buggy submission (verdict: Runtime Error):
B,C = list(map(int,input().split()))
n_l = list(map(int,input().split()))
dic = {1:1,2:1.5,3:2,4:2.5,5:3,6:3.5}
A = []
total = 0
for i in range(B-C+1):
    A.append(sum(n_l[i:i+C]))
place = A.index(max(A))
for i in range(C):
    total += dic[n_l[place+i]]
print(total)
Problem p02823 (python)

Fixed submission:
N,A,B = list(map(int,input().split(" ")))
C = B - A
count = 0
if C % 2 == 0:
    print(str(C // 2))
else:
    count += min(A - 1,N - B)
    count += (C - 1) // 2
    print(str(count + 1))

Buggy submission (verdict: Runtime Error):
S = input().split(" ")
N = S[0]
A = S[1]
B = S[2]
C = B - A
if C % 2 == 0:
	print(C // 2)
	exit()
print(min(B - 1,N - A))
Problem p02855 (python)

Fixed submission:
H,W,s=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
l_h=[0]*H
for i in range(H):
   if "#" in set(l[i]):
      l_h[i]=1
cnt=0
bor=sum(l_h)-1
for i in range(H):
   if cnt==bor:
      break
   if l_h[i]==1:
      l_h[i]=-1
      cnt+=1
cnt=1
import numpy as np
tmp=[]
st=0
ans=np.zeros((H,W))
for i in range(H):
   tmp.append(l[i])
   if l_h[i]==-1:
      n_tmp=np.array(tmp)
      s_count=np.count_nonzero(n_tmp=="#")-1
      for j in range(W):
         ans[st:i+1,j]=cnt
         if "#" in n_tmp[:,j] and s_count>0:
            cnt+=1
            s_count-=1
      st=i+1
      cnt+=1
      tmp=[]
n_tmp=np.array(tmp)
s_count=np.count_nonzero(n_tmp=="#")-1
for j in range(W):
   ans[st:i+1,j]=cnt
   if "#" in n_tmp[:,j] and s_count>0:
      cnt+=1
      s_count-=1
for i in ans:
   print(*list(map(int,i)))

Buggy submission (verdict: Runtime Error):
H,W,s=list(map(int,input().split()))
l=[list(input()) for i in range(H)]
l_h=[0]*H
for i in range(H):
   if "#" in set(l[i]):
      l_h[i]=1
cnt=0
bor=sum(l_h)-1
for i in range(H):
   if l_h[i]==1:
      l_h[i]=-1
      cnt+=1
   if cnt==bor:
      break
cnt=1
import numpy as np
tmp=[]
st=0
ans=np.zeros((H,W))
for i in range(H):
   tmp.append(l[i])
   if l_h[i]==-1:
      n_tmp=np.array(tmp)
      s_count=np.count_nonzero(n_tmp=="#")-1
      for j in range(W):
         ans[st:i+1,j]=cnt
         if "#" in n_tmp[:,j] and s_count>0:
            cnt+=1
            s_count-=1
      st=i+1
      cnt+=1
      tmp=[]
n_tmp=np.array(tmp)
s_count=np.count_nonzero(n_tmp=="#")-1
for j in range(W):
   ans[st:i+1,j]=cnt
   if "#" in n_tmp[:,j] and s_count>0:
      cnt+=1
      s_count-=1
for i in ans:
   print(*list(map(int,i)))
Problem p02900 (python)

Fixed submission:
import fractions
import math
from collections import deque
A,B = list(map(int,input().split()))
gcd = fractions.gcd(A,B)
def gcd_another(N):
    R = deque()
    for i in range(1,math.ceil(int(N**0.5))+1):
        if N % i == 0:
            R.append(i)
            if i != N // i:
                R.append(N//i)
    R = list(R)
    R.sort()
    return R
C = gcd_another(gcd)
C.pop(0)
total = 1
while C != []:
    i = C[0]
    C = [j for j in C if j % i != 0]
    total += 1
print(total)

Buggy submission (verdict: Runtime Error):
import math
from collections import deque
A,B = list(map(int,input().split()))
gcd = math.gcd(A,B)
def gcd_another(N):
    R = deque()
    for i in range(1,math.ceil(int(N**0.5))+1):
        if N % i == 0:
            R.append(i)
            if i != N // i:
                R.append(N//i)
    R = list(R)
    R.sort()
    return R
C = gcd_another(gcd)
C.pop(0)
total = 1
while C != []:
    i = C[0]
    C = [j for j in C if j % i != 0]
    total += 1
print(total)
Problem p02923 (python)

Fixed submission:
max_score = 0
total = int(input())
now = 0
count = 0 
i = 0
if total == 1:
    print(0)
    exit()
number_list = list(map(int,input().split(" ")))
while i == 0:
    if number_list[now] >= number_list[now+1] and now+1 != total-1:
        count += 1
        now += 1
    elif number_list[now] >= number_list[now+1] and now+1 == total-1:
        count += 1
        now += 1
        if max_score < count:
            max_score = count
        break
    elif number_list[now] < number_list[now+1] and now+1 == total-1:
        break
    else:
        now += 1
        if max_score < count:
            max_score = count
            count = 0
        else:
            count = 0
            continue
print(max_score)

Buggy submission (verdict: Runtime Error):
max_score = 0
total = int(input())
now = 0
count = 0 
i = 0
number_list = list(map(int,input().split(" ")))
while i == 0:
    if number_list[now] >= number_list[now+1] and now+1 != total-1:
        count += 1
        now += 1
    elif number_list[now] >= number_list[now+1] and now+1 == total-1:
        count += 1
        now += 1
        if max_score < count:
            max_score = count
        break
    elif number_list[now] < number_list[now+1] and now+1 == total-1:
        break
    else:
        now += 1
        if max_score < count:
            max_score = count
            count = 0
        else:
            count = 0
            continue
print(max_score)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = list(map(int,input().split(" ")))
best_count = 0
count = 0
Y = 0
list = []
number_start = 0
number_sub = 0
for i in range(A - 1):
    count = 0
    number_start = B[i]
    number_sub = B[i + 1]
    while Y == 0:
        if number_start < number_sub:
            break
        else:
            if i +count  == A - 2:
                count += 1
                break
            else:
                count += 1
                number_start = B[i + count]
                number_sub = B[i + count + 1]  
    list.append(count)
print(max(list))
Problem p02934 (python)

Fixed submission:
import fractions
total = 0
A = int(input())
listB = list(map(int,input().split()))
if 1 < A:
    B = listB[0] * listB[1] // fractions.gcd(listB[0],listB[1])
    for i in range(A-2):
        B = listB[i+2] * B // fractions.gcd(B,listB[i+2])
else:
    B = listB[0]
for i in listB:
    total += B // i
print(B / total)

Buggy submission (verdict: Runtime Error):
import math
total = 0
A = int(input())
listB = list(map(int,input().split()))
if 1 < A:
    B = listB[0] * listB[1] // math.gcd(listB[0],listB[1])
    for i in range(A-2):
        B = listB[i+2] * B // math.gcd(B,listB[i+2])
else:
    B = listB[0]
for i in listB:
    total += B // i
print(B / total)
Problem p02995 (python)

Fixed submission:
A,B,C,D = list(map(int,input().split()))
import fractions
E = C * D // fractions.gcd(C,D)
total = B - B // C - B // D + B // E
F = A-1
total -= F - F // C - F // D + F // E
print(total)

Buggy submission (verdict: Runtime Error):
A,B,C,D = list(map(int,input().split()))
import math
E = C * D // math.gcd(C,D)
total = B - B // C - B // D + B // E
F = A-1
total -= F - F // C - F // D + F // E
print(total)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int,input().split()))
A -= 1
lcn = C * D / math.gcd(C,D) 
m_n = B - B // C - B // D + B // lcn
min_n = A - A // C - A // D + A // lcn
print(int(m_n-min_n))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int,input().split()))
A -= 1
lcn = C * D / math.gcd(C,D) 
m_n = B - B // C - B // D + B // lcn
min_n = A - A // C - A // D + A // lcn
print(m_n-min_n)
Problem p03006 (python)

Fixed submission:
N = int(input())
l=[]
if N==1:
   print(1)
   exit()
for i in range(N):
   a,b=map(int,input().split())
   l.append((a,b))
l2=[]
for i in range(N):
   for j in range(N):
      if i!=j:
         l2.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter
l2=max(Counter(l2).values())
print(N-l2)

Buggy submission (verdict: Runtime Error):
N = int(input())
l=[]
for i in range(N):
   a,b=map(int,input().split())
   l.append((a,b))
l2=[]
for i in range(N):
   for j in range(N):
      if i!=j:
         l2.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter
l2=max(Counter(l2).values())
print(N-l2)

Buggy submission (verdict: Runtime Error):
N=int(input())
l=[]
l_a=[]
for i in range(N):
   l.append(list(map(int,input().split())))
for i in range(N):
   for j in range(i+1,N):
      tmp=str(l[j][0]-l[i][0])+" "+str(l[j][1]-l[i][1])
      l_a.append(tmp)
import collections
l_a=collections.Counter(l_a).most_common()
print(N-l_a[0][1])
Problem p03037 (python)

Fixed submission:
N,M= list(map(int,input().split()))
end = []
start = []
for i in range(M):
    A,B = list(map(int,input().split()))
    end.append(B)
    start.append(A)
end_min = min(end)
start_max = max(start)
if start_max > end_min:
    print(0)
else:
    print(end_min-start_max+1)

Buggy submission (verdict: Runtime Error):
N,M= list(map(int,input().split()))
end = []
start = []
for i in range(M):
    A,B = list(map(int,input().split()))
    end.append(B)
    start.append(A)
end_min = min(end)
start_max = max(start)
if start_max >= end_min:
    print(0)
else:
    print(end_min-start_end+1)

Buggy submission (verdict: Runtime Error):
N,M= list(map(int,input().split()))
end = []
start = []
for i in range(M):
    A,B = list(map(int,input().split()))
    end.append(B)
    start.append(A)
end_min = min(end)
start_max = max(start)
if start_max => end_min:
    print(0)
else:
    print(end_min-start_end+1)
Problem p03050 (python)

Fixed submission:
N=int(input())
def div(n):
    low,high= [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            low.append(i)
            if i != n // i:
                high.append(n//i)
        i += 1
    return low+high[::-1]
S=div(N)
ans=0
S=S[1:]
for i in S:
   if i==0:
      continue
   if N%(i-1)==N//(i-1):
      ans+=i-1
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
N=int(input())
S=sympy.divisors(N)
ans=0
S=S[1:]
for i in S:
   if i==0:
      continue
   if N%(i-1)==N//(i-1):
      ans+=i-1
print(ans)
Problem p03074 (python)

Fixed submission:
N,K=list(map(int,input().split()))
l=input()
n=l[0]
cnt=0
ans=[]
for i in l:
   if i != n:
      ans.append(cnt)
      cnt=1
      n=i
   else:
      cnt+=1
ans.append(cnt)
if l[0] == "0":
   sum_n=sum(ans[0:K*2])
   now=1
   end=K*2
   plus=0
else:
   sum_n=sum(ans[0:K*2+1])
   now=0
   end=K*2+1
   plus=1
max_n=sum_n
for i in range(len(ans)-end+plus):
   sum_n-=ans[i]
   if now==0:
      now=1
   else:
      try:
         sum_n=sum_n+ans[end]+ans[end+1]
         end+=2
      except IndexError:
         sum_n+=ans[end]
         max_n=max(sum_n,max_n)
         print(max_n)
         exit()
      now=0
   max_n=max(sum_n,max_n)
print(max_n)

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
l=input()
n=l[0]
cnt=0
ans=[]
for i in l:
   if i != n:
      ans.append(cnt)
      cnt=1
      n=i
   else:
      cnt+=1
ans.append(cnt)
if l[0] == "0":
   sum_n=sum(ans[0:K*2])
   now=1
   end=K*2
else:
   sum_n=sum(ans[0:K*2+1])
   now=0
   end=K*2+1
max_n=sum_n
for i in range(len(ans)-end+1):
   sum_n-=ans[i]
   if now==0:
      now=1
   else:
      try:
         sum_n=sum_n+ans[end]+ans[end+1]
         end+=2
      except IndexError:
         sum_n+=ans[end]
         max_n=max(sum_n,max_n)
         print(max_n)
         exit()
      now=0
   max_n=max(sum_n,max_n)
print(max_n)

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
l=input()
n=l[0]
cnt=0
ans=[]
for i in l:
   if i != n:
      ans.append(cnt)
      cnt=1
      n=i
   else:
      cnt+=1
ans.append(cnt)
if l[0] == "0":
   sum_n=sum(ans[0:K*2])
   now=1
   end=K*2
else:
   sum_n=sum(ans[0:K*2+1])
   now=0
   end=K*2+1
max_n=sum_n
for i in range(len(ans)-end+1):
   sum_n-=ans[i]
   if now==0:
      now=1
   else:
      try:
         sum_n=sum_n+ans[end]+ans[end+1]
         end+=2
      except IndexError:
         sum_n+=ans[end]
         max_n=max(sum_n,max_n)
         print(max_n)
         exit()
      now=0
   max_n=max(sum_n,max_n)

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
l=input()
n=l[0]
cnt=0
ans=[]
for i in l:
   if i != n:
      ans.append(cnt)
      cnt=1
      n=i
   else:
      cnt+=1
ans.append(cnt)
if l[0] == "0":
   sum_n=sum(ans[0:K*2])
   now=1
   end=K*2
else:
   sum_n=sum(ans[0:K*2+1])
   now=0
   end=K*2+1
max_n=sum_n
for i in range(len(ans)-end+1):
   sum_n-=ans[i]
   if now==0:
      now=1
   else:
      try:
         sum_n=sum_n+ans[end]+ans[end+1]
         end+=2
      except IndexError:
         sum_n+=ans[end]
         max_n=max(sum_n,max_n)
         break
      now=0
   max_n=max(sum_n,max_n)
print(max_n)
Problem p03087 (python)

Fixed submission:
N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
l_n = list(input())
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + 1 if l_n[i] == "A" and l_n[i+1] == "C" else l_a[i]
for i in range(M):
    l,r = list(map(int,input().split()))
    print(l_a[r-1]-l_a[l-1])
Problem p03101 (python)

Fixed submission:
H,W=list(map(int,input().split()))
h,w=list(map(int,input().split()))
print(H*W-h*W-w*H+h*w)

Buggy submission (verdict: Runtime Error):
3 2
2 1
Problem p03128 (python)

Fixed submission:
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
l.sort()
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
dp=[0]*(N+1)
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
dict={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]*(N+1)
for j in l:
   nu,val=j,dict[j]
   dp[val]=max(dp[val],int(nu))
for i in range(N):
   if dp[i]!=0:
      for j in l:
         nu,val=j,dict[j]
         if i+val<=N:
            dp[i+val]=max(dp[i+val],int(str(dp[i])+str(nu)))
print(dp[N])
Problem p03294 (python)

Fixed submission:
I = int(input())
B = 0
count = 0
A = list(map(int,input().split()))
for i in range(I):
    B += A[count] - 1
    count += 1
print(str(B))

Buggy submission (verdict: Runtime Error):
I = int(input())
B = 0
for i in range(I):
	A = input()
	B = A - 1 + B
print(str(B))

Buggy submission (verdict: Runtime Error):
I = int(input())
B = 0
for i in range(I):
	A = input()
    B = A - 1 + B
print(str(B))

Buggy submission (verdict: Runtime Error):
I = int(input())
B = 0
for i in range(I):
	A = input()
    B = A - 1 + B
print(B)
Problem p03393 (python)

Fixed submission:
A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   for i in reversed(range(25)):
      for j in reversed(range(i+1,26)):
         if A[i] < A[j]:
            print(A[:i]+A[j])
            exit()
   else:
      print(-1)

Buggy submission (verdict: Runtime Error):
A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   l=[chr(ord('a') + i) for i in range(26)]
   A=A[::-1]
   for i in range(1,26):
      if A[i-1] < A[i]:
         pass
      else:
         if A[i-1] == "z":
            S=l[-1*i:]
            S.sort()
            A=A[::-1]
            print(A[:-1*i-1]+S[0])
            exit()
         else:
            A[i-1],A[i]=A[i],A[i-1]
            print(A[::-1])
            exit()
Problem p03427 (python)

Fixed submission:
A= input()
if len(A)== 1:
	print(A)
	exit()
length=len(A)
B = "9" * (length-1)
A=int(A)
C=A-int(B)
B=str(int(C/10**(length-1)))+B
B=int(B)
B=list(str(B))
B=list(map(int,B))
print(sum(B))

Buggy submission (verdict: Runtime Error):
A= input()
length=len(A)
B = "9" * (length-1)
A=int(A)
C=A-int(B)
B=str(int(C/10**(length-1)))+B
B=int(B)
B=list(str(B))
B=list(map(int,B))
print(sum(B))
Problem p03612 (python)

Fixed submission:
N=int(input())
A= list(map(int,input().split()))
l=[0]*N
for i in range(N):
   if A[i] == i+1:
      l[i]=1
ans=0
for i in range(N):
   if l[i] == 1:
      try:
         if l[i+1] == 1:
            l[i+1]=0
            ans+=1
         else:
            ans+=1
      except IndexError:
         ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A= list(map(int,input().split()))
l=[0]*N
for i in range(N):
   if A[i] == i+1:
      l[i]=1
ans=0
for i in range(N):
   if l[i] == 1:
      if l[i+1] == 1:
         l[i+1]=0
         ans+=1
      else:
         ans+=1
print(ans)
Problem p03633 (python)

Fixed submission:
import fractions
A = int(input())
ans = int(input())
for i in range(A-1):
    B = int(input())
    ans = B * ans // fractions.gcd(ans,B)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A = int(input())
ans = int(input())
for i in range(A-1):
    B = int(input())
    ans = B * ans // math.gcd(ans,B)
print(ans)
Problem p03651 (python)

Fixed submission:
N,K=list(map(int,input().split()))
l=list(map(int,input().split()))
import math
if N==1:
   if l[0]==K:
      print("POSSIBLE")
      exit()
   else:
      print("IMPOSSIBLE")
      exit()
A=math.gcd(l[0],l[1])
if K<=max(l):
   for i in range(max(0,N-2)):
      A=math.gcd(A,l[i+2])
   if K%A==0:
      print("POSSIBLE")
   else:
      print("IMPOSSIBLE")
else:
   print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
l=list(map(int,input().split()))
import math
A=math.gcd(l[0],l[1])
if K<=max(l):
   for i in range(max(0,N-2)):
      A=math.gcd(A,l[i+2])
   if K%A==0:
      print("POSSIBLE")
   else:
      print("IMPOSSIBLE")
else:
   print("IMPOSSIBLE")
Problem p03759 (python)

Fixed submission:
a,b,c=map(int,input().split())
if b-a==c-b:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A,B,C = list(map(int,input().split()))
if abs(A-B) == abs(B-C):
	print("YES")
    exit()
else:
	print("NO")
    exit()
Problem p04044 (python)

Fixed submission:
N,L =  list(map(int,input().split()))
listA = []
for i in range(N):listA.append(input())
listA.sort()
print("".join(listA))

Buggy submission (verdict: Runtime Error):
N,K =  list(map(int,input().split()))
listA = []
for i in range(K):listA.append(input())
listA.sort()
print("".join(listA))
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def DFS(i):
    if done[i]:
        ans[-1]+=1
        done[i]=False
        for g in G[i]:
            if done[g]:
                DFS(g)
    else:
        return p

N,M=map(int,input().split())
G=[[] for _ in range(N)]
done=[True for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
ans=[]
for j in range(N):
    ans.append(0)
    if done[j]:
        DFS(j)
print(max(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

def DFS(i):
    if done[i]:
        ans[-1]+=1
        done[i]=False
        for g in G[i]:
            if done[g]:
                DFS(g)
    else:
        return p

N,M=map(int,input().split())
G=[[] for _ in range(N)]
done=[True for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
ans=[]
for j in range(N):
    ans.append(0)
    if done[j]:
        DFS(j)
print(max(ans))
Problem p02642 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
M=max(A)+1
table=[0 for _ in range(M)]

for i in range(N):
    if i>0 and A[i]==A[i-1]:
        table[A[i]]=0
        continue
    table[A[i]]=1
    for n in range(2,M):
        if A[i]*n>=M:
            break
        table[A[i]*n]=0
print(sum(table))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
d={}
for a in A:
    if a in d:
        d[a]+=1
    else:
        d[a]=1

ans=0
for i in range(N):
    a=A[i]
    p=1
    if d[a]>1:
        continue
    for j in range(2,int(a**0.5)+1):
        if a%j==0:
            if j in d or a//j in d:
                p=0
                break
    ans+=p

if A[-1]==1:
    if A[-2]>1:
        ans=1
    else:
        ans=0
print(ans)
Problem p02678 (python)

Fixed submission:
from collections import deque

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

tree=[[0] for _ in range(N)]

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

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
ans=[0 for _ in range(N)]
for i in range(1,N):
    for t in tree[i]:
        if dist[t]==dist[i]-1:
            ans[i]=t+1
            break

print("Yes")
for j in range(1,N):
    print(ans[j])

Buggy submission (verdict: Runtime Error):
from collections import deque

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

tree=[[0] for _ in range(N)]

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

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w]!=-1:
            continue
        dist[w] = v
        que.append(w)

print("Yes")
for j in range(1,N):
    print(ans[j])