Problem p03295 (python)

Fixed submission:
ab=[]

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

for i in range(m):
    ab.append(tuple(map(int,input().split())))

ab.sort(key=lambda x:x[1])

res=0
for z in range(len(ab)):
    x=ab[0][1]
    for j in range(len(ab)):
        if x > ab[0][0]:
            del ab[0]
        else:
            res+=1
            break
    if len(ab)==0:
        res+=1
        break
    
print(res)

Buggy submission (verdict: Runtime Error):
ab=[]

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

for i in range(m):
    ab.append(tuple(map(int,input().split())))

ab.sort(key=lambda x:x[1])

res=0
for z in range(len(ab)):
    x=ab[0][1]
    if x==ab[-1][1]:
        res+=1
        break
    for j in range(len(ab)):
        if x > ab[0][0]:
            del ab[0]
            if len(ab)==0:
                res+=1
                break
        else:
            res+=1
            break
    
print(res)

Buggy submission (verdict: Runtime Error):
ab=[]

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

for i in range(m):
    ab.append(tuple(map(int,input().split())))

ab.sort(key=lambda x:x[0])
abrs=ab.copy()
abrs.sort(key=lambda x:x[1])

res=0
mark=0
while(1):
    for j in range(len(ab)):
        if abrs[0][1] > ab[j][0]:
            pass
        else:
            if mark!=j:res+=1
            mark=j
            break
    del ab[:mark]
    if len(ab)==1:
        res+=1
        break
    for j in range(len(abrs)):
        if ab[0][0] > abrs[j][0]:
            pass
        else:
            mark=j
            break
    del abrs[:mark]
    
print(res)

Buggy submission (verdict: Runtime Error):
ab=[]

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

for i in range(m):
    ab.append(tuple(map(int,input().split())))

ab.sort(key=lambda x:x[1])

res=0
milestone=0
while(1):
    for j in range(len(ab)):
        if ab[0][1] < ab[j][0]:
          milestone=j
          res+=1
          break
    del ab[:milestone]
    if len(ab)==1:
        res+=1
        ab.remove(0)
    if len(ab)==0:
        break

print(res)

Buggy submission (verdict: Runtime Error):
ab=[]

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

for i in range(m):
    ab.append(tuple(map(int,input().split())))

ab.sort(key=lambda x:x[1])

res=0
milestone=0
while(1):
    for j in range(len(ab)):
        if ab[0][1] < ab[j][0]:
          milestone=j
          res+=1
          break
    del ab[:milestone]
    if len(ab)==1:
      res+=1
      ab.remove(0)
    if len(ab)==0
      break

print(res)

Buggy submission (verdict: Runtime Error):
ab=[]

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

for i in range(m):
    ab.append(tuple(map(int,input().split())))

ab.sort(key=lambda x:x[1])

res=0
milestone=0
while(1):
    for j in range(len(ab)):
        if ab[0][1] < ab[j][0]:
          milestone=j
          res+=1
          break
    ab.remove[0:milestone]
    if len(ab)==0:break

print(res)

Buggy submission (verdict: Runtime Error):
ab=[]

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

for i in range(m):
    ab=(map(int,input().split()))


abr=[]
enabled=[]
removed=[]
for i in range(m):
    abr.append(range(ab[i][0],ab[i][1]))
    enabled.append(False)
    removed.append(False)

res=0
for i in range(n):
    for j in range(len(abr)):
        if i == abr[j][0] and not removed[j]:
            enabled[j]=True
    for j in range(len(abr)):
        if i == abr[j][-1] and enabled[j]:
            res+=1
            for k in range(len(abr)):
                if enabled[k] and not removed[k]:
                    enabled[k]=False
                    removed[k]=True

print(res)

Buggy submission (verdict: Runtime Error):
ab=[]
n,m = map(int,input().split())

for i in range(m):
    ab=(map(int,input().split()))

abr=[]
enabled=[]
removed=[]
for i in range(m):
    abr.append(range(ab[i][0],ab[i][1]))
    enabled.append(False)
    removed.append(False)

res=0
for i in range(n):
    for j in range(len(abr)):
        if i == abr[j][0] and not removed[j]:
            enabled[j]=True
    for j in range(len(abr)):
        if i == abr[j][-1]:
            res+=1
            for k in range(len(abr)):
                if enabled[j]:
                    enabled[j]=False
                    removed[j]=True
print(res)