ZhenlongDai/ACPR huggingface dataset:
Problem: p03724
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N)
for _ in range(M):
    l,r=map(int,input().split())
    road[l-1]+=1
    road[r-1]-=1
road = list(itertools.accumulate(road))[:-1]

if sum(road)%2==0:
    print('YES')
else:
    print('NO')


Failing test case input:
14 2
1 2
2 -1
0 1
-2 4
0 1

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N)
for _ in range(M):
    l,r=map(int,input().split())
    road[l-1]+=1
    road[r-1]-=1
road = list(itertools.accumulate(road))[:-1]

flag=0
for ro in road:
    if ro%2==1:
        print('NO')
        exit()
print('YES')

Problem: p03724
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = [int(x) for x in input().split()]
cnt = [0]*(n+1)
for i in range(m):
    a,b = [int(x) for x in input().split()]
    cnt[a]+=1
    cnt[b]+=1
for i in range(n):
  if cnt[i]%2==1:
    print("No")
    exit()
print("Yes")

Failing test case input:
10 1
0 1
2 3
11 3
-1 4
0 0

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
n,m = [int(x) for x in input().split()]
cnt = [0]*(n+1)
for i in range(m):
    a,b = [int(x) for x in input().split()]
    cnt[a]+=1
    cnt[b]+=1
for i in range(n):
  if cnt[i]%2==1:
    print("NO")
    exit()
print("YES")

Problem: p03724
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m=map(int,input().split())
g=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  g[a]+=1
  g[b]+=1
  g[a]%=2
  g[b]%=2
  
print("Yes" if max(g) else "No")

Failing test case input:
10 0
1 1
2 6
11 2
-1 4
0 10

Expected output:
YES


Actual output:
No


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
g=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  g[a]+=1
  g[b]+=1
  g[a]%=2
  g[b]%=2
  
print("YES" if 1-max(g) else "NO")

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N, M = map(int, input().split())

    i = 0
    AB = []
    while i < M:
        AB.append(tuple(map(int, input().split())))
        i += 1

    edge = [0 for i in range(N - 1)]
    for i in AB:
        s = i[0] - 1
        e = i[1] - 1
        while s < e:
            edge[s] += 1
            s += 1

    for i in edge:
        if i % 2 > 0:
            print('NO')
            break
    else:
        print('YES')

main()


Failing test case input:
14 2
0 2
2 0
0 0
-2 4
0 1

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
def main():
    N, M = map(int, input().split())

    i = 0
    AB = [0 for i in range(N)]
    while i < M:
        a, b = map(int, input().split())
        AB[a-1] += 1
        AB[b-1] += 1
        i += 1

    for i in AB:
        if i % 2 > 0:
            print('NO')
            break
    else:
        print('YES')

main()
Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())

tree = [0 for _ in range(n+1)]
for _i in range(m):
    a, b = map(int, input().split())
    tree[a] += 1
    tree[b] += 1
if all(i%2==0 for i in tree):
    print("Yes")
else:
    print("No")

Failing test case input:
10 0
1 1
11 6
5 2
3 4
3 3

Expected output:
YES


Actual output:
Yes


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())

tree = [0 for _ in range(n+1)]
for _i in range(m):
    a, b = map(int, input().split())
    tree[a] += 1
    tree[b] += 1
if all(i%2==0 for i in tree):
    print("YES")
else:
    print("NO")

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())

count=[0]*N
for _ in range(M):
    a,b=map(int,input().split())
    count[a-1]+=1
    count[b-1]+=1

for c in count:
    if c%2==0:
        print("NO")
        exit()

print("YES")

Failing test case input:
10 0
1 1
11 6
5 2
0 4
1 3

Expected output:
YES


Actual output:
NO


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

count=[0]*N
for _ in range(M):
    a,b=map(int,input().split())
    count[a-1]+=1
    count[b-1]+=1

for c in count:
    if c%2==1:
        print("NO")
        exit()

print("YES")

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):







from collections import Counter
n, m = map(int, input().split())

cnt = Counter()
for i in range(m):
    a, b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1

for a in range(1, n+1):
    if cnt[a] % 2 == 1:
        print('No')
        exit()

print('Yes')


Failing test case input:
14 1
0 2
8 3
1 1
-2 4
0 1

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):







from collections import Counter
n, m = map(int, input().split())

cnt = Counter()
for i in range(m):
    a, b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1

for a in range(1, n+1):
    if cnt[a] % 2 == 1:
        print('NO')
        exit()

print('YES')

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
c_list = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    c_list[a] += 1
    c_list[b] += 1

ok = True
for c in c_list:
    if c % 2 != 0:
        ok = False
if ok:
    print("Yes")
else:
    print("No")


Failing test case input:
5 1
1 1
6 5
5 2
3 4
2 3

Expected output:
YES


Actual output:
Yes


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
c_list = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    c_list[a] += 1
    c_list[b] += 1

ok = True
for c in c_list:
    if c % 2 != 0:
        ok = False
if ok:
    print("YES")
else:
    print("NO")
Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
cnt=[]
for i in range(n):
  cnt.append(0)
for i in range(m):
  a,b=map(int,input().split())
  cnt[a-1]+=1
  cnt[b-1]+=1
for i in range(n):
  if cnt[i]%2==1:
    print('NO')
    exit()
print('Yes')

Failing test case input:
6 5
1 2
3 5
5 1
3 4
2 4

Expected output:
YES


Actual output:
Yes


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
cnt=[]
for i in range(n):
  cnt.append(0)
for i in range(m):
  a,b=map(int,input().split())
  cnt[a-1]+=1
  cnt[b-1]+=1
for i in range(n):
  if cnt[i]%2==1:
    print('NO')
    exit()
print('YES')

Problem: p03724
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, M = map(int, input().split())
    ans = 0
    for _ in range(M):
        a, b = map(int, input().split())
        ans += abs(a-b)
    if ans & 1:
        print('NO')
    else:
        print('YES')

if __name__ == "__main__":
    main()


Failing test case input:
14 2
1 2
2 -1
0 1
-2 4
0 1

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):

import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, M = map(int, input().split())
    ans = [0] * N
    for _ in range(M):
        a, b = map(lambda x: int(x)-1, input().split())
        ans[a] = 1-ans[a]
        ans[b] = 1-ans[b]
    if 1 in ans:
        print('NO')
    else:
        print('YES')

if __name__ == "__main__":
    main()

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(n):
  if l[i]%2!=1:
    b=False
if b:
  print("YES")
else:
  print("NO")


Failing test case input:
10 0
2 1
2 3
11 2
-1 2
0 5

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(n):
  if l[i]%2==1:
    b=False
if b:
  print("YES")
else:
  print("NO")

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
A, B = [0 for _ in range(N)], [0 for _ in range(N)]
for i in range(M):
	a, b = map(int, input().split())
	A[a-1] += 1
	B[b-1] += 1
print("NO" if sum(A)%2 or sum(B)%2 else "YES")

Failing test case input:
14 2
1 2
2 -1
0 1
-2 4
0 1

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
AB = [0 for _ in range(N)]
for i in range(M):
	a, b = map(int, input().split())
	AB[a-1] += 1
	AB[b-1] += 1
for i in range(N):
	if AB[i]%2 or AB[i]%2:
		print("NO")
		exit()
print("YES")
Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

def solve():
    N, M = map(int, input().split())

    if M & 1:
        print('NO')
        return

    ncnt = [0]*N

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1

        ncnt[a] += 1
        ncnt[b] += 1

    if all(ni & 1 == 0 for ni in ncnt):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    solve()

Failing test case input:
5 1
1 1
6 6
5 2
3 4
2 3

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
import sys

def solve():
    N, M = map(int, input().split())

    ncnt = [0]*N

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1

        ncnt[a] += 1
        ncnt[b] += 1

    if all(ni & 1 == 0 for ni in ncnt):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    solve()

Problem: p03724
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve():
  n,m = (int(i) for i in input().split())
  a = [0]*n
  for i in range(m):
    a1,b1 = (int(i) for i in input().split())
    a[a1-1]+=1
    a[b1-1]+=1
  ans = 'YES'
  for i in range(1,n+1):
   if (a.count(i))%2 == 1:
    ans ='NO'
  return ans
                   
  
if __name__ == '__main__':
  print(solve())

Failing test case input:
14 1
0 2
8 3
1 1
-2 4
0 1

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
def solve():
  n,m = (int(i) for i in input().split())
  a = [0]*n
  for i in range(m):
    a1,b1 = (int(i) for i in input().split())
    a[a1-1]+=1
    a[b1-1]+=1
  ans = 'YES'
  for i in range(n):
   if a[i]%2 == 1:
    ans ='NO'
  return ans
                   
  
if __name__ == '__main__':
  print(solve())

Problem: p03724
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m=map(int,input().split())
g=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  g[a]+=1
  g[b]+=1
  g[a]%=2
  g[b]%=2
  
print("Yes" if 1-max(g) else "No")


Failing test case input:
14 1
0 1
8 3
11 2
-2 4
1 1

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
g=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  g[a]+=1
  g[b]+=1
  g[a]%=2
  g[b]%=2
  
print("YES" if 1-max(g) else "NO")
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xl = [[int(i) for i in input().split()] for j in range(n)]


xl.sort()





plus = []
minus = []

for i in range(n):
    plus.append(xl[i][0]-xl[i][1]+1)
    minus.append(xl[i][0]+xl[i][1]-1)




num = 0
ima = n

for i in range(n-1):
    if minus[i]  > plus[i+1]:
        ima -= 1
        
print(ima)

Failing test case input:
4
7 32
8 3
1 2
101 4

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
xl = [[int(i) for i in input().split()] for j in range(n)]

xl_li = []

for i in range(n):
    xl_li.append([xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]])
    
xl_li = sorted(xl_li,key=lambda xl_li:xl_li[1])

tmp = xl_li[0][1]
ans = 1

for i in range(1,n):
    if tmp <= xl_li[i][0]:
        tmp = xl_li[i][1]
        ans += 1
        
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xs = []
scope = {}
for _ in range(n):
    x, l = map(int, input().split())
    xs.append(x)
    scope[x] = [x-l, x+l]
    
xs.sort()
ans = n
end = scope[xs[0]][1]
for i in xs[1:]:
    start = scope[i][0]
    if end > start:
        ans -= 1
        end = start
print(ans)


Failing test case input:
4
4 80
2 4
2 2
001 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
scope = []
for _ in range(n):
    x, l = map(int, input().split())
    scope.append([x+l, x-l])
    
scope.sort()
ans = 1
border = scope[0][0]
for i, r in enumerate(scope[1:]):
    if border <= r[1]:
        ans += 1
        border = r[0]
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    robo = []
    for i in range(N):
        x, l = [int(x) for x in input().split()]
        robo.append((x, l))
    robo.sort()

    ans = N
    x0, l0 = robo[0]
    for i in range(1, N):
        x, l = robo[i]
        if x - l < x0 + l0:
            ans -= 1
        else:
            x0, l0 = x, l

    print(ans)

if __name__ == '__main__':
    main()


Failing test case input:
4
4 32
14 2
6 2
101 3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    robo = []
    for i in range(N):
        x, l = [int(x) for x in input().split()]
        robo.append((x-l, x+l))
    robo.sort()
    robo.sort(key=lambda x: x[1])

    ans = N
    l, r = robo[0]
    for i in range(1, N):
        if robo[i][0] < r:
            ans -= 1
        else:
            l, r = robo[i]
    print(ans)


if __name__ == '__main__':
    main()
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve():
    n = int(input())
    XL = sorted(list(map(int, input().split())) for _ in range(n))
    ans = n
    last = XL[0][0] + XL[0][1] - 1
    for x, l in XL[1:]:
        if last >= x - l + 1:
            ans -= 1
        else:
            last = x + l - 1
    print(ans)
solve()


Failing test case input:
5
10 1
2 2
4 1
6 1
8 1

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
def solve():
    n = int(input())
    XL = [list(map(int, input().split())) for _ in range(n)]
    ps = sorted((x + l, x - l) for x, l in XL)
    ans = 1
    last = ps[0][0]
    for s, t in ps[1:]:
        if last <= t:
            ans += 1
            last = s
    print(ans)
solve()

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def resolve():
	n = int(input())
	robots = [list(map(int, input().split())) for _ in range(n)]
	robots.sort(key=lambda x: x[0])
	t = robots[0][0] + robots[0][1]
	a = n
	for i in range(1, n):
		if t > robots[i][0] - robots[i][1]:
			a -= 1
		else:
			t = robots[i][0] + robots[i][1]
	print(a)
resolve()

Failing test case input:
4
4 57
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def resolve():
	n = int(input())
	robots = [list(map(int, input().split())) for _ in range(n)]
	robots.sort(key=lambda x: x[0] + x[1])
	t = robots[0][0] + robots[0][1]
	a = n
	for i in range(1, n):
		if t <= robots[i][0] - robots[i][1]:
			t = robots[i][0] + robots[i][1]
		else:
			a -= 1
	print(a)
resolve()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
INF = float("inf") 

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    
    ls = sorted(ls,key = lambda x:x[0])

    ans = 0; t = -INF
    for i in range(n):
        if t <= ls[i][0] - ls[i][1]:
            ans += 1
            t = ls[i][0] + ls[i][1]
    print(ans)


if __name__ == "__main__":
    main()


Failing test case input:
4
4 32
14 2
6 2
101 3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
INF = float("inf") 

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    
    robot = [(ls[i][0] + ls[i][1],ls[i][0] - ls[i][1]) for i in range(n)]
    robot = sorted(robot,key = lambda x: x[0])
    

    ans = 0; latest = -INF
    for i in range(n):
        if latest <= robot[i][1]:
            ans += 1
            latest = robot[i][0]
    print(ans)


if __name__ == "__main__":
    main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=int(input())
t=[list(map(int, input().split())) for i in range(s)]
t.sort()
d=-10*10
ans=0
for i in range(s):
  if d<t[i][0]-t[i][1]:
    ans+=1
    d=t[i][0]+t[i][1]-1
print(ans)

Failing test case input:
4
4 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
s=int(input())
t=[]
for i in range(s):
    u,l=map(int,input().split())
    t.append((u-l,u+l-1))
t.sort(key=lambda x: x[1])
d=-10**10
ans=0
for i in range(s):
  if d<t[i][0]:
    ans+=1
    d=t[i][1]
print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
LR = [[0,0] for _ in range(N)]
for i in range(N):
  a,b = map(int, input().split())
  LR.append([a-b,a+b])

LR.sort(key=lambda x: x[0])

prev_right = - 10**9 
cnt = 0
for i in range(N):
  if LR[i][0]>=prev_right: 
    cnt += 1
    prev_right = LR[i][1]
  else:
    if LR[i][1]<prev_right:
      prev_right = LR[i][1]

print(cnt)

Failing test case input:
4
4 32
8 2
6 2
100 5

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
LR = [[0,0] for _ in range(N)]
for i in range(N):
  a,b = map(int, input().split())
  LR[i] = [a-b,a+b]

LR.sort(key=lambda x: x[0])

prev_right = - 10**9 
cnt = 0
for i in range(N):
  if LR[i][0]>=prev_right: 
    cnt += 1
    prev_right = LR[i][1]
  else:
    if LR[i][1]<prev_right:
      prev_right = LR[i][1]
  

print(cnt)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
R=sorted([list(map(int,input().split(' '))) for i in range(N)])
ans = 1
now = R[0][0]+R[0][1]
for x,l in R[1:]:
    if now<=x-l:
        ans += 1
        now = x+l
print(ans)

Failing test case input:
4
4 57
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
R=sorted([list(map(int,input().split(' '))) for i in range(N)])
ans = 1
now = R[0][0]+R[0][1]
for x,l in R[1:]:
    if now > x-l and now> x+l:
        now = x+l
    elif now <=x-l:
        ans += 1
        now = x+l
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

robots = []

for _ in range(n):
    x, l = map(int, input().split())
    left, right = x-l+1, x+l-1
    robots.append([left, right])

robots.sort()

DP = [0, -10**10]

for left, right in robots:
    count, now = DP[0], DP[1]
    if left > now:
        DP = [count+1, right]

    else:
        if right < now:
            DP = [count, right]
        else:
            continue

print(DP[0])

Failing test case input:
5
10 1
2 2
1 1
10 1
8 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())

robots = []

for _ in range(n):
    x, l = map(int, input().split())
    left, right = x-l, x+l
    robots.append([left, right])

robots.sort()

count = 0
now = -float('INF')

for left, right in robots:
    if left >= now:
        count += 1
        now = right

    else:
        if right < now:
            now = right
        else:
            continue

print(count)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()

ans=1
c=l[0][0]+l[0][1]
for i in range(n):
    if c<=l[i][0]-l[i][1]:
        c=l[i][0]+l[i][1]
        ans+=1
print(ans)

Failing test case input:
4
8 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
ans=1
c=l[0][0]+l[0][1]
for i in range(1,n):
    if c>=l[i][0]+l[i][1]:
        c=l[i][0]+l[i][1]
    elif c<=l[i][0]-l[i][1]:
        c=l[i][0]+l[i][1]
        ans+=1
print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
def main():
    N = int(input())
    robo = []

    for _ in range(N):
        x, l = map(int, input().split())
        l = l-1
        robo.append((x+l, x-l))

    robo.sort()
    
    ans = 1
    t = robo[0][0]
    for i in range(1, N):
        if t < robo[i][1]:
            ans += 1
            t = robo[i][0]

    print(ans)




    return 0

if __name__ == '__main__':
    main()


Failing test case input:
5
10 1
2 2
4 1
6 1
8 2

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    robo = []

    for _ in range(N):
        x, l = map(int, input().split())
        robo.append((x-l, x+l))

    robo = sorted(robo, key=lambda x:x[1])

    ans = 0
    max = -10**9

    for r in robo:
        if r[0] >= max:
            ans += 1
            max = r[1]
    print(ans)
    return 0

if __name__ == '__main__':
    main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

a_list = []
for i in range(N):
  x, l = map(int, input().split())
  a_list.append([x - l + 1, x + l - 1])
  
b_list = sorted(a_list, key=lambda x:x[0])

cnt = N
start, end = map(int, b_list[0])
for i in range(1,N):
  start_, end_ = map(int, b_list[i])
  if start_ <= end:
    if end_ <= end:
      cnt -= 1
      start = start_
      end = end_
      continue
    else:
      cnt -= 1
      continue
  else:
    start = start_
    end = end_
      
      
print(cnt)

Failing test case input:
4
4 57
8 4
2 4
001 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())

a_list = []
for i in range(N):
  x, l = map(int, input().split())
  a_list.append([x - l, x + l])
  
b_list = sorted(a_list, key=lambda x:x[0])
cnt = N
start, end = map(int, b_list[0])
for i in range(1,N):
  start_, end_ = map(int, b_list[i])
  if start_ < end:
    if end_ <= end:
      cnt -= 1
      start = start_
      end = end_
      continue
    else:
      cnt -= 1
      continue
  else:
    start = start_
    end = end_
      
      
print(cnt)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    x = [[0, 0] for  _ in range(n)]
    for i in range(n):
        x[i] = list(map(int, input().strip().split()))
    x = sorted(x, key=itemgetter(1))
    m = x[0][1]
    ans = 1
    for mi, ma in x[1:]:
        if m <= mi:
            m = ma
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Failing test case input:
5
10 1
2 2
0 1
6 1
8 2

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    x = [[0, 0] for  _ in range(n)]
    for i in range(n):
        p, q = list(map(int, input().strip().split()))
        x[i][0] = p-q
        x[i][1] = p+q
    x = sorted(x, key=itemgetter(1))
    m = x[0][1]
    ans = 1
    for mi, ma in x[1:]:
        if m <= mi:
            m = ma
            ans += 1

    
    
    
    
    

    
    
    
    
    
    

    print(ans)

if __name__ == '__main__':
    main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
from operator import itemgetter
def main():
    n = int(input())
    robots = []
    for _ in range(n):
        x, l = map(int, input().split())
        lside = x - l
        rside = x + l
        robots.append((lside, rside))

    robots = sorted(robots, key=itemgetter(1), reverse=True)
    robots = sorted(robots, key=itemgetter(0))
    robots = deque(robots)
    a_robot = robots.popleft()
    cnt = 1
    while robots:
        robot_next = robots.popleft()
        if a_robot[1] > robot_next[0]:
            continue
        else:
            cnt += 1
            a_robot = robot_next
    print(cnt)

if __name__ == '__main__':
    main()

Failing test case input:
4
4 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import deque
from operator import itemgetter
def main():
    n = int(input())
    robots = []
    for _ in range(n):
        x, l = map(int, input().split())
        lside = x - l
        rside = x + l
        robots.append((lside, rside))
    
    robots = sorted(robots, key=itemgetter(1))
    robots = deque(robots)
    a_robot = robots.popleft()
    cnt = n
    while robots:
        robot_next = robots.popleft()
        if a_robot[1] > robot_next[0]:
            cnt -= 1
        else:
            a_robot = robot_next
            continue
    print(cnt)

if __name__ == '__main__':
    main()
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
rm = 0
r = -float('inf')
robot = sorted([list(map(int, input().split())) for i in range(N)])
for x, l in robot:
    if x - l < r:
        rm += 1
    else:
        r = x + l

print(N - rm)


Failing test case input:
4
4 32
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
rm = 0
r = -float('inf')
robot = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[0] + x[1])

for x, l in robot:
    if x - l < r:
        rm += 1
    else:
        r = max(r, x + l)

print(N - rm)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    X = []
    for _ in range(N):
        x, l = map( int, input().split())
        X.append((x+l-1, x-l+1))
    X.sort()
    ans = 1
    now = X[0][0]
    for i in range(1,N):
        b, a = X[i]
        if now < a:
            now = b
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Failing test case input:
4
4 80
0 1
2 2
001 8

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    X = []
    for _ in range(N):
        x, l = map( int, input().split())
        X.append((x+l, x-l))
    X.sort()
    ans = 1
    now = X[0][0]
    for i in range(1,N):
        b, a = X[i]
        if now <= a:
            now = b
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
robots = list(list(map(int,input().split())) for _ in range(N))
robots.sort()
now = robots[0][0] + robots[0][1]
ans = 0
for i in range(1 , N):
    if robots[i][0] - robots[i][1] >= now:
        now = robots[i][0] + robots[0][1]
    else:
        ans += 1
print(N - ans)

Failing test case input:
4
4 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
robots = []
for _ in range(N):
    X, L = map(int, input().split())
    robots.append([X + L, X - L])
robots.sort()
now = -float("inf")
ans = 0
for i in range(N):
    if robots[i][1] >= now:
        now = robots[i][0]
        ans += 1
print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

xl = []

for i in range(N):
    xl.append(list(map(int,input().split())))

xl.sort()



left = [0]*N
right = [0]*N
exist = [1]*N

for i in range(N):
    left[i] = xl[i][0] - xl[i][1] + 1
    right[i] = xl[i][0] + xl[i][1] - 1

most_right = 0
for i in range(N-1):
    tmp = right[most_right]
    if exist[i]:
        if tmp >= left[i+1]:
            exist[i] = 0
        else:
            most_right += 1
print(sum(exist))

Failing test case input:
5
10 1
2 2
4 1
6 1
8 1

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())

xl = []

for i in range(N):
    xl.append(list(map(int,input().split())))

itv = []

for i in range(N):
    right = xl[i][0] + xl[i][1] - 0.01 
    left = xl[i][0] - xl[i][1] + 0.01 
    itv.append([right,left])
itv.sort()

ass = 0
tt = -1e10
for i in range(N):
    if tt < itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
a = []
p = []
res = 0
for _ in range(N):
  x, l = map(int, input().split())
  a.append((x - l + 1, x + l - 1))
  p.append(x - l + 1)
p.sort()
a.sort(key = lambda x: (x[0], -x[1]))


for i in range(N):
  r = bl(p, a[i][1])
  
  res += max(r - i - 1, 0)
print(N - res)

Failing test case input:
4
4 80
0 1
2 2
001 4

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
a = []
x = -float("inf")
res = 0
for _ in range(N):
  x, l = map(int, input().split())
  a.append((x - l, x + l))
a.sort(key = lambda x: x[1])
x = -float("inf")

for i in range(N):
  if x <= a[i][0]:
    x = a[i][1]
    res += 1
print(res)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
robots = []
for _ in range(N):
    x, l = map(int, input().split())
    robots.append((x-l, x+l))

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

cnt = 0
last = -10**18  
for left, right in robots:
    if left+1 > last-1:  
        cnt += 1
        last = right
print(cnt)


Failing test case input:
5
10 1
2 2
0 1
6 1
8 2

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
robots = []
for _ in range(N):
    x, l = map(int, input().split())
    robots.append((x-l, x+l))

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

cnt = 0
last = -10**18  
for left, right in robots:
    if left >= last:  
        cnt += 1
        last = right
print(cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

robots = []

for _ in range(n):
    x, l = map(int, input().split())
    left, right = x-l+1, x+l-1
    robots.append([left, right])

robots.sort()

DP = [0, -float('INF')]

for left, right in robots:
    count, now = DP[0], DP[1]
    if left > now:
        DP = [count+1, right]

    else:
        if right < now:
            DP = [count, right]
        else:
            continue

ans = DP[0]
print(ans)

Failing test case input:
4
4 57
8 4
1 4
001 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())

robots = []

for _ in range(n):
    x, l = map(int, input().split())
    left, right = x-l, x+l
    robots.append([left, right])

robots.sort()

count = 0
now = -float('INF')

for left, right in robots:
    if left >= now:
        count += 1
        now = right

    else:
        if right < now:
            now = right
        else:
            continue

print(count)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: (x[0]-x[1],x[0]+x[1]))
M = XL[0][0]+XL[0][1]-1
ans = N
for i in range(1,N):
    if M >= XL[i][0]-XL[i][1]:
        ans -= 1
    else:
        M = XL[i][0]+XL[i][1]-1
print(ans)


Failing test case input:
4
4 32
14 2
6 2
101 3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
M = XL[0][0]+XL[0][1]-1
ans = 0
for i in range(1,N):
    if M >= XL[i][0]-XL[i][1]:
        ans += 1
    else:
        M = XL[i][0]+XL[i][1]-1
print(N-ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy
import sys
inf = sys.maxsize 
n = int(input())
robot = []
for i in range(n):
    x, l = map(int,input().split())
    robot.append([x - l, x + l]) 
robot.sort()
preright = -inf
ans = 0
for i in range(n):
    left = robot[i][0]
    if preright <= left:
        ans += 1
        preright = robot[i][1]
print(ans)


Failing test case input:
4
4 32
8 4
1 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
robot = []
for i in range(n):
    x, l = map(int,input().split())
    robot.append([x + l, x - l]) 
robot.sort()
preright = robot[0][1]
ans = 0
for i in range(n):
    left = robot[i][1]
    
    if preright <= left:
        ans += 1
        preright = robot[i][0]
print(ans)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
XL = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])
last = XL[0]
cnt=1
for i in range(1, N):
    last_X, last_L = last
    c_X, c_L = XL[i]
    if last_X+last_L>c_X-c_L:
        continue
    else:
        last = XL[i]
        cnt+=1
print(cnt)

Failing test case input:
4
4 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
XL = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0]+x[1])
last = XL[0][0]-XL[0][1]
cnt = 0
for i in range(N):
    if last<=XL[i][0]-XL[i][1]:
        last = XL[i][0]+XL[i][1]
        cnt+=1
print(cnt)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
a = []
p = []
res = 0
for _ in range(N):
  x, l = map(int, input().split())
  a.append((x - l + 1, x + l - 1))
  p.append(x - l + 1)
p.sort()
a.sort(key = lambda x: (x[0], -x[1]))


for i in range(N):
  r = bl(p, a[i][1])
  
  if max(r - i - 1, 0) >= 1: res += 1
print(N - res)

Failing test case input:
4
4 32
8 2
6 2
101 4

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
a = []
x = -float("inf")
res = 0
for _ in range(N):
  x, l = map(int, input().split())
  a.append((x - l, x + l))
a.sort(key = lambda x: x[1])
x = -float("inf")

for i in range(N):
  if x <= a[i][0]:
    x = a[i][1]
    res += 1
print(res)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
XLlist = [tuple(map(int, input().split())) for _ in range(N)]
XLlist.sort(key=lambda x: x[0])
ans = 1
tikan = -1
x, l = XLlist[0]
rl = x + (l - 1)
for x, l in XLlist:
    ll = x - l
    if ll < rl:
        tikan += 1
        rl = min(rl, x + l - 1)
    else:
        ans += 1
        rl = x + l - 1

print(ans - 1)


Failing test case input:
4
4 4
1 5
9 3
100 5

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
XLlist = [tuple(map(int, input().split())) for _ in range(N)]
XLlist.sort(key=lambda x: x[0])
ans = 1
x, l = XLlist[0]
rl = x + (l - 1)
for x, l in XLlist:
    ll = x - l
    if ll <= rl:
        rl = min(rl, x + l - 1)
    else:
        ans += 1
        rl = x + l - 1

print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
for i in range(n):
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])

now = 0
for i in range(n-1):
    if a[now][1]>a[now+1][0]:
        a.pop(now+1)
    else:
        now+=1
print(len(a))

Failing test case input:
4
4 57
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])
a.sort(key=lambda x: x[1])
INF = 10**10
preR = -INF
cnt=0
for L,R in  a:
    if L<preR:
        continue
    cnt+=1
    preR=R
print(cnt)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = []
left = []
right = []
for i in range(n):
    x,l = map(int, input().split())
    
    d.append([x-l,x+l])

d.sort()
p = d[0][1]
ans = n
for i in range(1,n):
    if d[i][0] <= p:
        ans -= 1
        p = d[i][1]
    else:
        p = min(p,d[i][1])
print(ans)


Failing test case input:
4
4 57
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
d = []
left = []
right = []
for i in range(n):
    x,l = map(int, input().split())
    
    d.append([x-l,x+l])

d.sort()
p = d[0][1]
ans = n
for i in range(1,n):
    if d[i][0] < p:
        ans -= 1
        p = min(p,d[i][1])
    else:
        p = d[i][1]
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = [list(map(int, input().split())) for i in range (n)]

grid = [list([0,0]) for i in range(n)]

for i in range(n):
    grid[i][0] = x[i][0] - x[i][1]
    grid[i][1] = x[i][0] + x[i][1]

new_grid = sorted(grid)
print(new_grid)
cnt = 0
for i in range(n-1):
    if i + 1 >= len(new_grid):
        break;
    if new_grid[i][1] > new_grid[i+1][0]:
        cnt += 1
        del new_grid[i+1]

ans = n - cnt

print(ans)

Failing test case input:
4
4 16
4 3
6 2
100 3

Expected output:
2


Actual output:
[[-12, 20], [1, 7], [4, 8], [97, 103]]
3


Fixed submission (verdict: Accepted):
n = int(input())
x = [list(map(int, input().split())) for i in range (n)]

grid = [list([0,0]) for i in range(n)]

for i in range(n):
    grid[i][0] = x[i][0] - x[i][1]
    grid[i][1] = x[i][0] + x[i][1]

new_grid = sorted(grid,key=lambda x:x[1])

cnt = 1
a = new_grid[0][1]

for i in range(n):
    if a <= new_grid[i][0]:
        cnt += 1
        a = new_grid[i][1]
print(cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy
n = int(input())
x_org = []
for i in range(n):
    x_org.append(input().split())

x = sorted(x_org, key=lambda z: int(z[0]))

removed = 0
for i in range(1, n):
    if (int(x[i][0]) - int(x[i][1])) < (int(x[i-1][0]) + int(x[i-1][1])):
        removed += 1
        x[i] = x[i-1]

print(n - removed)

Failing test case input:
4
8 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
x_org = []
for i in range(n):
    x_org.append(input().split())

x = sorted(x_org, key=lambda z: int(z[0]))
removed = 0
for i in range(1, n):
    before = int(x[i][0]) - int(x[i][1])
    after = int(x[i-1][0]) + int(x[i-1][1]) 
    if before < after:
        removed += 1
        if (int(x[i][0]) + int(x[i][1])) > (int(x[i-1][0]) + int(x[i-1][1])):
            x[i] = x[i-1]

print(n - removed)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter
N=int(input())
xl=[list(map(int, input().split())) for i in range(N)]
xl=sorted(xl, key=itemgetter(0))
a=[xl[i][0]+xl[i][1] for i in range(N)]
b=[xl[i][0]-xl[i][1] for i in range(N)]
hiku=0
tmp=a[0]
for i in range(1, N):
  if b[i]<tmp:
    hiku+=1
  else:
    if a[i]>tmp:
      tmp=a[i]
      
print(N-hiku)

Failing test case input:
4
8 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from operator import itemgetter
N=int(input())
xl=[list(map(int, input().split())) for i in range(N)]
ab=[[xl[i][0]-xl[i][1], xl[i][0]+xl[i][1]] for i in range(N)]
ab=sorted(ab, key=itemgetter(0))
hiku=0
a=ab[0][0]
b=ab[0][1]
for i in range(1, N):
  if b>ab[i][0]:
    hiku+=1
    b=min(b, ab[i][1])
  else:
    b=ab[i][1]
      
print(N-hiku)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
XLlist = [tuple(map(int, input().split())) for _ in range(N)]
XLlist.sort(reverse=True)
ans = 1
tikan = -1
x, l = XLlist[0]
ll = x - (l - 1)
for x, l in XLlist:
    l -= 1
    rl = x + l
    if rl < ll:
        ans += 1
        ll = x - l
    else:
        tikan += 1
        ll = max(ll, x - l)

print(N - tikan)


Failing test case input:
5
10 1
2 2
4 1
6 1
8 2

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
XLlist = [tuple(map(int, input().split())) for _ in range(N)]
XLlist.sort(key=lambda x: x[0])
ans = 1
x, l = XLlist[0]
rl = x + (l - 1)
for x, l in XLlist:
    ll = x - l
    if ll <= rl:
        rl = min(rl, x + l - 1)
    else:
        ans += 1
        rl = x + l - 1

print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:x[0])
ans = 1
x, l = xls[0]
for i in range(1, n):
    nx, nl = xls[i]
    if nx-nl+1<x+l: continue
    ans += 1
    x, l = nx, nl
print(ans)

Failing test case input:
4
4 80
0 1
2 2
001 8

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:sum(x))

ans = 0
now = -1e11
for i in range(n):
    if now<=xls[i][0]-xls[i][1]:
        ans += 1
        now = xls[i][0]+xls[i][1]
print(ans)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    N = int(input())
    X = []
    L = []
    for i in range(N):
        x, l = [int(s) for s in input().split()]
        X.append(x)
        L.append(l)

    ranges = []
    for i in range(N):
        ranges.append((X[i] - L[i], X[i] + L[i]))
    ranges.sort(key=lambda x: x[0])

    cnt = len(ranges)
    end = ranges[0][1]
    for i in range(1, len(ranges)):
        if ranges[i][0] < end:
            cnt -= 1
    print(cnt)

if __name__ == "__main__":
    main()


Failing test case input:
5
10 1
2 2
1 1
10 1
8 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    X = []
    L = []
    for i in range(N):
        x, l = [int(s) for s in input().split()]
        X.append(x)
        L.append(l)

    ranges = []
    for i in range(N):
        ranges.append((X[i] - L[i], X[i] + L[i]))
    ranges.sort(key=lambda x: x[1])

    cnt = len(ranges)
    end = ranges[0][1]
    for i in range(1, len(ranges)):
        if ranges[i][0] < end:
            cnt -= 1
        else:
            end = ranges[i][1]
    print(cnt)


if __name__ == "__main__":
    main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

xl =[]
for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l+1,x+l-1])
xl.sort(key=lambda x: x[1])

arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm < xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt) 

Failing test case input:
4
4 57
8 4
1 4
001 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())

xl =[]
for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l,x+l])
xl.sort(key=lambda x: x[1])

arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm <= xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n = int(input())
X = []
L = []
T = []
for i in range(n):
    a, b = map(int, input().split())
    T.append( (a-b, a+b) )
    X.append(a)
    L.append(b)

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

ans = 1
cur = T[0][0]
for k, v in enumerate(T):
    if k == 0: continue
    if v[1] <= cur:
        ans += 1
        cur = T[k][0]

print(ans)



Failing test case input:
4
4 45
8 4
1 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):


n = int(input())
T = []

for i in range(n):
    a, b = map(int, input().split())
    T.append( (a-b, a+b) )

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

ans = 1
cur = T[0]

for k, v in enumerate(T):
    if k == 0: continue
    if v[0] >= cur[1]:
        ans += 1
        cur = v

print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xl_lis = []
for i in range(n):
    xl_lis.append(list(map(int, input().split())))
fe_lis = []
for x, l in xl_lis:
    fe_lis.append([x - l, x + l])
curr = float("-inf")
cnt = 0
for f, e in fe_lis:
    if curr <= f:
        cnt += 1
        curr = e
print(cnt)        

Failing test case input:
4
4 45
8 4
1 2
101 4

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
xl_lis = []
for i in range(n):
    xl_lis.append(list(map(int, input().split())))
fe_lis = []

for x, l in xl_lis:
    fe_lis.append([x - l, x + l])
fe_lis.sort(key = lambda x:x[1])        
curr = float("-inf")
cnt = 0
for f, e in fe_lis:
    if curr <= f:
        cnt += 1
        curr = e
print(cnt)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A.sort(key=lambda x:x[0])
X = []
L = []
for l in A:
    X.append(l[0])
    L.append(l[1])

pl = X[0] + L[0]
k = 0
for i in range(1, N):
    pr = X[i] - L[i]
    if pl > pr:
        k += 1
    else:
        pl = min(pl, X[i] + L[i])

pr = X[N - 1] - L[N - 1]
t = 0
for i in range(N - 2, -1, -1):
    pl = X[i] + L[i]
    if pl > pr:
        t += 1
    else:
        pr = X[i] - L[i]

print(max(N - k, N - t))

Failing test case input:
5
10 1
2 2
0 1
6 1
8 2

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A.sort(key=lambda x:x[0])
X = []
L = []
for l in A:
    X.append(l[0])
    L.append(l[1])

pl = X[0] + L[0]
k = 0
for i in range(1, N):
    pr = X[i] - L[i]
    if pl > pr:
        k += 1
        pl = min(pl, X[i] + L[i])
    else:
        pl = X[i] + L[i]


print(N - k)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
INF = 2 * (10 ** 9) - 1

n = int(input())
xl = [[0] * 2 for i in range(n)]
for i in range(n) :
    x, l = map(int, input().split())
    xl[i][0] = x-l+1
    xl[i][1] = x+l-1

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

cnt = 0

cur = -10 ** 10
ans = 0

for i in range(n) :
    if cur < xl[i][0] :
        
        ans += 1
        cur = xl[i][1]
        


print(ans)


Failing test case input:
4
4 57
8 4
1 4
001 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
INF = 2 * (10 ** 9) - 1

n = int(input())
xl = [[0] * 2 for i in range(n)]
for i in range(n) :
    x, l = map(int, input().split())
    xl[i][0] = x-l
    xl[i][1] = x+l

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

cnt = 0

cur = -10 ** 10
ans = 0

for i in range(n) :
    if cur <= xl[i][0] :
        
        ans += 1
        cur = xl[i][1]
        


print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
w=[]
for i in range(n):
    x,l=map(int,input().split())
    w.append([x-l,x+l])
w=sorted(w)
val=-(10**10)
ans=0
for i in range(n):
    if val<=w[i][0]:
        ans+=1
        val=w[i][1]
print(ans)


Failing test case input:
4
8 80
8 4
2 2
001 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
w=[]
for i in range(n):
    x,l=map(int,input().split())
    w.append([x-l,x+l])
w.sort(key=lambda x: x[1])
val=-(10**10)
ans=0
for i in range(n):
    if val<=w[i][0]:
        ans+=1
        val=w[i][1]
print(ans)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a = int(input())
fanwei = []

for i in range(a):
    one = input().split()
    one = [int(i) for i in one]
    two = [one[0] - one[1], one[0] + one[1]]
    fanwei.append(two)

fanwei = sorted(fanwei, key=lambda student: 100000000000000000000 * (1 + student[0]) + student[1])

now = -100000000000000000000
ans = 0
for i in fanwei:
    down = i[0]
    if down >= now:
        ans += 1
        now = i[1]

print(ans)


Failing test case input:
4
4 45
8 4
1 2
101 4

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
a = int(input())
fanwei = []

for i in range(a):
    one = input().split()
    one = [int(i) for i in one]
    two = [one[0] - one[1], one[0] + one[1]]
    fanwei.append(two)

fanwei = sorted(fanwei, key=lambda student: student[0] + 100000000000000000000 * student[1])

now = -100000000000000000000
ans = 0
for i in fanwei[:]:
    down = i[0]
    if down >= now:
        ans += 1
        now = i[1]


print(ans)