ZhenlongDai/ACPR huggingface dataset:
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n=int(input())
    xs=[0]*n
    ls=[0]*n
    ranges=[0]*n
    for i in range(n):
        xs[i],ls[i]=map(int,input().split())
        ranges[i]=[xs[i]-ls[i],xs[i]+ls[i]]
    ranges.sort(key=lambda x:x[1])
    count=0
    point=-10000
    for irange in ranges:
        if irange[0]>=point:
            count+=1
        point=irange[1]
    print(count)
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):
def main():
    n=int(input())
    xs=[0]*n
    ls=[0]*n
    ranges=[0]*n
    for i in range(n):
        xs[i],ls[i]=map(int,input().split())
        ranges[i]=[xs[i]-ls[i],xs[i]+ls[i]]
    ranges.sort(key=lambda x:x[1])
    count=0
    point=-1000000000000
    for irange in ranges:
        if irange[0]>=point:
            count+=1
            point=irange[1]
    print(count)
if __name__ == "__main__":
    main()

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

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

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

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

lines = []
for i in range(n):
  x,l = map(int,input().split())
  lines.append([x-l,x+l])
lines = sorted(lines)
count = 0
kari = -9999999999999
for i in range(n):
  if lines[i][0] >= kari:
    count += 1
    kari = lines[i][1]
print(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())
 
lines = []
for i in range(n):
  x,l = map(int,input().split())
  lines.append([x-l,x+l])
lines = sorted(lines,key=lambda x:x[1])
count = 0
kari = -9999999999999
for i in range(n):
  if lines[i][0] >= kari:
    count += 1
    kari = lines[i][1]
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])
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:
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 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):
n = int(input())
r = []
for i in range(n):
    x, l = map(int, input().split())
    r.append((x, l))
r.sort(key=lambda _x: _x[1])

used = set()
cnt = 0
for ri in r:
    arm = set(range(ri[0] - ri[1] + 1, ri[0] + ri[1]))
    
    if len(arm & used) > 0 and len(used) != 0:
        continue
    used |= arm
    cnt += 1
print(cnt)

Failing test case input:
2
23 14
0 10

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
r = []
for i in range(n):
    x, l = map(int, input().split())
    r.append((x - l, x + l))
r.sort(key=lambda _x: _x[1])
cnt = 1
limit = r[0][1]
for ri in r[1:]:
    if ri[0] >= limit:
        cnt += 1
        limit = ri[1]
print(cnt)

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

P = [0] * 150

robot = []

for i in range(N):
    X, L = map(int,input().split())

    robot.append([X,L])

robot = sorted(robot)

p_max = robot[0][0] + robot[0][1]
cnt = 1

for i in range(1,N):
    if p_max <= robot[i][0] - robot[i][1]:
        p_max  = robot[i][0] + robot[i][1]
        cnt += 1

print(cnt)

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

P = [0] * 150

robot = []

for i in range(N):
    X, L = map(int,input().split())

    left = X-L
    right = X+L

    
    robot.append([right,left])

robot = sorted(robot)

cnt = 0 
last_right = -float('inf') 

for i in range(N):
    if last_right <= robot[i][1]:
        cnt += 1
        last_right =  robot[i][0]

print(cnt)

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

temp = l[0][1]
count = n
i = 1
for i in range(1,n):
  if temp <= l[i][1]:
    temp = l[i][0]
  else:
    temp = min(temp,l[i][1])
    count -= 1
print(count)

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

Expected output:
3


Actual output:
4


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

temp = l[0][0]
count = n
i = 1
for i in range(1,n):
  if temp <= l[i][1]:
    temp = l[i][0]
  else:
    temp = min(temp,l[i][0])
    count -= 1
print(count)

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, x+l])

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

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


Failing test case input:
2
12 14
1 13

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 = sorted(R, key=lambda x: x[1])

ans = 0
tmp = -float('inf')
for l, r in R:
    if tmp <= l:
        ans += 1
        tmp = r
print(ans)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
hani=[]
for i in range(n):
    x,l=map(int,input().split())
    hani.append([x-l,x+l])
hani2=sorted(hani)
no=0 
bef=0
af=1
for i in range(n-1):
    a,b,a2,b2=hani[bef][0],hani[bef][1],hani[af][0],hani[af][1]
    if a<=a2<b:
        no+=1
        if b<b2: 
            af+=1
        else:
            bef+=1
            af+=1
    else:
        bef+=1
        af+=1
print(n-no)

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

Expected output:
2


Actual output:
3


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

no=0 
bef=0
af=1
for i in range(n-1):
    a,b,a2,b2=hani2[bef][0],hani2[bef][1],hani2[af][0],hani2[af][1]
    if a<=a2<b:
        no+=1
        if b<b2: 
            af+=1
        else:
            bef=af
            af+=1
    else:
        bef=af
        af+=1
print(n-no)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x_l = []
for i in range(n):
    x,l = map(int,input().split())
    x_l.append([x-l,x+l])
x_l = sorted(x_l, key=lambda x:x[0])
ans = n
for i in range(n-1):
    if x_l[i][1] > x_l[i+1][0]:
        ans -= 1
        x_l[i+1] = x_l[i]
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):
n = int(input())
x_l = []
for i in range(n):
    x,l = map(int,input().split())
    x_l.append([x-l,x+l])
x_l = sorted(x_l, key=lambda x:x[0])
x_r = sorted(x_l, key=lambda x:x[1])
ans_l = n
ans_r = n
for i in range(n-1):
    if x_l[i][1] > x_l[i+1][0]:
        ans_l -= 1
        x_l[i+1] = x_l[i]
    if x_r[i][1] > x_r[i+1][0]:
        ans_r -= 1
        x_r[i+1] = x_r[i]
print(max(ans_l, ans_r))

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

import sys
import collections

sys.setrecursionlimit(10 ** 7)


N = int(input().rstrip())


A = list(tuple(map(int, input().rstrip().split())) for _ in range(N))

array = []
for s, t in A:
    array.append((s + t, s))

array.sort()


ans = 0
t = 0
for x, s in array:
    if t <= s:
        t = x
        ans += 1

print(ans)


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

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):

import sys
import collections

sys.setrecursionlimit(10 ** 7)


N = int(input().rstrip())


A = list(tuple(map(int, input().rstrip().split())) for _ in range(N))

array = []
for s, t in A:
    array.append((s + t, s - t))

array.sort()


ans = 0
t = -1e9
for e, s in array:
    if t <= s:
        t = e
        ans += 1

print(ans)
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)]
ans=1
B=[]
for j in range(n):
    B.append([A[j][0]-A[j][1],A[j][0]+A[j][1]])

B=sorted(B)
point=B[0][1]
for i in range(1,n):
    if point>B[i][0]:continue
    elif point<=B[i][1]:
        ans +=1
        point=B[i][1]

print(ans)

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
B=[]
for i in range(n):
    B.append([A[i][0]-A[i][1],A[i][0]+A[i][1]])
B=sorted(B)
point=B[0][1]
a,b=1,1
for i in range(1,n):
    if B[i][0]>=point:
        point=B[i][1]
        a +=1

point=B[-1][0]
for i in reversed(range(0,n-1)):
    if B[i][1]<=point:
        point=B[i][0]
        b +=1

print(max(a,b))

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
xl = [tuple(map(int,input().split())) for _ in range(n)]
xl.sort(key = lambda x:x[0]+x[1],reverse = True)
mini = xl[0][0]+xl[0][1]
ans = n
for i in range(n):
  if mini < xl[i][0]+xl[i][1]:
    ans -= 1
  else:
    mini = min(xl[i][0]-xl[i][1],mini)
    
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())
xl = [tuple(map(int,input().split())) for _ in range(n)]
xl.sort(key = lambda x:x[0]+x[1])
maxi = -10**9-7
ans = n
for i in range(n):
  if maxi <= xl[i][0]-xl[i][1]:
    maxi = xl[i][0]+xl[i][1]
  else:
    ans -= 1
    
print(ans)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X,L])
x.sort()
ans = 0
y = x[0][0] + x[0][1]
for i in range(1,n):
    z = x[i][0]-x[i][1]
    if y>z:
        ans +=1
    y = min(y,z+2*x[i][1])
print(n-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())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X-L,X+L])
x.sort(key=lambda x:x[0])
ans = n
tmp = x[0][1]
for i in range(1,n):
    if tmp>x[i][0]:
        ans -=1
        tmp = min(tmp,x[i][1])
    else:
        tmp = x[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.sort(key=lambda x: (x[0]-x[1],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)


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

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):
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[0])

cnt = 0


for i in range(n-1) :
    if xl[i][1] >= xl[i+1][0] :
        
        if xl[i][1] < xl[i+1][1] :
            xl[i+1][0] = xl[i][0]
            xl[i+1][1] = xl[i][1]
        cnt += 1

print(n-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):
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())

p = []
for i in range(N):
  a,b = map(int,input().split())
  p.append([max(0,a - b),a + b])
  
q = sorted(p,key=lambda x:(x[0],x[1]))

c = 0
d = q[0][1] 
for j,k in q[1:]:
  if j < d:
    c += 1
  else:
    d = k  
  
print(N-c) 

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

p = []
for i in range(N):
  a,b = map(int,input().split())
  p.append([max(0,a - b),a + b])
  
q = sorted(p,key=lambda x:x[1])  

cnt = 0
d = q[0][1]
for j,k in q[1:]:
  if j < d:
    cnt += 1
  else:
    d = k

print(N-cnt)

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
xl = [list(map(int, readline().split())) for i in range(n)]
pm = [[0] * 2 for _ in range(n)]
for i in range(n):
    pm[i][0] = xl[i][0] + xl[i][1]
    pm[i][1] = xl[i][0] - xl[i][1]
pm.sort(key=lambda x: x[1])
ans = 1
check = pm[0][0]
for i in range(1, n):
    if check <= pm[i][1]:
        check = pm[i][0]
        ans += 1
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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
xl = [list(map(int, readline().split())) for i in range(n)]
pm = [[0] * 2 for _ in range(n)]
for i in range(n):
    pm[i][0] = xl[i][0] + xl[i][1]
    pm[i][1] = xl[i][0] - xl[i][1]
pm.sort()
ans = 1
check = pm[0][0]
for i in range(1, n):
    if check <= pm[i][1]:
        check = pm[i][0]
        ans += 1
print(ans)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from operator import itemgetter
N= int(input())
ans = 1
a = []

for i in range(N):
    tmpa, tmpb = map(int,input().split())
    a.append([tmpa+tmpb, tmpa-tmpb])

a.sort()
    
tmp = a[0][1]
for i in range(1, N):
    if a[i][0] >= tmp:
        ans += 1
        tmp = a[i][1]
print(ans)

Failing test case input:
4
4 4
4 3
47 3
100 4

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
from operator import itemgetter
N= int(input())
ans = 1
a = []

for i in range(N):
    tmpa, tmpb = map(int,input().split())
    a.append([tmpa+tmpb, tmpa-tmpb])

a.sort()
    
tmp = a[0][0]
for i in range(1, N):
    if a[i][1] >= tmp:
        ans += 1
        tmp = a[i][0]
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()
cnt=0
now=0
temp=1
for i in range(n-1):
    if  a[now+temp][0]-a[now+temp][1]<a[now][0]+a[now][1]:
        cnt+=1
        temp+=1
    else:
        now+=temp
        temp=1

print(n-cnt)

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())
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())
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:
    l -= 1
    ll = x - l
    if ll <= rl:
        tikan += 1
        rl = min(rl, x + l)
    else:
        ans += 1
        rl = x + l
print(N - tikan)


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())
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 (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N=int(input())
ES = []
for i in range(N):
    x,l = list(map(int,input().split()))
    ES.append((x+l-1,x-l+1))

ES = sorted(ES)


sel = []
cur = None
for E,S in ES:
    if cur is None or cur < S:
        
        sel.append((E,S))
        cur = E

print(len(sel))



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

Expected output:
1


Actual output:
2


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

sel = []
cur = None
ans = 0
for E,S in ES:
    if cur is None or cur <= S:
        sel.append((S,E))
        cur = E
        ans += 1
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, x+l))
    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[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


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

n = int(input())


l = [list(map(int,input().split())) for i in range(n)]
l.sort()

count = 2
right = l[0][0]+l[0][1]
left = l[-1][0]-l[-1][1]
if right > left:
    print(1)
    exit()
for i in range(1,n):
    if l[i][0]-l[i][1] >= right:
        count += 1
        right = l[i][0]+l[i][1]
        
    if left >= l[-i-1][0]+l[-i-1][1]:
        count += 1
        left = l[-i-1][0]-l[-i-1][1]
        
    if right == left:
        print(count)
        exit()
    if right > left:
        count -= 1
        print(count)
        exit()
print(count)





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

Expected output:
3


Actual output:
4


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



for i in range(n):
    left.append((l[i][0]+l[i][1],l[i][0]-l[i][1]))
left.sort()   
count = 1
right = 10**10
right = left[0][0]
c = 0

while True:
    
    for i in range(c,n+1):
        if i == n:
            print(count)
            exit()
        if left[i][1] >= right:
            count += 1
            right = left[i][0]
            c = i
            
            
            
    if c == n-1:
        print(count)
        exit()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
XL = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    XL.append(array)
XL = sorted(XL)
Y = 0
cnt = 0
for i in range(N):
    if XL[i][0]-XL[i][1]>=Y:
        cnt += 1
        Y = XL[i][0]+XL[i][1]
    else:
        Y = min(Y,XL[i][0]+XL[i][1])
print(cnt)

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 = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    XL.append(array)
XL = sorted(XL)
Y = 0
cnt = 0
for i in range(N):
    if max(XL[i][0]-XL[i][1],0)>=Y:
        cnt += 1
        Y = XL[i][0]+XL[i][1]
    else:
        Y = min(Y,XL[i][0]+XL[i][1])
print(cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
robots = [[int(x) for x in input().split()] for _ in range(N)]
robots.sort(key=lambda x: x[0])
cur = float('-inf')
res = 0
for x, l in robots:
    left = x - l
    right = x + l
    if cur <= left:
        cur = right
    else:
        res += 1
print(N - res)

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())
robots = [[int(x) for x in input().split()] for _ in range(N)]
robots = [(x - l,  x + l) for x, l in robots]
robots.sort(key=lambda x: x[1])
cur = float('-inf')
count = 0
for left, right in robots:
    if cur <= left:
        cur = right
        count += 1
print(count)

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

robo_list = []
for i in range(N):
    robo_list.append(list(map(int, input().split())))

robo_list.sort()


xmax = 0
counter = 0
for i in range(N):
    if(i==0):
        robo = robo_list[i]
        xmax = robo[0]+robo[1]
        counter += 1
    else:
        robo = robo_list[i]
        if(robo[0]-robo[1] >= xmax):
            xmax = robo[0]+robo[1]
            counter += 1
        else:
            pass
            
    
print(counter)

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

robo_list = []
for i in range(N):
    robo_list.append(list(map(int, input().split())))

robo_list.sort()


xmax = 0
counter = 0
for i in range(N):
    if(i==0):
        robo = robo_list[i]
        xmax = robo[0]+robo[1]
        counter += 1
    else:
        robo = robo_list[i]
        if(robo[0]-robo[1] >= xmax):
            xmax = robo[0]+robo[1]
            counter += 1
        else:
            if(robo[0]+robo[1] <= xmax):
                xmax=robo[0]+robo[1]
                
    
print(counter)

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: 10000000000 * student[0] + student[1])


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

print(ans)

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

Expected output:
3


Actual output:
1


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)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    n = int(input())
    robots = []
    for i in range(n):
        x, l = map(int, input().split())
        robots.append((x, l, x - l, x + l))
    robots = sorted(robots, key=lambda x: x[2])
    ans = []
    for i in range(n):
        if i == 0:
            ans.append(robots[i][3])
        else:
            if robots[i][2] >= ans[-1]:
                ans.append(robots[i][3])
    print(len(ans))


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

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    n = int(input())
    robots = []
    for i in range(n):
        x, l = map(int, input().split())
        robots.append((x - l, x + l))
    robots = sorted(robots, key=lambda x: x[1])
    ans = []
    for i in range(n):
        if i == 0:
            ans.append(robots[i][1])
        else:
            if robots[i][0] >= ans[-1]:
                ans.append(robots[i][1])
    print(len(ans))

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

lob = []

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

lob.sort()

ans = 0
last = 0
for l in lob:
    if last <= l[1]:
        ans += 1
        last = l[0]

print(ans)

Failing test case input:
2
8 16
2 10

Expected output:
1


Actual output:
0


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

lob = []

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

lob.sort()

ans = 0
last = (-1) * 10 ** 9 - 1
for l in lob:
    if last <= l[1]:
        ans += 1
        last = l[0]

print(ans)

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

import operator as op
n = int(input())
a = []
for _ in range(n):
    x, l = map(int, input().split())
    a.append((x,l))

a.sort(key=op.itemgetter(0))

MAX = -int(1e11)
cnt = 0
for i in range(n):
    x, l = a[i]
    MIN = x - l
    if MAX > MIN:
        pass
    else:
        cnt +=1
        MAX = x+l
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 operator as op
n = int(input())
a = []
for _ in range(n):
    x, l = map(int, input().split())
    a.append((x - l, x + l))


a.sort(key=op.itemgetter(1))

tmp = - int(1e12)
cnt = 0
for i in range(n):
    MIN, MAX = a[i]
    if tmp > MIN:
        pass
    else:
        cnt +=1
        tmp = MAX
print(cnt)
Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
xl = [list(map(int, input().split())) for _ in range(N)]
rl = []
for i in range(N):
    rl.append((xl[i][0] - xl[i][1], xl[i][0] + xl[i][1]))
rl.sort(key=lambda x: x[0])
cnt = 0
tmp = -10 ** 18

for i, j in rl:
    if tmp <= i:
        cnt += 1
        tmp = j
print(cnt)

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 _ in range(N)]
rl = []
for i in range(N):
    rl.append((xl[i][0] - xl[i][1], xl[i][0] + xl[i][1]))
rl.sort(key=lambda x: x[1])
cnt = 0
tmp = -10 ** 18

for i, j in rl:
    if tmp <= i:
        cnt += 1
        tmp = j
print(cnt)

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])
A=ab[-1][0]
B=ab[-1][1]
cnt=1
for i in range(n-1):
    a=ab[-i-2][0]
    b=ab[-i-2][1]
    if b<=A:
        cnt+=1
        A=a
print(cnt)


Failing test case input:
4
7 32
8 5
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 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 (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
XL = [tuple(map(int, input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0])

right = -10**9
removed = 0
for x, l in XL:
    if x-l < right:
        removed += 1
    else:
        right = x+l
print(N-removed)


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

right = -10**9
removed = 0
for x, l in XL:
    if x-l < right:
        removed += 1
    else:
        right = x+l
print(N-removed)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())

P = [0] * 150

robot = []

for i in range(N):
    X, L = map(int,input().split())

    robot.append([X,L])

robot = sorted(robot)

p_max = robot[0][0] + robot[0][1]
cnt = 1

for i in range(1,N):
    if p_max <= robot[i][0] - robot[i][1]:
        cnt += 1

print(cnt)


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

P = [0] * 150

robot = []

for i in range(N):
    X, L = map(int,input().split())

    left = X-L
    right = X+L

    
    robot.append([right,left])

robot = sorted(robot)

cnt = 0 
last_right = -float('inf') 

for i in range(N):
    if last_right <= robot[i][1]:
        cnt += 1
        last_right =  robot[i][0]

print(cnt)

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 32
8 4
1 2
101 4

Expected output:
3


Actual output:
4


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())
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 and pre < x + l:
        cnt += 1
    elif x + l < pre:
        cnt += 1
        pre = x + l
    else:
        pre = x + l

print(n - cnt)

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

Expected output:
3


Actual output:
4


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


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

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




import sys
input = sys.stdin.readline



def main():
    N = int(input())
    X = []
    L = []
    XL = []
    for i in range(N):
        temp = list(map(int,input().split()))
        XL.append([temp[0],temp[1]])

    XL.sort()

    res = 1
    end = sum(XL[0])

    for i in range(1,N):
        if end <= XL[i][0] - XL[i][1]:
            res += 1
            end = sum(XL[i])

    print(res)



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
input = sys.stdin.readline



def main():
    N = int(input())
    X = []
    L = []
    LX = []
    for i in range(N):
        temp = list(map(int,input().split()))
        LX.append([temp[0]+temp[1],temp[0]-temp[1]])

    LX.sort()

    res = 0
    end = - 10 ** 9

    for i in range(N):
        if end <= LX[i][1]:
            res += 1
            end = LX[i][0]

    print(res)



main()

Problem: p02796
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n = int(input())
ans = 0
x = [0] * n
for i in range(n):
    x[i] = tuple([int(x) for x in input().strip().split()])

x.sort()
pre = -float('inf')

for xx in x:
    if pre > xx[0] - xx[1]:
        pre = min(pre, xx[0]+xx[1])
        
        continue
    
    ans += 1
    pre = xx[0] + xx[1]
    

x.reverse()
pre = float('inf')
ans2 = 0
for xx in x:
    if pre < xx[0] + xx[1]:
        pre = max(pre, xx[0]+xx[1])
        
        continue
    
    ans2 += 1
    pre = xx[0] - xx[1]
    

print(max(ans, ans2))

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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
n = int(input())
ans = 0
x = [0] * n
for i in range(n):
    x[i] = tuple([int(x) for x in input().strip().split()])

x.sort()
pre = -float('inf')
for xx in x:
    if pre > xx[0] - xx[1]:
        if pre < xx[0] + xx[1]:
            continue
        else:
            pre = xx[0] + xx[1]
            continue
    
    ans += 1
    pre = xx[0] + xx[1]
print(ans)
Problem: p02796
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
ES = []
for i in range(N):
    x,l = list(map(int,input().split()))
    ES.append((x+l,x-l))

ES = sorted(ES)

sel = []
cur = None
ans = 0
for E,S in ES:
    if cur is None or cur <= S:
        sel.append((S,E))
        cur = E
print(ans)



Failing test case input:
2
16 14
0 10

Expected output:
1


Actual output:
0


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

sel = []
cur = None
ans = 0
for E,S in ES:
    if cur is None or cur <= S:
        sel.append((S,E))
        cur = E
        ans += 1
print(ans)
Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    line = input()
    s1 = []
    s2 = []
    sum = 0
    for i, s in enumerate(line):
        if s == "\\":
            
            s1.append(i)
        elif s == "/" and len(s1) > 0:
            
            j = s1.pop()
            sum += i - j  
            
            a = i - j
            while len(s2) > 0 and s2[-1][0] > j:
                a += s2.pop()[1]
            
            s2.append((j, a))

    print(sum)
    if len(s2) > 0:
        print(len(s2), end="")
        for x in s2:
            print(f" {x[1]}")
    else:
        print(len(s2))


if __name__ == "__main__":
    main()



Failing test case input:
Z\\]/_-0\`_`\[\0a/[\/\[]/\0.]10/-a\]\

Expected output:
15
5 2 3 1 3 6


Actual output:
15
5 2
 3
 1
 3
 6


Fixed submission (verdict: Accepted):
def main():
    line = input()
    s1 = []
    s2 = []
    sum = 0
    for i, s in enumerate(line):
        if s == "\\":
            
            s1.append(i)
        elif s == "/" and len(s1) > 0:
            
            j = s1.pop()
            sum += i - j  
            
            a = i - j
            while len(s2) > 0 and s2[-1][0] > j:
                a += s2.pop()[1]
            
            s2.append((j, a))

    print(sum)
    if len(s2) > 0:
        print(len(s2), end="")
        for x in s2:
            print(f" {x[1]}", end="")
        print()
    else:
        print(len(s2))


if __name__ == "__main__":
    main()

Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
    if g[x] == '\\':
        if n:
            l.append(n)
            n = 0
            if q:
                q.append(-1)
        q.append(x)
    elif g[x] == '/':
        if q:
            while True:
                p = q.pop()
                print(p)
                if p == -1:
                    n += l.pop()
                else:
                    break
            n += x-p
    else:
        pass
if n:
    l.append(n)
for j in range(l.count(0)):
    l.remove(0)
print(sum(l))
print(len(l), *l)

Failing test case input:
[Z0]`_-\\[/a]_[1a/[]0Z0]/Y\/]1///`\^]

Expected output:
13
2 12 1


Actual output:
8
7
26
13
2 12 1


Fixed submission (verdict: Accepted):
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
    if g[x] == '\\':
        if n:
            l.append(n)
            n = 0
            if q:
                q.append(-1)
        q.append(x)
    elif g[x] == '/':
        if q:
            while True:
                p = q.pop()
                if p == -1:
                    n += l.pop()
                else:
                    break
            n += x-p
    else:
        pass
if n:
    l.append(n)
for j in range(l.count(0)):
    l.remove(0)
print(sum(l))
print(len(l), *l)
Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
def cross_section_area(data):
    area = 0;
    k = 0;
    section_areas = [];
    section_area = 0;
    stack = [];
    for i in range(len(data)):
        if data[i] == '\\':
            stack.append(i);
        elif data[i] == '/' and len(stack) > 0:
            section_area += i - stack.pop();
            if len(stack) == 0:
                k += 1;
                section_areas.append(section_area);
                area += section_area;
    print(area);
    print(k, *section_areas);

cross_section_area(input());


Failing test case input:
[[0/a./\`]`c1_\^b2[\_0XY/0.^__0/0Z[]X

Expected output:
22
1 22


Actual output:
0
0


Fixed submission (verdict: Accepted):
def cross_section_area(data):
    area = 0;
    sections = [];
    stack = [];
    for i in range(len(data)):
        if data[i] == '\\':
            stack.append(i);
        elif data[i] == '/' and len(stack) > 0:
            j = stack.pop();
            section_area = i - j;
            area += section_area;
            while len(sections) > 0 and sections[-1][0] > j:
                section_area += sections[-1][1];
                sections.pop();
            sections.append([j, section_area]);
    print(area);
    print(len(sections), *[n[1] for n in sections]);

cross_section_area(input());

Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
def cross_section_area(data):
    area = 0;
    section_areas = [];
    stack = [];
    section_area = 0;
    for i in range(len(data)):
        if data[i] == '\\':
            stack.append(i);
        elif data[i] == '/' and len(stack) > 0:
            section_area += i - stack.pop();
            if len(stack) == 0:
                area += section_area;
                section_areas.append(section_area);
                section_area = 0;
    if section_area > 0:
        section_areas.append(section_area);
        area += section_area;
    print(area);
    print(len(section_areas), *section_areas);

cross_section_area(input());


Failing test case input:
Z0\_`_/0\\_\\\//_/\\/`\/\\]._0\..\\]0

Expected output:
16
4 4 10 1 1


Actual output:
16
2 4 12


Fixed submission (verdict: Accepted):
def cross_section_area(data):
    area = 0;
    sections = [];
    stack = [];
    for i in range(len(data)):
        if data[i] == '\\':
            stack.append(i);
        elif data[i] == '/' and len(stack) > 0:
            j = stack.pop();
            section_area = i - j;
            area += section_area;
            while len(sections) > 0 and sections[-1][0] > j:
                section_area += sections[-1][1];
                sections.pop();
            sections.append([j, section_area]);
    print(area);
    print(len(sections), *[n[1] for n in sections]);

cross_section_area(input());
Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    line = input()

    s1 = []
    s2 = []
    sum = 0
    for i, s in enumerate(line):
        if s == "\\":
            
            s1.append(i)
        elif s == "/" and len(s1) > 0:
            
            j = s1.pop()
            sum += i - j  
            
            a = i - j
            while len(s2) > 0 and s2[-1][0] > j:
                a += s2.pop()[1]
            
            s2.append((j, a))

    print(sum)
    if len(s2) > 0:
        print(len(s2), s2[0][1])
    else:
        print(len(s2))


if __name__ == "__main__":
    main()



Failing test case input:
\/_/\_/\\_/\\__///\\/_/\[\\0\/_\/\/\\

Expected output:
31
7 1 2 20 5 1 1 1


Actual output:
31
7 1


Fixed submission (verdict: Accepted):
def main():
    line = input()
    s1 = []
    s2 = []
    sum = 0
    for i, s in enumerate(line):
        if s == "\\":
            
            s1.append(i)
        elif s == "/" and len(s1) > 0:
            
            j = s1.pop()
            sum += i - j  
            
            a = i - j
            while len(s2) > 0 and s2[-1][0] > j:
                a += s2.pop()[1]
            
            s2.append((j, a))

    print(sum)
    if len(s2) > 0:
        print(len(s2), end="")
        for x in s2:
            print(f" {x[1]}", end="")
        print()
    else:
        print(len(s2))


if __name__ == "__main__":
    main()

Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
arr = list(input())
down = list()
areas = list()

for i, el in enumerate(arr):
    if el == "\\":
        down.append(i)
    elif el == "/" and not len(down) == 0:
        start_ind = down.pop()
        area = i - start_ind
        while len(areas) > 0 and areas[-1][0] > start_ind:
            area += areas.pop()[1]
        areas.append((start_ind, area))
    
    
    
    
    
    

areas = [areas[i][1] for i in range(len(areas))]
print(sum(areas))
print(" ".join(map(str,areas)))


Failing test case input:
\\\\/._/\0\0Z/\`/\\///__\\0\\\/_\__0\

Expected output:
29
3 6 22 1


Actual output:
29
6 22 1


Fixed submission (verdict: Accepted):
arr = list(input())
down = list()
areas = list()

for i, el in enumerate(arr):
    if el == "\\":
        down.append(i)
    elif el == "/" and not len(down) == 0:
        start_ind = down.pop()
        area = i - start_ind
        while len(areas) > 0 and areas[-1][0] > start_ind:
            area += areas.pop()[1]
        areas.append((start_ind, area))
    
    
    
    
    
    

areas = [areas[i][1] for i in range(len(areas))]
print(sum(areas))
if len(areas) == 0:
    print("0")
else:
    print(len(areas), " ".join(map(str,areas)))
Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):


import sys
import os


s = input().strip()

S1 = []  
S2 = []  
area = 0

for i, c in enumerate(s):
    if c == '\\':
        S1.append(i)
    elif c == '_':
        pass
    elif c == '/' and S1:
        j = S1.pop(-1)
        area += i - j

        
        
        pond_sum = i - j  
        while S2 and S2[-1][0] > j:
            pond_sum += S2[-1][1]
            S2.pop(-1)
        S2.append([j, pond_sum])

pond_areas = []
for data in S2:
    pond_areas.append(data[1])


print(area)
print(*pond_areas)

Failing test case input:
Z0]]`_-\[\_a\/\1a/[\0[\]/\0/]1///`\^Z

Expected output:
66
1 66


Actual output:
66
66


Fixed submission (verdict: Accepted):


import sys
import os


s = input().strip()

S1 = []  
S2 = []  
area = 0

for i, c in enumerate(s):
    if c == '\\':
        S1.append(i)
    elif c == '_':
        pass
    elif c == '/' and S1:
        j = S1.pop(-1)
        area += i - j

        
        
        pond_sum = i - j  
        while S2 and S2[-1][0] > j:
            pond_sum += S2[-1][1]
            S2.pop(-1)
        S2.append([j, pond_sum])

pond_areas = []
for data in S2:
    pond_areas.append(data[1])


print(area)
print(len(pond_areas), *pond_areas)

Problem: p02266
Buggy submission (Python3, verdict: Wrong Answer):
target = input()
now_height = []
now_area = [0]
answer = []
continued = 0
for t in target:
    
    if t == '\\':
        now_height.append(continued)
        now_area.append(0)
    elif t == '_':
        pass
    elif t == '/' and len(now_height) > 0:
        started = now_height.pop()
        temp_area = continued - started
        temp = now_area.pop()
        now_area[-1] += temp_area + temp
        if len(now_height) == 0:
            answer.append(now_area[0])
            now_area = [0]
            continue
    continued += 1
now_area = list(filter(lambda x:x != 0,now_area))
answer.extend(now_area)
print(sum(answer))
print(len(answer),*answer)

Failing test case input:
\/_/\_/\\_/\\__///\\/_0/[\\0\/_\/\\\\

Expected output:
31
6 1 2 20 6 1 1


Actual output:
31
5 1 2 20 6 2


Fixed submission (verdict: Accepted):
target = input()
now_height = []
now_area = [0]
answer = []
continued = 0
depth = 0
depth_list = []
for t in target:
    
    if t == '\\':
        now_height.append(continued)
        depth_list.append(depth)
        now_area.append(0)
        depth -= 1
    elif t == '_':
        pass
    elif t == '/' and len(now_height) > 0:
        depth += 1
        started = now_height.pop()
        temp_area = continued - started
        
        now_area[-1] += temp_area
        if depth > depth_list[-1]:
            while depth > depth_list[-1]:
                temp = now_area.pop()
                now_area[-1] += temp
                depth_list.pop()
        if len(now_height) == 0 or depth == depth_list[0]:
            answer.append(sum(now_area))
            now_area = [0]
            depth_list = []
    continued += 1
now_area = list(filter(lambda x:x != 0,now_area))
answer.extend(now_area)
print(sum(answer))
print(len(answer),*answer)