Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    edges = [int(i) for i in input().split()]

    ans = set()
    for i, a in enumerate(edges):
        for j, b in enumerate(edges[i+1:]):
            for k, c in enumerate(edges[i+j+2:]):
                if a < b + c and b < c + a and c < a + b:
                    ans.add((a, b, c))
    print(len(ans))


if __name__ == "__main__":
    main()

Fixed submission:
import bisect


def main():
    N = int(input())
    edges = [int(i) for i in input().split()]
    edges.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_left(edges, edges[a] + edges[b])-b-1

    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations


def main():
    N = int(input())
    edges = [int(i) for i in input().split()]

    ans = set()
    edges.sort()
    for a in range(N - 2):
        for b, c in combinations(range(a + 1, N), 2):
            if edges[a] < edges[b] + edges[c] and edges[b] < edges[c] + edges[a] and edges[c] < edges[a] + edges[b]:
                ans.add((a, b, c))
    print(len(ans))


if __name__ == "__main__":
    main()

Fixed submission:
import bisect


def main():
    N = int(input())
    edges = [int(i) for i in input().split()]
    edges.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_left(edges, edges[a] + edges[b])-b-1

    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    edges = [int(i) for i in input().split()]

    ans = set()
    edges.sort()
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            for c in range(b + 1, N):
                if edges[a] < edges[b] + edges[c] and edges[b] < edges[c] + edges[a] and edges[c] < edges[a] + edges[b]:
                    ans.add((a, b, c))
    print(len(ans))


if __name__ == "__main__":
    main()

Fixed submission:
import bisect


def main():
    N = int(input())
    edges = [int(i) for i in input().split()]
    edges.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            ans += bisect.bisect_left(edges, edges[a] + edges[b])-b-1

    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from itertools import groupby
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    K = int(input())
    grouped = [len(tuple(s)) for _, s in groupby(S)]

    if len(grouped) > 1 and S[0] == S[-1]:
        _sum = 0
        top = grouped[0]
        tail = grouped[-1]
        for group in grouped[1:-1]:
            _sum += group[1] // 2
        dif = (top // 2) + (tail // 2) + (top + tail) * (K - 1) // 2
        print(_sum * K + dif)
    else:
        _sum = 0
        for group in grouped:
            _sum += group[1] // 2
        print(_sum * K)


if __name__ == "__main__":
    main()


Fixed submission:
from itertools import groupby


def main():

    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupby(S)]
    ans = 0

    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            ans = a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0] + a[-1]) // 2 * (K - 1)
            ans += sum(n // 2 for n in a[1:-1]) * K
    else:
        ans = sum(n // 2 for n in a) * K
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, K, Q = [int(i) for i in input().split()]
    L = [0] * N
    Submits = [int(input()) for _ in range(Q)]

    for submit in Submits:
        L[submit] =  L[submit] + 1
    
    for chk in L:
        if K - Q + chk > 0:
            print("Yes")
        else:
            print("No")



if __name__ == "__main__":
    main()

Fixed submission:
from collections import Counter

def main():
    N, K, Q = [int(i) for i in input().split()]
    Submits = Counter([int(input()) for _ in range(Q)])
    for n in range(1, N + 1):
        try:
            if K - Q + Submits[n] > 0:
                print("Yes")
            else:
                print("No")
        except:
            print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
print(sum([i for i in range(int(input()))]))

Fixed submission:
N = int(input())

print(str(int((N-1)*N//2)))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

N = int(input())
c = Counter(["".join(sorted(list(input()))) for i in range(N)])
res = 0
for k,i in c.most_common():
  if i == 1:
    break
  res += len(list(combinations([0 for n in range(i)],2)))

print(res)

Fixed submission:
N = int(input())
l = ["".join(sorted(list(input()))) for i in range(N)]
d = {}
ans = 0

for text in l:
  if text in d.keys():
    d[text] += 1
    ans += d[text]
  else:
    d[text] = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

N = int(input())
c = Counter(["".join(sorted(list(input()))) for i in range(N)])
res = 0
for i in c.values():
  if i > 1:
    res += len(list(combinations([0 for n in range(i)],2)))

print(res)

Fixed submission:
N = int(input())
l = ["".join(sorted(list(input()))) for i in range(N)]
d = {}
ans = 0

for text in l:
  if text in d.keys():
    d[text] += 1
    ans += d[text]
  else:
    d[text] = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = [int(i) for i in input().split()]

tmp = 2019
ans = 2019

for i in range(L,R):
  for j in range(i+1,R+1):
    tmp = (i*j)%2019
    ans = min(tmp,ans)

print(ans)

Fixed submission:
L,R = [int(i) for i in input().split()]

tmp = 2019
ans = 2019

for i in range(L,R):
  for j in range(i+1,R+1):
    tmp = (i*j)%2019
    ans = min(tmp,ans)
    if ans == 0:
      break
  else:
    continue
  break

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class GaussElimination:
    def __init__(self, a):
        self.a = a
        self.n = len(self.a)

    def exec(self):
        try:
            for k in range(self.n - 1):
                for i in range(k + 1, self.n):
                    d = self.a[i][k] / self.a[k][k]
                    for j in range(k + 1, self.n + 1):
                        self.a[i][j] -= self.a[k][j] * d
            for i in range(self.n - 1, -1, -1):
                d = self.a[i][self.n]
                for j in range(i + 1, self.n):
                    d -= self.a[i][j] * self.a[j][self.n]
                self.a[i][self.n] = d / self.a[i][i]
        except Exception:
            raise


def main():
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    matrix = [[0] * (N + 1) for _ in range(N)]
    for i in range(N):
        if i == N - 1:
            matrix[N - 1][0] = 1
            matrix[N - 1][N - 1] = 1
        else:
            matrix[i][i] = 1
            matrix[i][i + 1] = 1
        matrix[i][N] = A[i]
    gauss = GaussElimination(matrix)
    gauss.exec()
    ans = []
    for i in range(N):
        ans.append(str(int(gauss.a[i][N] * 2)))
    print(" ".join(ans))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    tmp = 0
    ans = [0] * n
    f = 1
    for i in a:
        tmp += f * i
        f = f * -1
    ans[0] = tmp
    ans[n - 1] = 2 * a[n - 1] - ans[0]
    for i in range(n - 2, 0, -1):
        ans[i] = 2 * a[i] - ans[i + 1]

    print(" ".join([str(i) for i in ans]))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    for i in range(a - 1, max(c, d) - 1):
        if S[i] == S[i + 1] == "#":
            print("No")
            quit()
    if c < d:
        print("Yes")
        quit()
    if c > d:
        for i in range(b - 2, d - 1):
            if S[i, i + 3] == "...":
                print("Yes")
                quit()
        print("No")
        quit()


if __name__ == "__main__":
    main()


Fixed submission:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    for i in range(a - 1, max(c, d) - 1):
        if S[i] == S[i + 1] == "#":
            print("No")
            quit()
    if c < d:
        print("Yes")
        quit()
    if c > d:
        for i in range(b - 2, d - 1):
            if S[i: i + 3] == "...":
                print("Yes")
                quit()
        print("No")
        quit()


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

# step1: pre-process "BC" を Xに置き換える
tmp = ""
flag = False  # skip用
for i in range(1, len(s)):
    if flag:
        flag = False
        continue
    elif s[i - 1] + s[i] == "BC":
        tmp += "X"
        flag = True
    else:
        tmp += s[i - 1]

if not flag:
    tmp += s[-1]

cnt = 0
ans = 0
# step:2 Xより左側にあるAの数を数える。
# ただし、B、Cが現れると、カウンターリセット
# （そのB、Cを越えてSwapできないため）
for i in range(len(tmp)):
    if tmp[i] == "A":
        cnt += 1
    elif tmp[i] == "B" or tmp[i] == "C":
        cnt = 0
    elif tmp[i] == "X":
        ans += cnt

print(ans)


Fixed submission:
s = input()

tmp = ""
cnt = 0
ans = 0
flag = False  # skip用
for i in range(0, len(s) - 1):
    if flag:
        flag = False
        continue
    if s[i] == "A":
        cnt += 1
    elif s[i] + s[i + 1] == "BC":
        ans += cnt
        flag = True
    else:
        cnt = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()
# sys.setrecursionlimit(100000)


def helper(cur: list, B, candi, ans, rest):
    if rest == 0:
        if cur == B:
            for i in ans:
                print(i)
            sys.exit()
        else:
            return
    for k, v in candi.items():
        if v > 0 and len(cur) + 1 >= k:
            cur.insert(k - 1, k)

            candi[k] -= 1
            helper(cur, B, candi, ans + [k], rest - 1)
            cur.pop(k - 1)
            candi[k] += 1


def main():
    n = int(input().strip())
    B = [int(i) for i in input().strip().split()]
    counter = Counter(B)
    helper([], B, counter, [], n)
    print(-1)
    return


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()
# sys.setrecursionlimit(100000)


def main():
    n = int(input().strip())
    B = [int(i) for i in input().strip().split()]
    ans = []
    ptr = len(B)
    while ptr > 0:
        if B[ptr - 1] == ptr:
            ans.append(B.pop(ptr - 1))
            ptr = len(B)
        else:
            ptr -= 1
    if len(ans) == n:
        for i in ans[::-1]:
            print(i)
    else:
        print(-1)

    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def main():
    N, W = [int(i) for i in input().strip().split()]
    items = [[int(i) for i in input().strip().split()] for _ in range(N)]

    dp = [[0 for _ in range(N)] for _ in range(W + 1)]

    for i in range(N):
        for capacity in range(W + 1):
            if i == 0:
                if capacity >= items[i][0]:
                    dp[capacity][i] = items[i][1]
                else:
                    dp[capacity][i] = 0
            else:
                if capacity >= items[i][0]:
                    dp[capacity][i] = max(
                        dp[capacity][i - 1], dp[capacity - items[i][0]][i - 1] + items[i][1])
                else:
                    dp[capacity][i] = dp[capacity][i-1]

    return dp[-1][-1]


if __name__ == "__main__":
    print(main())

Fixed submission:
class Solver():
    def __init__(self, N, costs):
        self.dp = [-1] * N
        self.dp[0] = 0
        self.costs = costs

    def solve(self):
        for i in range(1, len(self.costs)):
            if i == 1:
                self.dp[i] = abs(self.costs[i]-self.costs[i-1])
                continue
            self.dp[i] = min(self.dp[i - 1] + abs(self.costs[i] - self.costs[i-1]),
                        self.dp[i - 2] + abs(self.costs[i] - self.costs[i-2]))

        return self.dp[-1]


def main():
    N = int(input())
    costs = [int(i) for i in input().split()]
    solver = Solver(N, costs)
    print(solver.solve())


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():

    N, K = [int(i) for i in input().strip().split()]
    hights = [int(i) for i in input().strip().split()]
    min_costs = [10000*N] * N
    min_costs[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if j <= i:
                min_costs[i] = min(
                    min_costs[i - j] + abs(hights[i] - hights[i - j]), min_costs[i])
            else:
                break
    return min_costs[-1]


if __name__ == "__main__":
    print(main())


Fixed submission:
class Solver():
    def __init__(self, N, costs, K):
        self.dp = [99999999999] * N
        self.dp[0] = 0
        self.K = K
        self.costs = costs

    def solve(self):
        for i in range(0, len(self.costs)):
            for k in range(1, self.K + 1):
                if i >= k:
                    self.dp[i] = min(
                        self.dp[i - k] + abs(self.costs[i] - self.costs[i-k]), self.dp[i])
        return self.dp[-1]


def main():
    N, K = [int(i) for i in input().split()]
    costs = [int(i) for i in input().split()]
    solver = Solver(N, costs, K)
    print(solver.solve())


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():

    N, K = [int(i) for i in input().strip().split()]
    hights = [int(i) for i in input().strip().split()]
    min_costs = [float("inf")] * N
    min_costs[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if j <= i:
                min_costs[i] = min(
                    min_costs[i - j] + abs(hights[i] - hights[i - j]), min_costs[i])
    return min_costs[-1]


if __name__ == "__main__":
    print(main())


Fixed submission:
class Solver():
    def __init__(self, N, costs, K):
        self.dp = [99999999999] * N
        self.dp[0] = 0
        self.K = K
        self.costs = costs

    def solve(self):
        for i in range(0, len(self.costs)):
            for k in range(1, self.K + 1):
                if i >= k:
                    self.dp[i] = min(
                        self.dp[i - k] + abs(self.costs[i] - self.costs[i-k]), self.dp[i])
        return self.dp[-1]


def main():
    N, K = [int(i) for i in input().split()]
    costs = [int(i) for i in input().split()]
    solver = Solver(N, costs, K)
    print(solver.solve())


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

ans = ""

for x in range(2**len(s)):
  tmp = ""
  r1 = -1
  _s = "" 
  for y in range(len(s)):
    if ((x >> y) & 1):
      _s += s[y]
  for i in range(len(_s)):
    for j in range(len(t)):
      if _s[i] == t[j]:
        if j > r1:
          tmp += _s[i]
          r1 = j
          break
  if len(tmp) > len(ans):
    ans = tmp

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline

class Solver(object):
    def __init__(self):
        pass

    def solve(self,s:str,t:str) -> int:
        ## DP loop
        dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
        for i in range(len(s)):
            for j in range(len(t)):
                if s[i] == t[j]:
                    dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1)
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j],dp[i][j+1])
        
        ans = ""

        ## Recover the LCS from DP table
        ## checking the update point
        l,m = len(s),len(t)
        while l > 0 and m >0:
            if dp[l][m] == dp[l-1][m]:
                l -= 1
            elif dp[l][m] == dp[l][m-1]:
                m -= 1
            else:
                ans = t[m-1] + ans
                l -= 1
                m -= 1

        return ans

def main():
    s = input().rstrip()
    t = input().rstrip()
    solver = Solver()
    print(solver.solve(s,t))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
S = input()
k = int(input())
n = len(S)

orders = set()

for i in range(n):
    for j in range(1, 6):
        if i + j < n:
            orders.add(S[i:i + j])

print(sorted(list(orders))[k - 1])


Fixed submission:
S = input()
k = int(input())
n = len(S)

orders = set()

for i in range(n):
    for j in range(1, 6):
        if i + j < n + 1:
            orders.add(S[i:i + j])

print(sorted(list(orders))[k - 1])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
k = int(input())

begin, end = 0, 1

# 辞書順先頭となる1文字目を探索

top = S[0]
idxs = {0}

for idx, s in enumerate(S):
    if ord(s) < ord(top):
        idxs = {idx}
        top = s
    elif ord(s) == ord(top):
        idxs.add(idx)

orders = {top}
while len(orders) < k:
    flag = False
    for idx in idxs:
        ptr = 2
        while idx + ptr < len(S) + 1 and ptr < 7:
            orders.add(S[idx: idx + ptr])
            flag = True
            ptr += 1
    if not flag:
        break


if len(orders) < k:
    second = chr(123)
    idxs = set()
    for idx, s in enumerate(S):
        if s != top:
            if ord(s) < ord(second):
                idxs = {idx}
                second = s
            elif ord(s) == ord(second):
                idxs.add(idx)

    orders.add(second)
    ptr = 2
    while len(orders) < 5:
        flag = False
        for idx in idxs:
            ptr = 2
            while idx + ptr < len(S) + 1 and ptr < 7:
                orders.add(S[idx: idx + ptr])
                flag = True
                ptr += 1
        if not flag:
            break

print(sorted(list(orders))[k - 1])


Fixed submission:
S = input()
k = int(input())
n = len(S)

orders = set()

for i in range(n):
    for j in range(1, 6):
        if i + j < n + 1:
            orders.add(S[i:i + j])

print(sorted(list(orders))[k - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
 
def main():
    a,b,k = map(int,input().rstrip().split())
    numbers=[i for i in range(a,b+1)]
    A=set(numbers[:k])
    B=set(numbers[-k:])
    answers = A|B
    
    for i in sorted(answers):
        print("{}".format(i))
 
 
if __name__=="__main__":
    main()

Fixed submission:
a, b, k = [int(i) for i in input().split()]

lim_1 = min(a + k, b)
lim_2 = max(b - k + 1, a)
ans = set(list(range(a, lim_1)) + list(range(lim_2, b + 1)))

for n in ans:
    print(n)

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
def main():
    numbers=[]
    a,b,k = map(int,input().split())
    numbers=np.arange(a,b+1)
    A=set(numbers[:k])
    B=set(numbers[-k:])
    answer = A|B
    
    for i in sorted(answer):
        print("{}".format(i))
 
 
if __name__=="__main__":
    main()

Fixed submission:
a, b, k = [int(i) for i in input().split()]

lim_1 = min(a + k, b)
lim_2 = max(b - k + 1, a)
ans = set(list(range(a, lim_1)) + list(range(lim_2, b + 1)))

for n in ans:
    print(n)

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
import numpy as np
 
def main():
    numbers=[]
    a,b,k = map(int,input().rstrip().split())
    numbers=np.arange(a,b+1)
    #A=set(numbers[:k])
    #B=set(numbers[-k:])
    #answer = A|B
    
    #for i in sorted(answer):
    #    print("{}".format(i))
 
 
if __name__=="__main__":
    main()

Fixed submission:
a, b, k = [int(i) for i in input().split()]

lim_1 = min(a + k, b)
lim_2 = max(b - k + 1, a)
ans = set(list(range(a, lim_1)) + list(range(lim_2, b + 1)))

for n in ans:
    print(n)

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
import numpy as np
 
def main():
    numbers=[]
    a,b,k = map(int,input().rstrip().split())
    numbers=np.arange(a,b+1)
    A=set(numbers[:min(k,b+1)])
    B=set(numbers[max(b-k,a):])
    answer = A.union(B)
    
    for i in sorted(answer):
        print("{}".format(i))
 
 
if __name__=="__main__":
    main()

Fixed submission:
a, b, k = [int(i) for i in input().split()]

lim_1 = min(a + k, b)
lim_2 = max(b - k + 1, a)
ans = set(list(range(a, lim_1)) + list(range(lim_2, b + 1)))

for n in ans:
    print(n)

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
import numpy as np
 
def main():
    numbers=[]
    a,b,k = map(int,input().rstrip().split())
    numbers=np.arange(a,b+1)
    A=set(numbers[:k])
    B=set(numbers[-k:])
    answers = A|B
    
    for i in sorted(answers):
        print("{}".format(i))
 
 
if __name__=="__main__":
    main()

Fixed submission:
a, b, k = [int(i) for i in input().split()]

lim_1 = min(a + k, b)
lim_2 = max(b - k + 1, a)
ans = set(list(range(a, lim_1)) + list(range(lim_2, b + 1)))

for n in ans:
    print(n)
Buggy python submission (verdict: Runtime Error):
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    for a in range(1, 3501):
        for b in range(1, 3501):
            numerator = a * b * n
            denominator = 4 * a * b - a * n - b * n
            if denominator == 0:
                continue
            c = numerator // denominator
            if n / 4 == 1 / a + 1 / b + 1 / c:
                print(a, b, c)
                return
    return


if __name__ == "__main__":
    main()


Fixed submission:
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    for a in range(1, 3501):
        for b in range(1, 3501):
            if 4 * a * b - n * b - n * a == 0:
                continue
            c = (n * a * b) // (4 * a * b - n * b - n * a)
            if c < 1:
                continue
            if 4 * a * b * c == n * (a * b + b * c + c * a):
                print(a, b, c)
                return
    return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)
 
counter = np.bincount(A)
if len(counter) <= 2:
  answer = counter.sum()
else:
  answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)
 
counter = np.bincount(A)
if len(counter) <= 2:
  answer = counter.sum()
else:
  answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer)