Buggy python submission (verdict: Runtime Error):
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    n=0
    check = 0
    checkmm = 0
    checkm = 0
    a.sort()
    for i in a:
        if i == i-1:
            break
        if i-2 in a:
            checkmm = checkm
        else:
            checkmm = 0

        if i-1 in a:
            checkm = check
        else :
            checkm = 0
        check = 0
        while a[n] == i:
            check = check + 1
            n = n+1
            if N==n:
                break


        if ans < check+checkm+checkmm:
            ans = check+checkm+checkmm

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    count = [0]*100000

    for i in a:
        count[i] += 1

    print(max(map(sum,zip(count,count[1:],count[2:]))))


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    check = 0
    checkmm = 0
    checkm = 0
    a.sort()
    for i in a:
        if i == i-1:
            break
        if i-2 in a:
            checkmm = checkm
        else:
            checkmm = 0

        if i-1 in a:
            checkm = check
        else :
            checkm = 0

        check = a.count(i)


        if ans < check+checkm+checkmm:
            ans = check+checkm+checkmm

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    count = [0]*100000

    for i in a:
        count[i] += 1

    print(max(map(sum,zip(count,count[1:],count[2:]))))


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    check = 0
    checkmm = 0
    checkm = 0
    a.sort()
    for i in a:
        if i-2 in a:
            checkmm = checkm
        else:
            checkmm = 0

        if i-1 in a:
            checkm = check
        else :
            checkm = 0

        check = a.count(i)


        if ans < check+checkm+checkmm:
            ans = check+checkm+checkmm

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    count = [0]*100000

    for i in a:
        count[i] += 1

    print(max(map(sum,zip(count,count[1:],count[2:]))))


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in a:
        check = a.count(i)
        check2 = a.count(i-1)
        check3 = a.count(i+1)
        if ans < check+check2+check3:
            ans = check+check2+check3

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    count = [0]*100000

    for i in a:
        count[i] += 1

    print(max(map(sum,zip(count,count[1:],count[2:]))))


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(1,500000):
        check = a.count(i)
        check2 = a.count(i-1)
        check3 = a.count(i+1)
        if ans < check+check2+check3:
            ans = check+check2+check3

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    count = [0]*100000

    for i in a:
        count[i] += 1

    print(max(map(sum,zip(count,count[1:],count[2:]))))


if __name__ == '__main__':
    solve()