ZhenlongDai/ACPR huggingface dataset:
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys; readline = sys.stdin.readline

N = int(readline())
X, L = zip(*[map(int, readline().split()) for i in range(N)])

rm = -10000000
dropc = 0
for i in range(N):
    if X[i] - L[i] < rm:
        if rm > X[i] + L[i]:
            rm = X[i] + L[i]
        dropc += 1
    else:
        rm = X[i] + L[i]

print(N - dropc)


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

Expected output:
5

Actual output:
4


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

N = int(readline())
XL = [list(map(int, readline().split())) for i in range(N)]
XL.sort()
X, L = zip(*XL)

rm = -10000000
dropc = 0
for i in range(N):
    if X[i] - L[i] < rm:
        if rm > X[i] + L[i]:
            rm = X[i] + L[i]
        dropc += 1
    else:
        rm = X[i] + L[i]

print(N - dropc)

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

n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
xl2 = sorted([[x + l, x - l] for x, l in xl])

ans = 0
mr = xl2[0][0] - 1
for r, l in xl2:
    if l > mr:
        ans += 1
        mr = r
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):
import sys
input = sys.stdin.readline

n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
xl2 = sorted([[x + l, x - l] for x, l in xl])

ans = 0
mr = xl2[0][1]
for r, l in xl2:
    if l >= mr:
        ans += 1
        mr = r
print(ans)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

P = [[x - l, x, x + l] for x, l in XL]
P.sort(key=lambda x: x[2])

leave = []
for i in range(N):
    
    
    if len(list([p for p in leave if p[1] >= P[i][0]])) == 0:
        leave.append(P[i])
        
    else:
        
        continue

print(len(leave))

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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]

P.sort(key=lambda x: x[0]+x[1])

leave = [P[0]]
for i in range(1, N):
    
    leave_max = leave[-1][0] + leave[-1][1]
    p_min = P[i][0] - P[i][1]
    if leave_max <= p_min:
        leave.append(P[i])
    else:
        continue
        
print(len(leave))

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
R = []
for _ in range(n):
    x, l = map(int, input().split())
    R.append((x+l-1, x-l+1))
R.sort()

ans = n
last = -1e10
for r, l in R:
    if last >= l:
        ans -= 1
    else:
        last = r
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())
R = []
for _ in range(n):
    x, l = map(int, input().split())
    R.append((x+l, x-l))
R.sort()

ans = 0
last = -1e10
for r, l in R:
    if last <= l:
        ans += 1
        last = r
print(ans)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
ans=0
xl.sort()
if n==1:
    print(1)
    quit()

for i in range(n-1):
    if xl[i][0]==-1:
        continue
    else:
        if xl[i][0]+xl[i][1]>xl[i+1][0]-xl[i+1][1]:
            ans+=1
            if xl[i][0]+xl[i][1]>xl[i+1][0]+xl[i+1][1]:
                xl[i][0]=-1
            else:
                xl[i+1][0]=-1

print(n-ans)

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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
from collections import deque



ans=0
xl.sort()


d=deque(xl)
while d:
    tmp=d.popleft()
    while d:
        if tmp[0]+tmp[1]>d[0][0]-d[0][1]:
            ans+=1
            if tmp[0]+tmp[1]>d[0][0]+d[0][1]:
                
                break
            elif tmp[0]-tmp[1]>d[0][0]-d[0][1]:
                d.popleft()
            else:
                d.popleft()
        else:
            break
if n==1:
    print(1)
    quit()

print(n-ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
robots = sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])

x_max = -10**10
ans = 0
for x, l in robots:
    if x - l >= x_max:
        ans += 1
        x_max = x + l
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())
robots = []
for _ in range(N):
    x, l = map(int, input().split())
    robots.append((x-l, x+l))
robots = sorted(robots, key=lambda x: x[1])

x_max = -10**10
ans = 0
for s, t in robots:
    if s < x_max:
        continue
    ans += 1
    x_max = t
print(ans)

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

ans = 0
last = -float('inf')
for l, r in robot:
  if last <= l:
    ans += 1
    last = r
    
print(ans)

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
robots = [tuple(map(int,input().split())) for _ in range(N)]
 
robots = [(x+l,x-l) for x,l in robots]
 
robots.sort()
 
cnt = 0
last = -float('inf')
for r,l in robots:
    if last <= l:
        cnt += 1
        last = r
 
print(cnt)
Problem: p02796
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
pos_list = []
for _ in range(N):
    X, L = map(int, input().split())
    pos_list.append([X - L, X + L])
sorted_data = sorted(pos_list, key=lambda x: (x[0], -x[1]))

ans = 0
current = -(10 ** 9)
for val in sorted_data:
    if current <= val[0]:
        ans += 1
        current = val[1]
print(ans)


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())
pos_list = []
for _ in range(N):
    X, L = map(int, input().split())
    pos_list.append([X + L, X - L])
sorted_data = sorted(pos_list)

ans = 0
current = -(10 ** 9)
for val in sorted_data:
    if current <= val[1]:
        ans += 1
        current = val[0]
print(ans)

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

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

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

start = l[0][1]
ans = 1
for i in range(1,N):
    if start <= l[i][0]:
        start = l[i][0]
        ans += 1

print(ans)

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

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
l = []

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

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

start = l[0][1]
ans = 1
for i in range(1,N):
    if start <= l[i][0]:
        start = l[i][1]
        ans += 1

print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    robot = int(input())
    right_lim = 0
    answer = 1
    robot_info = [tuple(map(int, input().split())) for _ in range(robot)]
    robot_info = sorted(robot_info, key=lambda x: x[0])
    for i in range(robot):
        coordinate, arm_length = robot_info[i]
        if i == 0:
            right_lim = coordinate + arm_length - 1
        elif right_lim <= coordinate - arm_length:
            answer += 1
            right_lim = coordinate + arm_length - 1
    print(answer)


if __name__ == '__main__':
    main()



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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
def main():
    robot = int(input())
    right_lim = 0
    answer = 1
    robot_info = []
    for _ in range(robot):
        coordinate, arm_length = map(int, input().split())
        robot_info.append([coordinate - arm_length, coordinate + arm_length])
    robot_info = sorted(robot_info, key=lambda x: x[1])
    for i in range(robot):
        if i == 0:
            right_lim = robot_info[i][1]
        elif right_lim <= robot_info[i][0]:
            right_lim = robot_info[i][1]
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
lst = []
for i in range(n):
    x, l = map(int, input().split())
    lst.append((x + l, x - l))

sorted_lst = sorted(lst)
num = 0
ans = n
while True:
    tmp = sorted_lst[num][0]
    for i in range(num + 1, n):
        if tmp > sorted_lst[i][1]:
            ans -= 1
            print(num, i)
        else:
            num = i
            break
        if i == n - 1:
            num = i
            break
    if num == n - 1:
        break

print(ans)

Failing test case input:
4
2 5
4 3
14 3
100 5

Expected output:
3


Actual output:
0 1
3


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

sorted_lst = sorted(lst)
num = 0
ans = n
while True:
    tmp = sorted_lst[num][0]
    for i in range(num + 1, n):
        if tmp > sorted_lst[i][1]:
            ans -= 1
        else:
            num = i
            break
        if i == n - 1:
            num = i
            break
    if num == n - 1:
        break

print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def acinput():
    return list(map(int, input().split(" ")))

N=int(input())
bars=[]
for i in range(N):
    tmp = acinput()
    tmp.extend([tmp[0]-tmp[1],tmp[0]+tmp[1]])
    bars.append(tmp)

bars=sorted(bars,key=lambda x:x[3])

print(bars)

count=0
R=-10000000000
for i in range(0,N):

    if R<=bars[i][2]:
        R=bars[i][3]
        count+=1


print(count)


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

Expected output:
2


Actual output:
[[8, 2, 6, 10], [8, 2, 6, 10], [4, 32, -28, 36], [101, 6, 95, 107]]
2


Fixed submission (verdict: Accepted):
def acinput():
    return list(map(int, input().split(" ")))

N=int(input())
bars=[]
for i in range(N):
    tmp = acinput()
    tmp.extend([tmp[0]-tmp[1],tmp[0]+tmp[1]])
    bars.append(tmp)

bars=sorted(bars,key=lambda x:x[3])



count=0
R=-10000000000
for i in range(0,N):

    if R<=bars[i][2]:
        R=bars[i][3]
        count+=1


print(count)

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

N = int(input())
R = []

for i in range(N):
	x,l = map(int, input().split())
	R.append([max(x-l+1,0),x+l-1])
R.sort(key = lambda r : r[1])

ans = N
lr = -1
for i in range(N):
	if(lr >= R[i][0]):
		ans -=1
		continue
	else:
		lr = R[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):
import sys
input = sys.stdin.readline

N = int(input())
R = []

for i in range(N):
	x,l = map(int, input().split())
	R.append([max(x-l,0),x+l])
R.sort(key = lambda r : r[1])

ans = N
lr = -1
for i in range(N):
	if(lr > R[i][0]):
		ans -=1
		continue
	else:
		lr = R[i][1]
print(ans)
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 = sorted(A, key = lambda x:x[0])

now = 0
cnt = 0
for i in range(n):
    if now < A[i][0]:
        now = A[i][0] + A[i][1]
        cnt += 1
print(cnt)


Failing test case input:
2
16 20
1 6

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
A = []
for i in range(n):
    a,l = map(int,input().split())
    A.append([a-l,a+l])
A = sorted(A,key = lambda x:x[1])



cnt = 0
now = -(1<<60)
for i in range(n):
    f,s = A[i]
    if now > f:
        continue
    cnt += 1
    now = s
print(cnt)

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

N = int(input())
cnt = 0
L = []
for i in range(N):
    x, l = map(int, input().split())
    L.append([x, l])

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

for i in range(N):
    x, l = L[i]
    if i == 0:
        px, pl = L[i]
    else:
        if px + pl >  x - l:
            cnt += 1
        else:
            px, pl = x, l
print(N - 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())
cnt = 0
L = []
for i in range(N):
    x, l = map(int, input().split())
    L.append([x, l])

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

for i in range(N):
    x, l = L[i]
    if i == 0:
        px, pl = x, l
    else:
        if px + pl >  x - l:
            cnt += 1
            if px + pl > x + l:
                px, pl = x, l
        else:
            px, pl = x, l
print(N - cnt)

Problem: p02796
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
ls = [(0, 0)] * n
for i in range(n):
    x, ln = map(int, input().split())
    l = x - ln
    r = x + ln
    ls[i] = (l, x)


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

last = -float('inf')
count = 0
for i in ls:
    if last <= i[0]:
        count += 1
        last = i[1]
print(count)

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

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
ls = [(0, 0)] * n
for i in range(n):
    x, ln = map(int, input().split())
    l = x - ln
    r = x + ln
    ls[i] = (l, r)


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

last = -float('inf')
count = 0
for i in ls:
    if last <= i[0]:
        count += 1
        last = i[1]
print(count)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
xs = []
r = 1
for i in range(N):
    x, l = map(int, input().split())
    a,b = x-l, x+l
    xs.append((a,b))
xs.sort()
for i, (a, b) in enumerate(xs):
    if i == 0:
        ba, bb= a, b
        continue
    if a<bb:
        continue
    else:
         ba, bb = a, b
         r += 1
print(r)


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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
xs = []
r = 1
for i in range(N):
    x, l = map(int, input().split())
    a,b = x-l, x+l
    xs.append((a,b))
xs.sort()
xs = xs[::-1]
for i, (a, b) in enumerate(xs):
    if i == 0:
        ba, bb= a, b
        continue
    if ba<b:
        continue
    else:
         ba, bb = a, b
         r += 1
print(r)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), 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[0])

ans = 1
t = XL[0][1]
for i in range(1,N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][1]
print(ans)

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())
XL = []
for i in range(N):
    x,l = map(int,input().split())
    XL.append((x-l,x+l-1))

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

ans = 0
t = -10**10
for i in range(N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][1]
print(ans)

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 = sorted(xl)

pre = 0
cnt = 0
for x, l in xl:
    if pre == 0:
        pre = x + l
        continue

    if x - l < pre:
        cnt += 1
    else:
        pre = x + l

pre = 0
cnt1 = 0
xl = xl[::-1]
for x, l in xl:
    if pre == 0:
        pre = x - l
        continue

    if x + l > pre:
        cnt += 1
    else:
        pre = x - l

cnt = min(cnt, cnt1)
print(n - cnt)

Failing test case input:
2
12 20
1 13

Expected output:
1


Actual output:
2


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

pre = 0
cnt = 0
for x, l in xl:
    if pre == 0:
        pre = x + l
        continue

    if x - l < pre <= x + l:
        cnt += 1
    elif x + l < pre:
        cnt += 1
        pre = x + l
    else:
        pre = x + l

print(n - cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
data = [[]]*n
for i in range(n):
    x, l = map(int, input().split())
    data[i] = [x-l,x+l]
data.sort()
ans = 0
prev_r = -10**18
for i in range(n):
    if prev_r >  data[i][0]:
      continue
    ans += 1
    prev_r = data[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):
from operator import itemgetter

n = int(input())
data = [()]*n
for i in range(n):
    x, l = map(int, input().split())
    data[i] = (x-l,x+l)
data.sort(key = itemgetter(1))
ans = 0
prev_r = -10**18
for l, r in data:
    if prev_r >  l:
      continue
    ans += 1
    prev_r = r

print(ans)

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

result=n


for i  in range(n):
    xx,ll=map(int, input().split())
    lo.append(xx+ll)
    sh.append(xx-ll)
    

c=zip(sh,lo)
d=sorted(c)

for i in range(n-1):
    if d[i+1][0] == -1:
        break
    if d[i+1][0] < d[i][1]:
        result-=1
        del d[i+1]
        tmp=(-1,-1)
        d.append(tmp)

print(result)

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

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
lo=[]
sh=[]

result=0

MAX = -(10**20)

for i  in range(n):
    xx,ll=map(int, input().split())
    lo.append(xx+ll)
    sh.append(xx-ll)
    

c=zip(sh,lo)
d=sorted(c,key=lambda x:x[1])

for i in range(n):
    if MAX <= d[i][0]:
        result+=1
        MAX=d[i][1]

print(result)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: -lr[1])
count = 0
cur = LR[0][0]
for l, r in LR[1:]:
    if cur < r:
        count += 1
    else:
        cur = l
print(n - count)


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())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: lr[1])
count = 1
cur = LR[0][1]
for l, r in LR[1:]:
    if cur <= l:
        count += 1
        cur = r
print(count)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
ans=0
xxx=[list(map(int,input().split()))for _ in range(n)]
xxx.sort()
x,l=xxx[0]
for i in range(1,n):
  xx,ll=xxx[i]
  if x+l>xx-ll:ans+=1
  else:x,l=xx,ll
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())
a=[]
for i in range(n):
  x,l=map(int,input().split())
  a.append((x+l,2*l))
a.sort()
ans=1
x,l=a[0]
for i in range(1,n):
  xx,ll=a[i]
  if x<=xx-ll:
    ans+=1
    x,l=xx,ll
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 = sorted(robo, key=lambda x:x[1], reverse=True)
    robo = sorted(robo, key=lambda x: x[0])
    

    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:
4
4 80
0 1
2 2
001 4

Expected output:
1


Actual output:
2


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):
import sys
input=sys.stdin.buffer.readline

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

L.sort(key=lambda x:x[1])
ans=0
cur=-1
for a,b in L:
  if a>=cur:
    cur=b
    ans+=1
print(ans)

Failing test case input:
2
8 40
1 10

Expected output:
1


Actual output:
0


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

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

L.sort(key=lambda x:x[1])
ans=0
cur=-11111111111111111
for a,b in L:
  if a>=cur:
    cur=b
    ans+=1
print(ans)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), 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],x[0]))

ans = 0
t = -10**9
for i in range(N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][1]
print(ans)

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):
    x,l = map(int,input().split())
    XL.append((x-l,x+l-1))

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

ans = 0
t = -10**10
for i in range(N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][1]
print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

input = lambda: sys.stdin.readline().rstrip()

n = int(input())
X_L = []
X_L_append = X_L.append
for _ in range(n):
    x, l = map(int, input().split())
    X_L_append((x-l, x))
X_L.sort(reverse=True)

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

Failing test case input:
2
23 14
0 10

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys

input = lambda: sys.stdin.readline().rstrip()

n = int(input())
X_L = []
X_L_append = X_L.append
for _ in range(n):
    x, l = map(int, input().split())
    X_L_append((x+l, x-l))
X_L.sort()

ans = n
tmp = X_L[0][0]
for upper, lower in X_L[1:]:
  if lower < tmp:
    ans -= 1
  else:
    tmp = upper

print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter

N = int(input())
R = [0]*N
for i in range(N):
    X_i, L_i = map(int, input().split())
    R[i] = (X_i-L_i+1,X_i+L_i-1)
R.sort(key=itemgetter(1))

ans, loc = 0, -(float('inf'))
for i in range(len(R)):
    if loc < R[i][0]:
        ans += 1
        loc = R[i][1]
print(ans)

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):
from operator import itemgetter

N = int(input())
R = [0]*N
for i in range(N):
    X_i, L_i = map(int, input().split())
    R[i] = (X_i-L_i,X_i+L_i)
R.sort(key=itemgetter(1))

ans, loc = 0, -(float('inf'))
for i in range(len(R)):
    if loc <= R[i][0]:
        ans += 1
        loc = R[i][1]
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -1
for s, e in target:
    
    if s < before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)

Failing test case input:
2
16 14
0 10

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -float("inf")
for s, e in target:
    
    if s < before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    X,L = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((X-L,X+L))

ans = 0
left = -10**9-1
for j,k in sorted(data):
    if j >= left:
        left = k
        ans += 1
print(ans)

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    X,L = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((X+L,X-L))

ans = 0
left = -10**9-1
for k,j in sorted(data):
    if j >= left:
        left = k
        ans += 1
print(ans)

Problem: p02796
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = []
for _ in range(n):
    a.append(list(map(int,input().split())))

d = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]

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


b = [-100000000000000000]
c = [0]


for i in range(n):
    for j in range(len(b)):
        if d[i][0] >= b[j]:
            b = [d[i][1]]
            c = [c[j] + 1]
            break
        else:
            b.append(d[i][1])
            c.append(c[j]+1)
    
    
    

print(max(c))
        
    


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

Expected output:
1


Actual output:
4


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

d = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]

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


b = [-100000000000000000]
c = [0]


for i in range(n):
    for j in range(len(b)):
        if d[i][0] >= b[j]:
            b = [d[i][1]]
            c = [c[j] + 1]
            break

    
    
    

print(max(c))

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n = int(input())
xl = []
for _ in range(n):
    x, l = map(int, input().split())
    xl.append((x, l))
xl.sort(key=lambda x:x[0])
i = 0
if n==1:
    print(1)
    sys.exit(0)
while i<len(xl)-1:
    if xl[i][0]+xl[i][1] <= xl[i+1][0]-xl[i+1][1]:
        i += 1
    else:
        del xl[i+1]
print(len(xl))

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
n = int(input())
xl = []
for _ in range(n):
    x, l = map(int, input().split())
    xl.append((x, l))
xl.sort(key=lambda x:x[0])
i = 0
if n==1:
    print(1)
    sys.exit(0)
while i<len(xl)-1:
    if xl[i][0]+xl[i][1] <= xl[i+1][0]-xl[i+1][1]:
        i += 1
    else:
        if xl[i][0]+xl[i][1] < xl[i+1][0]+xl[i+1][1]:
            del xl[i+1]
        else:
            del xl[i]
print(len(xl))
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
ab=[]
for i in range(n):
    x=xl[i][0]
    l=xl[i][1]
    a=x-l
    b=x+l
    ab.append([a,b])
ab.sort(key=lambda x:x[1],reverse=True)
A=float("inf")
cnt=0
for i in range(n):
    a=ab[i][0]
    b=ab[i][1]
    if b<=A:
        cnt+=1
        A=a
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):
import sys
input = sys.stdin.readline
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
ab=[]
for i in range(n):
    x=xl[i][0]
    l=xl[i][1]
    a=x-l
    b=x+l
    ab.append([a,b])
ab.sort(key=lambda x:x[1])
B=-float("inf")
cnt=0
for i in range(n):
    a=ab[i][0]
    b=ab[i][1]
    if a>=B:
        cnt+=1
        B=b
print(cnt)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())

robos = []
for i in range(N):
    x, l = map(int, input().split())
    robos.append((x, l))

robos.sort()

kosuu = 0
maenomigi = -100000000000000000000000
for x, l in robos:
    
    if maenomigi <= x - l:
        maenomigi = x + l
        kosuu += 1

print(kosuu)


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())

robos = []
for i in range(N):
    x, l = map(int, input().split())
    robos.append((x + l, x - l))

robos.sort()

kosuu = 0
maenomigi = -100000000000000000000000
for migi, hidari in robos:
    
    if maenomigi <= hidari:
        maenomigi = migi
        kosuu += 1

print(kosuu)

Problem: p02796
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
XL = []
for _ in range(n):
    x, l = map(int, input().split())
    XL.append([x-l, x+l])
XL.sort()
XL += [-1]
i = 0
cnt = 1
before = XL[0][1]
while XL[i] != -1:
    if before <= XL[i][0]:
        before = XL[i][1]
        cnt += 1
    i += 1
print(cnt)


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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from operator import itemgetter

n = int(input())
XL = []
for _ in range(n):
    x, l = map(int, input().split())
    XL.append([x-l, x+l])
XL.sort(key=itemgetter(1))
INF = 10**18
cur = -INF
ans = 0
for i in range(n):
    if cur <= XL[i][0]:
        ans += 1
        cur = XL[i][1]
print(ans)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

n = int(input())
x_l = [0]*n
x_plus_l = [0]*n








for i in range(n):
    x,l = map(int,input().split())
    x_l[i] = x-l
    x_plus_l[i] = x+l
x_l,x_plus_l = zip(*sorted(zip(x_l,x_plus_l)))
cnt = 1
i = 1
X = min(x_plus_l)


while i < n:
    if x_l[i] >= X:
        cnt += 1
        
    else:
        if cnt != 1:
            X = max(X,x_plus_l[i])
    i += 1
print(cnt)

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):

n = int(input())
x_l = [0]*n
x_plus_l = [0]*n








for i in range(n):
    x,l = map(int,input().split())
    x_l[i] = x-l
    x_plus_l[i] = x+l
x_l,x_plus_l = zip(*sorted(zip(x_l,x_plus_l)))
cnt = 1
i = 1
X = min(x_plus_l)


while i < n:
    if x_l[i] >= X:
        cnt += 1
        X = x_plus_l[i]
        
    else:
        if cnt != 1:
            X = min(X,x_plus_l[i])
    i += 1
print(cnt)

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

A = []
for i in range(N):
    x, l = map(int, input().split())
    
    
    A.append((x - l, x + l))

A.sort(key=lambda x: x[1])
ans = 0
x = -10e50
for i in range(N):
    l, r = A[i]
    if x <= l:
        ans += 1
        x = r-1

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())

A = []
for i in range(N):
    x, l = map(int, input().split())
    
    
    A.append((x - l, x + l))

A.sort(key=lambda x: x[1])
ans = 0
x = -10e50
for i in range(N):
    l, r = A[i]
    if x <= l:
        ans += 1
        x = r

print(ans)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
Y = []
for s in inputs[1:]:
    x, l = map(int, s.split())
    Y.append((x-l+1, x+l-1))
Y.sort(key=lambda x: x[0])

cnt = 0
l0, r0 = Y[0]
for i in range(1, n):
    l, r = Y[i]
    if r0 >= l:
        cnt += 1
        if r0 > r:
            l0, r0 = l, r
    else:
        l0, r0 = l, r
print(n-cnt)

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):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
Y = []
for s in inputs[1:]:
    x, l = map(int, s.split())
    Y.append((x-l, x+l))
Y.sort(key=lambda x: x[1])

cnt = 1
_, r0 = Y[0]
for i in range(1, n):
    l, r = Y[i]
    if r0 <= l:
        cnt += 1
        r0 = r
    
print(cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
robots = [tuple(map(int,input().split())) for _ in range(N)]

print(robots)

robots = [(x+l,x-l) for x,l in robots]
print(robots)

robots.sort()
print(robots)

cnt = 0
last = -float('inf')
for r,l in robots:
    print(last, l, r)
    
    if last <= l:
        cnt += 1
        
        last = r

print(cnt)

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

Expected output:
2


Actual output:
[(7, 32), (8, 3), (6, 2), (101, 4)]
[(39, -25), (11, 5), (8, 4), (105, 97)]
[(8, 4), (11, 5), (39, -25), (105, 97)]
-inf 4 8
8 5 11
8 -25 39
8 97 105
2


Fixed submission (verdict: Accepted):
N = int(input())
robots = [tuple(map(int,input().split())) for _ in range(N)]



robots = [(x+l,x-l) for x,l in robots]


robots.sort()


cnt = 0
last = -float('inf')
for r,l in robots:
    
    
    if last <= l:
        cnt += 1
        
        last = r

print(cnt)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
from collections import deque

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    l = []
    for _ in range(N):
        X, L = MAP()
        l.append([X-L, X+L])

    q = deque(sorted(l, key=lambda x: (x[0], x[1])))

    cnt = N
    xm, xl = q.popleft()
    for i in range(N-1):
        nm, nl = q.popleft()
        if nm < xl:
            cnt -= 1
        else:
            xm = nm
            xl = nl

    print(cnt)


if __name__ == '__main__':
    main()

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

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
from collections import deque

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    l = []
    for _ in range(N):
        X, L = MAP()
        l.append([X-L, X+L])

    q = deque(sorted(l, key=lambda x: (x[0], x[1])))

    cnt = N
    xm, xl = q.popleft()
    for i in range(N-1):
        nm, nl = q.popleft()
        if nm < xl:
            cnt -= 1
            if nl < xl:
                xm = nm
                xl = nl
        else:
            xm = nm
            xl = nl

    print(cnt)


if __name__ == '__main__':
    main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a.sort()
a.append([10**9+1,0])
ans = 0
left = [a[0]]
for i in range(1,n):
  if a[i][0]-a[i][1] >= left[-1][0]+a[-1][1]:
    left.append(a[i-1])
print(len(left))

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())
a = [list(map(int,input().split())) for i in range(n)]
a = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]
a.sort(key = lambda x:x[1])
ans = 1
g = a[0][1]
for i in range(1,n):
  x = a[i][0]
  if g<=x:
    ans += 1
    g = a[i][1]
print(ans)
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])
xl.sort(key = lambda x: x[1])
ans = 0
arm = 0
for i in range(n):
    if arm <= xl[i][0]:
        ans += 1
        arm = xl[i][1]
print(ans)

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

Expected output:
3


Actual output:
4


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])
ans = 0
arm = -10**18
for i in range(n):
    if arm<=xl[i][0]:
        ans += 1
        arm = xl[i][1]
print(ans)

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

array = [[0]*2 for i in range(N)] 

tmp = 0
for i in range(N):
    x, l = map(int, input().split())
    lower = x-l
    if x-l <= 0:
        lower = 0
    higher =  x+l

    array[i][0] = lower
    array[i][1] = higher

array.sort()
flg = 0
for i in range(len(array)-1):

    if flg == 1: continue
    if array[i+1][0] < array[i][1]:
        tmp += 1
        flg = 1
        continue
    flg = 0
print(len(array)-tmp)

Failing test case input:
4
4 16
8 3
6 2
101 5

Expected output:
2


Actual output:
3


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

num_array = [[0]*2 for i in range(N)]
for i in range(N):
    x, l = map(int, input().split())
    small = x-l
    if small <= 0:
        small = 0
    big = x+l

    num_array[i][1] = small
    num_array[i][0] = big

num_array.sort()

tmp_r = -(10**18)
count = 0
for r, l in num_array:
    if tmp_r > l:
        continue
    count += 1
    tmp_r = r

print(count)

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

XL = sorted(XL, key=lambda x: x[0]+x[1])

cnt = 0
prev_right = -10**9+10
for x, l in XL:
    left = x - l + 1
    right = x + l - 1
    if left > prev_right:
        cnt += 1
        prev_right = right

print(cnt)


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

Expected output:
3


Actual output:
4


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

XL = sorted(XL, key=lambda x: x[0]+x[1])

cnt = 0
prev_right = -10**9+10
for x, l in XL:
    left = x - l
    right = x + l
    if left >= prev_right:
        cnt += 1
        prev_right = right

print(cnt)
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]-1:
        ans -= 1
    else:
        m = XL[i][0]-XL[i][1]+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())
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 sys
N = int(sys.stdin.readline().rstrip())
sec = []

for _ in range(N):
    x, l = map(int, sys.stdin.readline().rstrip().split())
    sec.append((x - l + 1, x + l - 1))

sec = sorted(sec, key=lambda x: x[1])
r = -10**10
ans = 0
for s, t in sec:
    if r <= s:
        ans += 1
        r = t
print(ans)

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):
import sys
N = int(sys.stdin.readline().rstrip())
sec = []

for _ in range(N):
    x, l = map(int, sys.stdin.readline().rstrip().split())
    sec.append((x - l, x + l))

sec = sorted(sec, key=lambda x: x[1])
r = -10**10
ans = 0
for s, t in sec:
    if r <= s:
        ans += 1
        r = t
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys


def main():
    input = sys.stdin.readline
    N = int(input())

    robots = dict()
    inversed = dict()

    for i in range(N):
        x, arm = map(int, input().split())
        right = x+arm
        robots[x] = right
        inversed[right] = x

    orderd_r = sorted(inversed.keys())
    order = [inversed[r] for r in orderd_r]

    count = 0
    last_r = -10**10
    for x in order:
        r = robots[x]
        l = x - (r - x)
        if l < last_r:
            count += 1
        else:
            last_r = r

    print(N - count)


if __name__ == '__main__':
    main()


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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys


def main():
    input = sys.stdin.readline
    N = int(input())

    robots = list()

    for i in range(N):
        x, arm = map(int, input().split())
        right = x+arm
        robots.append([x, right])

    robots.sort(key=lambda x: x[1])
    count = 0
    last_r = -10**10
    for x, r in robots:
        l = x - (r - x)
        if l < last_r:
            count += 1
        else:
            last_r = r

    print(N - count)


if __name__ == '__main__':
    main()
Problem: p02796
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
X = [[] for _ in range(n)]
for i in range(n):
    x,l = list(map(int, input().split()))
    X[i] = [x-l,x+l]

X.sort(key = lambda x: x[1])
cnt = 0
rIdx = 1
for lIdx in range(n):
    while (lIdx<rIdx<n and X[rIdx][0]<X[lIdx][1]):
        X[rIdx][1] = -1
        rIdx += 1
        cnt += 1
    if rIdx == lIdx:
        rIdx += 1
print(n-cnt)

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

Expected output:
2


Actual output:
3


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

X.sort(key = lambda x: x[1])
cnt = 1
mx = X[0][1]
for i in range(1,n):
    if mx <= X[i][0]:
        cnt += 1
        mx = X[i][1]
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 = X[i] + L[i]
print(N - k)

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())
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):
N = int(input())

arms_range_list =[]
for _ in range(N):
    X, L = map(int, input().split())
    arms_range_list.append((X-L, X+L))

arms_range_list = sorted(arms_range_list)


count = 0
max_arm_position_now = -float('inf')
for i in range(N):
    min_arm_position_next = arms_range_list[i][0]
    if min_arm_position_next >= max_arm_position_now:
        max_arm_position_now = arms_range_list[i][1]
        count += 1


print(count)

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

Expected output:
3


Actual output:
2


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

arms_range_list =[]
for _ in range(N):
    X, L = map(int, input().split())
    arms_range_list.append((X-L, X+L))

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


count = 0
max_arm_position_now = -int(1e10)
for i in range(N):
    min_arm_position_next = arms_range_list[i][0]
    if min_arm_position_next >= max_arm_position_now:
        max_arm_position_now = arms_range_list[i][1]
        count += 1


print(count)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
d = [[0, 0] for _ in range(n)]
for i in range(n):
    d[i] = list(map(int, input().split()))
d = [[dd[0], dd[1], dd[0]+dd[1]] for dd in d]
d.sort(key=lambda x: x[2])
ans = 0
target = 0
for dd in d:
    if target == 0:
        ans += 1
        target = dd[2]
    else:
        if dd[0] - dd[1] < target < dd[0] + dd[1]:
            ans += 1
        else:
            target = dd[2]
print(n-ans+1)


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

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
d = [[0, 0] for _ in range(n)]
for i in range(n):
    d[i] = list(map(int, input().split()))
d = [[dd[0], dd[1], dd[0]+dd[1]] for dd in d]
d.sort(key=lambda x: x[2])
ans = 0
target = d[0][2]
for dd in d:
    if dd[0] - dd[1] < target:
        ans += 1
    else:
        target = dd[2]
print(n-ans+1)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = float("inf")

for s, e in target:
    
    if s >= before_e:
        
        answer += 1
    else:
        before_e = e
print(length - answer)

Failing test case input:
2
12 27
1 21

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -float("inf")
for s, e in target:
    
    if s < before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)

Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]
MM = []
for i in range(N):
    MM.append([XL[i][0]-XL[i][1], XL[i][0]+XL[i][1]])


XL = sorted(XL)
MM.sort(key=lambda x: x[0])
MM.sort(key=lambda x: x[1])
migi = []
for i in range(N):
    migi.append(MM[i][1])
    
dp = [0]*(N+1)
dp[0] = 1

for i in range(1,N):
    k = bisect.bisect_right(migi,MM[i][0]) - 1
    
    if k >= 0:
        dp[i] = dp[k] + 1

ans = max(dp)

print(ans)

Failing test case input:
4
4 32
4 4
1 2
101 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]
MM = []
for i in range(N):
    MM.append([XL[i][0]-XL[i][1], XL[i][0]+XL[i][1]])


XL = sorted(XL)
MM.sort(key=lambda x: x[0])
MM.sort(key=lambda x: x[1])
ans = 0
now  = -float('inf')
for i in range(N):
    if MM[i][0] >= now:
        ans += 1
        now = MM[i][1]
print(ans)