Buggy python submission (verdict: Runtime Error):
import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * (max(a)+1)

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] + k[2:]):
    ans = max(ans, q+r+s)

print(ans)

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)

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

temp = {}
for i in a_:
    temp[i] = a.count(i)

temp3 = []
for i in a_:
    if i in temp:
        a1 = temp[i]
    else :
        a1 = 0

    if i+1 in temp:
        a2 = temp[i+1]
    else :
        a2 = 0

    if i-1 in temp:
        a3 = temp[i-1]
    else :
        a3 = 0
        
    temp3.append(a1+a2+a3)
 
print(max(temp3))

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
 
a_ = list(set(a))
temp = []
for i in a_:
    temp.append(a.count(i+1) + a.count(i) + a.count(i-1))
 
print(max(temp))

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))

a_ = list(set(a))
temp2 = []

for i in a_:
    temp2.appned(a.count(a_))

temp = []
for i in range(1,len(temp2)):
    temp = temp2[i-1] + temp2[i] + temp2[i+1]

print(max(temp))

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)

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

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

a_ = list(set(a))
temp = []
for i in a_:
    temp.append(a.count(i+1) + a.count(i) + a.count(i-1))

print(max(temp))

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)

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

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

a_ = list(set(a))
temp = []
for i in a:
    temp.append(a.count(i+1) + a.count(i) + a.count(i-1))

print(max(temp))

Fixed submission:

import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * max(3,(max(a)+1))

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)