Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())

    s = []
    e = []
    tls = []
    buff = {}
    for i in range(n):
        tmp = list(map(int, input().split()))
        s.append(tmp[0] - tmp[1])
        e.append(tmp[0] + tmp[1])
    for i in range(n):
        buff[s[i]] = e[i]
    
    maxcount = 0
    sorted_s = sorted(s)
    preve = 0
    while len(sorted_s) > 0:
        tmps = sorted_s[0]
        tmpe = buff[tmps]
        if preve == 0:
            maxcount += 1
            preve = tmpe
            sorted_s = sorted_s[1:]
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
            sorted_s = sorted_s[1:]
        elif tmpe < preve:
            preve = tmpe
            sorted_s = sorted_s[1:]
        else:
            sorted_s = sorted_s[1:]
    print(maxcount)
    return
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys #追加
    sys.setrecursionlimit(500*500) #追加
    n = int(input())

    x = []
    l = []
    tls = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0])
        l.append(tmp[1])
    x, l = zip(*sorted(zip(x, l)))

    m = {}
    def solve(prev, idx):
        if idx == n:
            return 0
        key = (prev, idx)
        if key in m:
            return m[key]
        res_use = 0
        res_nouse = 0
        if idx < n - 1:
            if x[idx] + l[idx] >= x[idx+1] + l[idx+1]: 
                return solve(prev, idx+1)
        if x[idx] - l[idx] >= prev or prev == 0:
            res_use = 1
            res_use += solve(x[idx] + l[idx], idx + 1)
        res_nouse += solve(prev, idx + 1)

        ans = max(res_use, res_nouse)
        m[key] = ans
        return ans
    print(solve(0, 0))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys #追加
    sys.setrecursionlimit(500*500) #追加
    n = int(input())

    x = []
    l = []
    tls = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0])
        l.append(tmp[1])
    x, l = zip(*sorted(zip(x, l)))

    m = {}
    def solve(prev, idx):
        if idx == n:
            return 0
        key = (prev, idx)
        if key in m:
            return m[key]
        res_use = 0
        res_nouse = 0

        if x[idx] - l[idx] >= prev or prev == 0:
            res_use = 1
            res_use += solve(x[idx] + l[idx], idx + 1)
        res_nouse += solve(prev, idx + 1)

        ans = max(res_use, res_nouse)
        m[key] = ans
        return ans
    print(solve(0, 0))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())

    x = []
    l = []
    tls = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0])
        l.append(tmp[1])
    x, l = zip(*sorted(zip(x, l)))

    m = {}
    def solve(prev, idx):
        if idx == n:
            return 0
        key = (prev, idx)
        if key in m:
            return m[key]
        res_use = 0
        res_nouse = 0

        if x[idx] - l[idx] >= prev or prev == 0:
            res_use = 1
            res_use += solve(x[idx] + l[idx], idx + 1)
        res_nouse += solve(prev, idx + 1)

        ans = max(res_use, res_nouse)
        m[key] = ans
        return ans
    print(solve(0, 0))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())

x = []
l = []
tls = []
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    l.append(tmp[1])
x, l = zip(*sorted(zip(x, l)))

m = {}
def solve(prev, idx):
    if idx == n:
        return 0
    key = (prev, idx)
    if key in m:
        return m[key]
    res_use = 0
    res_nouse = 0

    if x[idx] - l[idx] >= prev or prev == 0:
        res_use = 1
        res_use += solve(x[idx] + l[idx], idx + 1)
    res_nouse += solve(prev, idx + 1)

    ans = max(res_use, res_nouse)
    m[key] = ans
    return ans
print(solve(0, 0))

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())

x = []
l = []
tls = []
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    l.append(tmp[1])
x, l = zip(*sorted(zip(x, l)))

m = {}
def solve(prev, idx):
    if idx == n:
        return 0
    key = (prev, idx)
    if key in m:
        return m[key]
    res_use = 0
    res_nouse = 0

    if x[idx] - l[idx] >= prev or prev == 0:
        res_use = 1
        res_use += solve(x[idx] + l[idx], idx + 1)
    res_nouse += solve(prev, idx + 1)

    ans = max(res_use, res_nouse)
    m[key] = ans
    return ans
print(solve(0, 0))
    

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())

x = []
l = []
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    l.append(tmp[1])
keydict = dict(zip(l, x))
l.sort(key=keydict.get)
x.sort()

m = {}
def solve(prev, idx):
    if idx == n:
        return 0
    key = (prev, idx)
    if key in m:
        return m[key]
    res_use = 0
    res_nouse = 0

    if x[idx] - l[idx] >= prev or prev == 0:
        res_use = 1
        res_use += solve(x[idx] + l[idx], idx + 1)
    res_nouse += solve(prev, idx + 1)

    ans = max(res_use, res_nouse)
    m[key] = ans
    return ans
print(solve(0, 0))

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())

x = []
l = []
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    l.append(tmp[1])
keydict = dict(zip(l, x))
l.sort(key=keydict.get)
x.sort()

m = {}
def solve(prev, idx):
    if idx == n:
        return 0
    key = (prev, idx)
    if key in m:
        return m[key]
    res_use = 0
    res_nouse = 0

    if x[idx] - l[idx] >= prev or prev == 0:
        res_use = 1
        res_use += solve(x[idx] + l[idx], idx + 1)
    res_nouse += solve(prev, idx + 1)

    ans = max(res_use, res_nouse)
    m[key] = ans
    return ans
print(solve(0, 0))

Fixed submission:
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()