Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=input()
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[i][j]==b:
                a[i][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l==0 and a[2][l]==:
        ans=1
        break

if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")


Fixed submission:
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[k][j]==b:
                a[k][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l]==0 and a[2][l]==0:
        ans=1
        break




if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

s=""
for i in range(N):
    for j in range(N):
        if A[j]==i+1:
            s+="{} ".format(j+1)
            break
print(s)



Fixed submission:
from operator import itemgetter

N = int(input())
A = list(map(int, input().split()))

print(*[t[0] + 1 for t in sorted(enumerate(A), key=itemgetter(1))])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

s=""
for i in range(N):
    for j in range(N):
        if A[j]==i+1:
            s+="{} ".format(j+1)
            break
print(s)



Fixed submission:
from operator import itemgetter

N = int(input())
A = list(map(int, input().split()))

print(*[t[0] + 1 for t in sorted(enumerate(A), key=itemgetter(1))])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
#Ai=A[i-1]
s=""
for i in range(N):
    if i!=0:
        s+=" "
#教室にi+1人いたとき
    for j in range(N):
#出席番号i=j+1
        if i+1==A[j]:
            s+="{}".format(j+1)

print(s)


Fixed submission:
from operator import itemgetter

N = int(input())
A = list(map(int, input().split()))

print(*[t[0] + 1 for t in sorted(enumerate(A), key=itemgetter(1))])
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=0
for i in range(a):
    b+=i
print(b)


Fixed submission:
a=int(input())
b=(a-1)*a//2
print(b)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
print({:.16g}.format(1/sum(1/x for x in a)))


Fixed submission:
n=int(input())
a=map(int,input().split())
print("{:.16g}".format(1/sum(1/x for x in a)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
c=0
for i in range(n):
    b=int(input())
    c+=1.0/b
print(1.0/c)

     



Fixed submission:
n=int(input())
a=map(int,input().split())
print("{:.16g}".format(1/sum(1/x for x in a)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
c=0
for i in range(n):
    b=int(input())
    c+=1.0/b
print(1.0/c)

     


Fixed submission:
n=int(input())
a=map(int,input().split())
print("{:.16g}".format(1/sum(1/x for x in a)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
v1=map(int,input().split())
v=list(v1)
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    a=(v[0]+v[1])/2
    v=a+v[2,n-l]
print(v[0])


Fixed submission:
n=int(input())
v1=map(int,input().split())
v=list(v1)
#価値の低いものから順に平均をとっていけばよい
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    v2=[]
    a=(v[0]+v[1])/2
    v2.append(a)
    v2=v2+v[2:n]
    v=v2
print(v[0])

Buggy python submission (verdict: Runtime Error):
n=int(input())
v1=map(int,input().split())
v=list(v1)
#価値の低いものから順に平均をとっていけばよい
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    a=(v[0]+v[1])/2
    v=a+v[2,n-l]
print(v[0])


Fixed submission:
n=int(input())
v1=map(int,input().split())
v=list(v1)
#価値の低いものから順に平均をとっていけばよい
for i in range(n):
    for j in range(i+1,n):
        if v[i]>v[j]:
            a=v[i]
            v[i]=v[j]
            v[j]=a
for l in range(n-1):
    v2=[]
    a=(v[0]+v[1])/2
    v2.append(a)
    v2=v2+v[2:n]
    v=v2
print(v[0])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
LST=[]
count=0
for i in range(N):
    a=input()
    lst=[]
    for j in range(len(a)):
        lst.append(a[j])
    LST.append(sorted(lst))
for i in range(N-1):
    for j in range(i+1,N):
        if LST[i]==LST[j]:
            count+=1
print(count)


Fixed submission:
N=int(input())

count=0
dic=dict()

for i in range(N):
    s="".join(sorted(input()))
#    print(s)

    if s in dic:
        count+=dic[s]
#        print(dic[s])
        dic[s]+=1
    else:
        dic[s]=1
#        print(dic)

print(count)

Buggy python submission (verdict: Runtime Error):
N=int(input())
LST=[]
for i in range(N):
    a=input()
    lst=[]
    for j in range(len(a)):
        lst.append(a[j])
    lst=sorted(lst)
    if lst in LST:
        count+=1
        break
    else:
        LST.append(lst)
        

print(count)


Fixed submission:
N=int(input())

count=0
dic=dict()

for i in range(N):
    s="".join(sorted(input()))
#    print(s)

    if s in dic:
        count+=dic[s]
#        print(dic[s])
        dic[s]+=1
    else:
        dic[s]=1
#        print(dic)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
LST=[]
for i in range(N):
    a=input()
    lst=[]
    for j in range(len(a)):
        lst.append(a[j])

    LST.append(sorted(lst))

count=0
for i in range(N-1):
    for j in range(i+1,N):
        if LST[i]==LST[j]:
            count+=1
print(count)



Fixed submission:
N=int(input())

count=0
dic=dict()

for i in range(N):
    s="".join(sorted(input()))
#    print(s)

    if s in dic:
        count+=dic[s]
#        print(dic[s])
        dic[s]+=1
    else:
        dic[s]=1
#        print(dic)

print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range:
    if p[i]==i+1:
        count+=1

if count==2 or count==0:
    print("YES")
else:
    print("NO")


Fixed submission:
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n):
    if p[i]!=i+1:
        count+=1

if count==2 or count==0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
ans=2018

for i in range(l,r):
    if r-i>2019:
        a=2019
    else:
        a=r-i
    for j in range((i+1)%2019,(i+1)%2019+a):
        if (i*j)%2019<ans:
            ans=(i*j)%2019
print(ans)



Fixed submission:
l,r=map(int,input().split())
ans=2018
d=r-l
if d>2019:
    d=2019

for i in range(l%2019,l%2019+d):
    for j in range(i+1,l%2019+d+1):
        a=(i*j)%2019
        if a<ans:
            ans=a
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
ans=2018
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019<ans:
            ans=i*j%2019
        if ans==0:
            break
print(ans)


Fixed submission:
l,r=map(int,input().split())
ans=2018
d=r-l
if d>2019:
    d=2019

for i in range(l%2019,l%2019+d):
    for j in range(i+1,l%2019+d+1):
        a=(i*j)%2019
        if a<ans:
            ans=a
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()


for i in range(3):
    if s[i]==s[i+1]:
        ans=1
if ans==1:
    print("Bad")
else:
    print("Good")
    


Fixed submission:
s=input()

ans=0
for i in range(3):
    if s[i]==s[i+1]:
        ans=1
if ans==1:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()

print(s[:k-1]+s[k-1]>lower()+s[k])


Fixed submission:
n,k=map(int,input().split())
s=input()

s=s[:k-1]+s[k-1].lower()+s[k:]

print(s)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()

s1=s[:k+1]
s2=s[k+1]
s3=s[k+2:]

if s2=="A":
    s2="a"
elif s2=="B":
    s2="b"
else:
    s2="c"

print(s1+s2+s3)


Fixed submission:
n,k=map(int,input().split())
s=input()

s=s[:k-1]+s[k-1].lower()+s[k:]

print(s)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)

ss=s

def change(x):
    if x=="0":
        ans="1"
    else:
        ans="0"
    return ans

count_1=0
#1枚目をそのまま使う
for i in range(1,n):
    if s[i-1]==s[i]:
        if i!=n-1:
            s=s[:i]+change(s[i])+s[i+1:]
        else:
            s=s[:i]+change(s[i])
        count_1+=1

count_2=1
ss=change(ss[0])+ss[1:]
for i in range(1,n):
    if ss[i-1]==ss[i]:
        if i!=n-1:
            ss=ss[:i]+change(ss[i])+ss[i+1:]
        else:
            ss=ss[:i]+change(ss[i])
        count_2+=1

if count_1>count_2:
    print(count_2)
else:
    print(count_1)


Fixed submission:
s=input()
n=len(s)

s1=s[0]
count_1=0
#1枚目をそのまま使う
for i in range(1,n):
    if i%2==0:
        if s[i]!=s1:
            count_1+=1
    else:
        if s[i]==s1:
            count_1+=1

count_2=1
for i in range(1,n):
    if i%2==0:
        if s[i]==s1:
            count_2+=1
    else:
        if s[i]!=s1:
            count_2+=1

if count_1>count_2:
    print(count_2)
else:
    print(count_1)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)

ss=s

def change(x):
    if x=="0":
        ans="1"
    else:
        ans="0"
    return ans

count_1=0
#1枚目をそのまま使う
for i in range(1,n):
    if s[i-1]==s[i]:
        if i!=n-1:
            s=s[:i]+change(s[i])+s[i+1:]
        else:
            s=s[:i]+change(s[i])
        count_1+=1

count_2=1
ss=change(ss[0])+ss[1:]
for i in range(1,n):
    if ss[i-1]==ss[i]:
        if i!=n-1:
            ss=ss[:i]+change(ss[i])+ss[i+1:]
        else:
            ss=ss[:i]+change(ss[i])
        count_2+=1

if count_1>count_2:
    print(count_2)
else:
    print(count_1)


Fixed submission:
s=input()
n=len(s)

s1=s[0]
count_1=0
#1枚目をそのまま使う
for i in range(1,n):
    if i%2==0:
        if s[i]!=s1:
            count_1+=1
    else:
        if s[i]==s1:
            count_1+=1

count_2=1
for i in range(1,n):
    if i%2==0:
        if s[i]==s1:
            count_2+=1
    else:
        if s[i]!=s1:
            count_2+=1

if count_1>count_2:
    print(count_2)
else:
    print(count_1)
Buggy python submission (verdict: Time Limit Exceeded):
import random

def calc_score(D, C, S, T):
    score = 0
    last = [0]*26
    for d in range(D):
        t = T[d] - 1
        score += S[d][t]
        last[t] = d + 1
        for i in range(26):
            score -= C[i]*(d + 1 - last[i])
    return score

def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    last = [0]*26
    ans = []
    for d in range(D):
        score = -100*365
        t = 0
        for i in range(26):
            tmp = S[d][i]
            for j in range(26):
                if i != j:
                    tmp -= C[j]*(d + 1 - last[j])
            if tmp > score:
                score = tmp
                t = i + 1
        last[t - 1] = d + 1
        ans.append(t)
    score = calc_score(D, C, S, ans)
    for i in range(10**4):
        d = random.randint(0, D - 1)
        t = random.randint(0, 25)
        org_t = ans[d]
        ans[d] = t
        s = calc_score(D, C, S, ans)
        if s <= score:
            ans[d] = org_t
        else:
            score = s
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    last = [0]*26
    ans = []
    for d in range(D):
        s = 0
        t = 0
        for i in range(26):
            tmp = S[d][i]
            if tmp > s:
                s = tmp
                t = i + 1
        ans.append(t)
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha:
            ans.add(b)
        else:
            ans.add(a)
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    R, G, B = [], [], []
    num_r, num_g, num_b = 0, 0, 0
    for i in range(N):
        s = S[i]
        if s == 'R':
            R.append(i)
            num_r += 1
        elif s == 'G':
            G.append(i)
            num_g += 1
        elif s == 'B':
            B.append(i)
            num_b += 1
    len_b = (B[-1] + 1)
    B1 = [0]*len_b
    for b in B:
        B1[b] = 1
    # print(R, G, B)
    ans = 0
    for i in R:
        for j in G:
            ans += num_b
            if i < j:
                ans -= calc(i, j, B1, len_b)
            else:
                ans -= calc(j, i, B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    R, G, B = [], [], []
    num_r, num_g, num_b = 0, 0, 0
    for i in range(N):
        s = S[i]
        if s == 'R':
            R.append(i)
            num_r += 1
        elif s == 'G':
            G.append(i)
            num_g += 1
        elif s == 'B':
            B.append(i)
            num_b += 1
    if len(R) == 0 or len(G) == 0 or len(B) == 0:
        print(0)
        return
    len_b = (B[-1] + 1)
    B1 = [0]*len_b
    for b in B:
        B1[b] = 1
    # print(R, G, B)
    ans = 0
    for i in R:
        for j in G:
            ans += num_b
            if i < j:
                ans -= calc(i, j, B1, len_b)
            else:
                ans -= calc(j, i, B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    ans = {i: 0 for i in range(1, N)}
    for i in range(1, N + 1):
        cost = [-1]*(N+1)
        cost[i] = 0
        d = deque([i])
        while len(d) != 0:
            v = d.popleft()
            c = cost[v]
            for j in [-1, 1]:
                vj = v + j
                if vj > 0 and vj <= N and cost[vj] == -1:
                    cost[vj] = c + 1
                    d.append(vj)
                    ans[c + 1] += 1
            if v in [X, Y]:
                vxy = X + Y - v
                if cost[vxy] == -1:
                    cost[vxy] = c + 1
                    d.append(vxy)
                    ans[c + 1] += 1
    for a in ans:
        print(ans[a]//2)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import deque

def main():
    N, X, Y = map(int, input().split())
    ans = {i: 0 for i in range(1, N)}
    for i in range(1, N + 1):
        cost = [-1]*(N+1)
        cost[i] = 0
        d = deque([i])
        while len(d) != 0:
            v = d.popleft()
            c = cost[v]
            for j in [-1, 1]:
                vj = v + j
                if vj > 0 and vj <= N and cost[vj] == -1:
                    cost[vj] = c + 1
                    d.append(vj)
                    ans[c + 1] += 1
            if v in [X, Y]:
                vxy = X + Y - v
                if cost[vxy] == -1:
                    cost[vxy] = c + 1
                    d.append(vxy)
                    ans[c + 1] += 1
    for a in ans:
        print(ans[a]//2)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    S = deque([s for s in input()])
    Q = int(input())
    for i in range(Q):
        query = input().split()
        t = int(query[0])
        if t == 1:
            S.reverse()
        else:
            f = int(query[1])
            c = query[2]
            if f == 1:
                S.appendleft(c)
            else:
                S.append(c)
    print(''.join(S))

if __name__ == '__main__':
    main()


Fixed submission:
from collections import deque
def main():
    S = deque([s for s in input()])
    Q = int(input())
    order = True
    for i in range(Q):
        query = input().split()
        t = int(query[0])
        if t == 1:
            order = not order
        else:
            f = int(query[1])
            c = query[2]
            left = True
            if f == 1:
                if order:
                    left = True
                else:
                    left = False
            else:
                if order:
                    left = False
                else:
                    left = True
            if left:
                S.appendleft(c)
            else:
                S.append(c)
    if not order:
        S.reverse()
    print(''.join(S))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S = deque([s for s in input()])
Q = int(input())
for i in range(Q):
    query = input().split()
    t = int(query[0])
    if t == 1:
        S.reverse()
    else:
        f = int(query[1])
        c = query[2]
        if f == 1:
            S.appendleft(c)
        else:
            S.append(c)
print(''.join(S))


Fixed submission:
from collections import deque
def main():
    S = deque([s for s in input()])
    Q = int(input())
    order = True
    for i in range(Q):
        query = input().split()
        t = int(query[0])
        if t == 1:
            order = not order
        else:
            f = int(query[1])
            c = query[2]
            left = True
            if f == 1:
                if order:
                    left = True
                else:
                    left = False
            else:
                if order:
                    left = False
                else:
                    left = True
            if left:
                S.appendleft(c)
            else:
                S.append(c)
    if not order:
        S.reverse()
    print(''.join(S))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, N, *AB = map(int, open(0).read().split())
    dp = [-1]*(H + 1)
    dp[0] = 0
    for i in range(N):
        a = AB[2 * i + 0]
        b = AB[2 * i + 1]
        for i in range(H + 1):
            d = dp[i] + b
            if dp[i] != -1:
                j = i + a
                if j > H:
                  j = H
                if dp[j] == -1 or d < dp[j]:
                    dp[j] = d
    print(dp[H])

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    H, N, *AB = map(int, open(0).read().split())
    dp = [-1]*(H + 1)
    dp[0] = 0
    for i in range(N):
        a = AB[2 * i + 0]
        b = AB[2 * i + 1]
        for i in range(H + 1):
            d = dp[i] + b
            if dp[i] != -1:
                j = i + a
                j = min(j, H)
                if dp[j] == -1 or d < dp[j]:
                    dp[j] = d
    print(dp[H])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, N, *AB = map(int, open(0).read().split())
    dp = [-1]*(H + 1)
    dp[0] = 0
    for i in range(N):
        a = AB[2 * i + 0]
        b = AB[2 * i + 1]
        for i in range(H + 1):
            d = dp[i] + b
            if dp[i] != -1:
                j = i + a
                j = min(j, H)
                if dp[j] == -1 or d < dp[j]:
                    dp[j] = d
    print(dp[H])

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    H, N, *AB = map(int, open(0).read().split())
    dp = [-1]*(H + 1)
    dp[0] = 0
    for i in range(N):
        a = AB[2 * i + 0]
        b = AB[2 * i + 1]
        for i in range(H + 1):
            d = dp[i] + b
            if dp[i] != -1:
                j = i + a
                j = min(j, H)
                if dp[j] == -1 or d < dp[j]:
                    dp[j] = d
    print(dp[H])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, *XL = map(int, open(0).read().split())
    # print(N, XL)
    robots = [0]*N
    for i in range(N):
        X, L = XL[2 * i + 0], XL[2 * i + 1]
        robots[i] = (i, X - L, X + L)
    robots.sort(key=lambda x: x[2])
    # print(robots)
    remains = []
    for robot in robots:
        # print('remains={}, robot={}'.format(remains, robot))
        conflict = False
        l = robot[1]
        r = robot[2]
        for remain in remains:
            # print(l, r, remain)
            if remain[1] <= l and l < remain[2]:
                # print(robot, remain, l, remain[2], remain[1], r)
                conflict = True
                break
            if remain[1] < r and r < remain[2]:
                # print(robot, remain, l, remain[2], remain[1], r)
                conflict = True
                break
            if l <= remain[1] and remain[1] < r:
                conflict = True
                break
            if l < remain[2] and remain[2] < r:
                conflict = True
                break
        if not conflict:
            remains.append(robot)
    print(len(remains))

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, *XL = map(int, open(0).read().split())
    # print(N, XL)
    robots = [0]*N
    for i in range(N):
        X, L = XL[2 * i + 0], XL[2 * i + 1]
        robots[i] = (X - L, X + L)
    robots.sort(key=lambda x: x[1])
    # print(robots)
    ans = 0
    last = robots[0][0] - 1
    for robot in robots:
        if last <= robot[0]:
            last = robot[1]
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()