Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = list()

    for i in range(min(a),max(a)+1):
        cnt.append(a.count(i-1)+a.count(i)+a.count(i+1))
    print(max(cnt))

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = list()

    for i in range(min(a),max(a)+1):
        cnt.append(a.count(i-1)+a.count(i)+a.count(i+1))
    print(max(cnt))

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = 0

    for i in range(1,10**5):
        cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = 0

    for i in range(min(a),max(a)+1):
        cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = sorted(list(map(int,input().split())))
    cnt = 0

    for i in range(a[0],a[N-1]+1):
        cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = sorted(list(map(int,input().split())))
    cnt = 0

    for i in range(a[0],a[N-1]+1):
        cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    a = sorted(list(map(int,input().split())))
    cnt = 0

    for i in range(a[0],a[N-1]+1):
        cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = sorted(list(map(int,input().split())))
cnt = 0

for i in range(a[0],a[N-1]+1):
    cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
print(cnt)

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

    for i in a:
        if i != 0:
            cnt[i-1] += 1
        cnt[i] += 1
        cnt[i+1] += 1
    print(max(cnt))

if __name__ == "__main__":
    main()