Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]

ans = []
for i in range(h):
    for j in range(w - 1):
        if arr[i][j] % 2 == 1:
            arr[i][j] -= 1
            arr[i][j + 1] += 1
            ans.append([i + 1, j + 1, i + 1, j + 2])

for i in range(h - 1):
    if arr[i][w - 1] % 2 == 1:
        arr[i][w - 1] -= 1
        arr[i + 1][w - 1] += 1
        ans.append([i + 1, j + 1, i + 2, j + 1])

print(len(ans))
for x in ans:
    print(*x)

Fixed submission:
h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]

ans = []
for i in range(h):
    for j in range(w - 1):
        if arr[i][j] % 2 == 1:
            arr[i][j] -= 1
            arr[i][j + 1] += 1
            ans.append([i + 1, j + 1, i + 1, j + 2])

for i in range(h - 1):
    if arr[i][w - 1] % 2 == 1:
        arr[i][w - 1] -= 1
        arr[i + 1][w - 1] += 1
        ans.append([i + 1, w, i + 2, w])

print(len(ans))
for x in ans:
    print(*x)

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]
visited = [[False] * w for _ in range(h)]

dt = "right"
c = [0, 0]
cnt = 0
ans = []
while cnt < h * w:
    cnt += 1
    visited[c[0]][c[1]] = True
    if dt == "right":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0]][c[1] + 1] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0] + 1, c[1] + 2])
        if c[1] + 1 == w - 1 or visited[c[0]][c[1] + 1]:
            dt = "down"
        c = [c[0], c[1] + 1]
        continue
    if dt == "down":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0] + 1][c[1]] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0] + 2, c[1] + 1])
        if c[0] + 1 == h - 1 or visited[c[0] + 1][c[1]]:
            dt = "left"
        c = [c[0] + 1, c[1]]
        continue
    if dt == "left":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0]][c[1] - 1] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0] + 1, c[1]])
        if c[1] - 1 == 0 or visited[c[0]][c[1] - 1]:
            dt = "up"
        c = [c[0], c[1] - 1]
        continue
    if dt == "up":
        if arr[c[0]][c[1]] % 2 == 1:
            arr[c[0]][c[1]] -= 1
            arr[c[0] - 1][c[1]] += 1
            ans.append([c[0] + 1, c[1] + 1, c[0], c[1] + 1])
        if c[0] - 1 == 0 or visited[c[0] - 1][c[1]]:
            dt = "right"
        c = [c[0] - 1, c[1]]
        continue

print(len(ans))
for x in ans:
    print(*x)

Fixed submission:
h, w = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]

ans = []
for i in range(h):
    for j in range(w - 1):
        if arr[i][j] % 2 == 1:
            arr[i][j] -= 1
            arr[i][j + 1] += 1
            ans.append([i + 1, j + 1, i + 1, j + 2])

for i in range(h - 1):
    if arr[i][w - 1] % 2 == 1:
        arr[i][w - 1] -= 1
        arr[i + 1][w - 1] += 1
        ans.append([i + 1, w, i + 2, w])

print(len(ans))
for x in ans:
    print(*x)
Buggy python submission (verdict: Runtime Error):
import numpy as np

H, W = map(int, input().split())

ans = []

judge_h = []

for i in range(H):
    tmp = list(map(str, input().rstrip()))
    ans.append(tmp)
    if tmp.count("#")==0:
        judge_h.append(False)
    else:
        judge_h.append(True)

ans = np.array(ans)

judge_w = []

for i in range(W):
    if np.where(ans[:, i]=="#")[0].shape[0]==0:
        judge_w.append(False)
    else:
        judge_w.append(True)

ans = ans[judge_h, :]
ans = ans[:, judge_w]
ans = [list(i) for i in ans]

for i in range(len(ans)):
    print("".join(ans[i]))

Fixed submission:
H, W = map(int, input().split())

a = []

# 必要な行だけ読み込む
for i in range(H):
    tmp = list(input())
    if "#" not in tmp:
        continue
    else:
        a.append(tmp)

# 転置して削って転置
a = list(zip(*a))
a = [x for x in a if "#" in x]
a = list(zip(*a))

for i in a:
    print("".join(i))

Buggy python submission (verdict: Runtime Error):
import numpy as np

H, W = map(int, input().split())

ans = []

judge_h = []

for i in range(H):
    tmp = list(map(str, input().rstrip()))
    ans.append(tmp)
    if tmp.count("#")==0:
        judge_h.append(False)
    else:
        judge_h.append(True)

ans = np.array(ans)

judge_w = []

for i in range(W):
    if np.where(ans[:, i]=="#")[0].shape[0]==0:
        judge_w.append(False)
    else:
        judge_w.append(True)

ans = ans[judge_h, :]
ans = ans[:, judge_w]

for i in range(ans.shape[0]):
    print("".join(ans[i]))

Fixed submission:
H, W = map(int, input().split())

a = []

# 必要な行だけ読み込む
for i in range(H):
    tmp = list(input())
    if "#" not in tmp:
        continue
    else:
        a.append(tmp)

# 転置して削って転置
a = list(zip(*a))
a = [x for x in a if "#" in x]
a = list(zip(*a))

for i in a:
    print("".join(i))

Buggy python submission (verdict: Runtime Error):
import numpy as np

H, W = map(int, input().split())

ans = []

for i in range(H):
    tmp = list(map(str, input().rstrip()))
    if tmp.count("#")==0:
        continue
    else:
        ans.append(tmp)

ans = np.array(ans)

judge = []

for i in range(W):
    if np.where(ans[:, i]=="#")[0].shape[0]==0:
        judge.append(False)
    else:
        judge.append(True)

ans = ans[:, judge]

for i in range(ans.shape[0]):
    print("".join(ans[i]))

Fixed submission:
H, W = map(int, input().split())

a = []

# 必要な行だけ読み込む
for i in range(H):
    tmp = list(input())
    if "#" not in tmp:
        continue
    else:
        a.append(tmp)

# 転置して削って転置
a = list(zip(*a))
a = [x for x in a if "#" in x]
a = list(zip(*a))

for i in a:
    print("".join(i))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n - k + 1):
    left = x[i]
    right = x[i + k - 1]
    elif abs(left) > abs(right):
        ans.append(abs(right) + abs(left - right))
    else:
        ans.append(abs(left) + abs(right - left))

print(min(ans))

Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n - k + 1):
    left = x[i]
    right = x[i + k - 1]
    ans.append(min(abs(left) + abs(right - left),
                   abs(right) + abs(left - right)))

print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, k = map(int, input().split())
x = np.array(list(map(int, input().split())))

ans = []
for i in range(n - k + 1):
    left = 0
    right = 0
    arr = x[i: i + k]
    if arr.min() < 0:
        left = (np.abs(arr[np.where(arr < 0)])).max()
    if arr.max() >= 0:
        right = (arr[np.where(arr >= 0)]).max()
    ans.append(min(left * 2 + right, left + right * 2))

print(min(ans))

Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(n - k + 1):
    left = x[i]
    right = x[i + k - 1]
    ans.append(min(abs(left) + abs(right - left),
                   abs(right) + abs(left - right)))

print(min(ans))
Buggy python submission (verdict: Runtime Error):
import sympy

n = int(input())

ans = 0
for i in range(1, n + 1, 2):
    if len(sympy.divisors(i)) == 8:
        ans += 1

print(ans)

Fixed submission:
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())

ans = 0
for i in [2 * x + 1 for x in range((n + 1) // 2)]:
    if len(make_divisors(i)) == 8:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

cnt = 0

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(ans))

Fixed submission:
import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

cnt = 0
ans = 1

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(ans))

Buggy python submission (verdict: Runtime Error):
import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(s))

Fixed submission:
import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

cnt = 0
ans = 1

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(ans))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

arr = np.arange(n) + 1
diff = a - arr

diff.sort()

diff -= np.median(diff)

print(int(np.abs(diff).sum()))

Fixed submission:
import sys
import numpy as np
n = int(input())
arr = np.array(list(map(int, input().split())))

comp = np.arange(n) + 1
diff = arr - comp

diff.sort()

diff = diff - np.median(diff)

print(int(np.abs(diff).sum()))
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())

def cnt(n):
    tmp = 0
    n = n*1.0
    while n.is_integer():
        if (n/100.0).is_integer():
            tmp += 1
            n = n / 100.0
        else:
            break
            
    return tmp

coef = 100**D
whole = np.array([i*coef for i in range(1, 150)])
result = np.array(list(map(cnt, whole)))

print(whole[np.where(result==D)][N-1])

Fixed submission:
import numpy as np
D, N = map(int, input().split())

def cnt(n):
    tmp = 0
    n = n*1.0
    while n.is_integer():
        if (n/100.0).is_integer():
            tmp += 1
            n = n / 100.0
        else:
            break
            
    return tmp

coef = 100**D
whole = np.array([i*coef for i in range(1, 150)])
result = np.array(list(map(cnt, whole)))

print(whole[np.where(result==D)][N-1])
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
print(A-B) if k%2==0 else print(B-A)

Fixed submission:
A, B, C, K = map(int, input().split())
print(A-B) if K%2==0 else print(B-A)

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

A, B, C, K = map(int, input().split())

@lru_cache(maxsize=None)
def operation(A, B, C):
    return(B+C, C+A, A+B)

if (A==B) & (B==C):
    print(0)
    sys.exit()

for _ in range(K):
    A, B, C = operation(A, B, C)
    if A - B > 10**18:
        print("Unfair")
        sys.exit()

print(A - B)

Fixed submission:
A, B, C, K = map(int, input().split())
print(A-B) if K%2==0 else print(B-A)
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n + 1))
        self.size = [1] * (n + 1)

    def find(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy


n, m = map(int, input().split())
p = np.array(list(map(int, input().split())))


uf = UnionFind(n)
union = uf.union
find = uf.find


for _ in range(m):
    x, y = map(int, input().split())
    union(x - 1, y - 1)

ans = 0
for i, x in enumerate(p):
    if find(i) == find(x - 1):
        ans += 1

print(ans)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n + 1))
        self.size = [1] * (n + 1)

    def find(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy


n, m = map(int, input().split())
p = list(map(int, input().split()))


uf = UnionFind(n)
union = uf.union
find = uf.find


for _ in range(m):
    x, y = map(int, input().split())
    union(x - 1, y - 1)

ans = 0
for i, x in enumerate(p):
    if find(i) == find(x - 1):
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

tmp_s = {i for i in range(A, A+K)}
tmp_l = {i for i in range(B+1-K, B+1)}
whole = {i for i in range(A, B+1)}

ans = list(tmp_s.union(tmp_l).intersection(whole))
ans.sort()

print(*ans, sep="\n")

Fixed submission:
A, B, K = map(int, input().split())

tmp_s = {i for i in range(A, A+K)}
tmp_l = {i for i in range(B+1-K, B+1)}

ans = list(tmp_s.union(tmp_l))
ans = [i for i in ans if A<=i<=B]
ans.sort()

print(*ans, sep="\n")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = np.array([0] + list(map(int, input().split())) + [0])

whole = np.abs((np.diff(a))).sum()

for i in range(n):
    print(whole - abs(a[i + 1] - a[i]) -
          abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))

Fixed submission:
import numpy as np
n = int(input())
a = np.array([0] + list(map(int, input().split())) + [0])

whole = np.abs((np.diff(a))).sum()

for i in range(n):
    print(whole - abs(a[i + 1] - a[i]) -
          abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))
Buggy python submission (verdict: Runtime Error):
h, w, d = map(int, input().split())
arr = [0] * (h * w + 1)

a = [list(map(int, input().split())) for _ in range(h)]

for i in range(h):
    for j in range(w):
        s = a[i][j]
        arr[s] = (i, j)

q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

cnt = h * w
result = [[0] for _ in range(d)]
for i in range(d):
    l = i
    score = 0
    while l + d <= cnt:
        if l == 0:
            result[i].append(score)
            l += d
            continue
        (ux, uy) = arr[l]
        (vx, vy) = arr[l + d]
        score += (abs(vx - ux) + abs(vy - uy))
        result[i].append(score)
        l += d


for l, r in lr:
    ans = result[l % d]
    print(ans[r // d] - ans[l // d])

Fixed submission:
n = int(input())
print(n // 3)
Buggy python submission (verdict: Runtime Error):
n = int(input())

csf = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    csf.append([c, s, f])

ans = []
for i in range(n - 1):
    tmp = csf[i][0] + csf[i][1]
    for j in range(i + 1, n - 1):
        if tmp < csf[j][1]:
            tmp = csf[j][0] + csf[j][1]
        elif (tmp - csf[j][1]) % csf[j][2] == 0:
            tmp += csf[j][0]
        else:
            tmp = ((tmp // csf[j][2] + 1) * csf[j][2] + csf[j][0]
    ans.append(tmp)
ans.append(0)

print(*ans, sep="\n")

Fixed submission:
n = int(input())

csf = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    csf.append([c, s, f])

ans = []
for i in range(n - 1):
    tmp = csf[i][0] + csf[i][1]
    for j in range(i + 1, n - 1):
        if tmp < csf[j][1]:
            tmp = csf[j][0] + csf[j][1]
        elif (tmp - csf[j][1]) % csf[j][2] == 0:
            tmp += csf[j][0]
        else:
            tmp = (tmp // csf[j][2] + 1) * csf[j][2] + csf[j][0]
    ans.append(tmp)
ans.append(0)

print(*ans, sep="\n")

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

csf = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    csf.append([c, s, f])

ans = []
for i in range(n - 1):
    tmp = csf[i][0] + csf[i][1]
    for j in range(i + 1, n - 1):
        if tmp < csf[j][1]:
            tmp = csf[j][0] + csf[j][1]
        elif (tmp - csf[j][1]) % csf[j][2] == 0:
            tmp += csf[j][0]
        else:
            tmp += ((tmp // csf[j][2] + 1) * csf[j][2] + csf[j][0]
    ans.append(tmp)
ans.append(0)

print(*ans, sep="\n")

Fixed submission:
n = int(input())

csf = []

for i in range(n - 1):
    c, s, f = map(int, input().split())
    csf.append([c, s, f])

ans = []
for i in range(n - 1):
    tmp = csf[i][0] + csf[i][1]
    for j in range(i + 1, n - 1):
        if tmp < csf[j][1]:
            tmp = csf[j][0] + csf[j][1]
        elif (tmp - csf[j][1]) % csf[j][2] == 0:
            tmp += csf[j][0]
        else:
            tmp = (tmp // csf[j][2] + 1) * csf[j][2] + csf[j][0]
    ans.append(tmp)
ans.append(0)

print(*ans, sep="\n")
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
diff = a + b - c - d
print("Left" if diff > 0 "Balanced" if diff == 0 else "Right")

Fixed submission:
a, b, c, d = map(int, input().split())
diff = a + b - c - d
print("Left" if diff > 0 else "Balanced" if diff == 0 else "Right")
Buggy python submission (verdict: Time Limit Exceeded):
def lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return lucas(n-1) + lucas(n-2)

N = int(input())

print(lucas(N))

Fixed submission:
from functools import lru_cache

@lru_cache(maxsize=None)
def lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return lucas(n-1) + lucas(n-2)

N = int(input())

print(lucas(N))
Buggy python submission (verdict: Runtime Error):
from collections import deque
import numpy as np

h, w = map(int, input().split())
dp = [list(map(int, input().split())) for _ in range(10)]
arr = np.array([list(map(int, input().split())) for h in range(h)])

# ワーシャルフロイド法で更新がなくなるまで更新
while True:
    prev = copy.deepcopy(dp)
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if i == j:
                    continue
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    if prev != dp:
        break
    prev = dp

arr = arr.flatten()

print(sum([dp[x][1] for x in arr if x != -1 or x != 1]))

Fixed submission:
import copy

h, w = map(int, input().split())
dp = [list(map(int, input().split())) for _ in range(10)]

# ワーシャルフロイド法で更新がなくなるまで更新
while True:
    prev = copy.deepcopy(dp)
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if i == j:
                    continue
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    if prev == dp:
        break
    prev = dp

ans = 0
for i in range(h):
    arr = list(map(int, input().split()))
    ans += sum([dp[x][1] for x in arr if x != -1])

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

s = deque(map(str, input().rstrip()))

cnt = 0
while s:
    if s[0] != s[-1]:
        if s[0] != "x" and s[-1] != "x":
            print(-1)
            sys.exit()
        elif s[0] == "x":
            tmp = s.popleft()
        else:
            tmp = s.pop()
        cnt += 1
    elif len(s) <= 1:
        break
    else:
        s.popleft()
        s.pop()

print(cnt)

Fixed submission:
import sys
from collections import deque

s = deque(map(str, input().rstrip()))

cnt = 0
while s:
    if s[0] != s[-1]:
        if s[0] != "x" and s[-1] != "x":
            print(-1)
            sys.exit()
        elif s[0] == "x":
            tmp = s.popleft()
        else:
            tmp = s.pop()
        cnt += 1
    elif len(s) <= 1:
        break
    else:
        s.popleft()
        s.pop()

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = list(map(str, input().rstrip()))

ns = [x for x in s if x != "x"]


def is_palin(s):
    result = []
    for i in range((len(s) + 1) // 2):
        result.append(s[i] == s[- i - 1])
    return all(result)


if not is_palin(ns):
    print(-1)
    sys.exit()

i = 0
cnt = 0
while not is_palin(s):
    if s[i] != s[- i - 1]:
        if s[i] == "x":
            if i == 0:
                s.append("x")
            else:
                s.insert(-i, "x")
        else:
            s.insert(i, "x")
        cnt += 1
    i += 1

print(cnt)

Fixed submission:
import sys
from collections import deque

s = deque(map(str, input().rstrip()))

cnt = 0
while s:
    if s[0] != s[-1]:
        if s[0] != "x" and s[-1] != "x":
            print(-1)
            sys.exit()
        elif s[0] == "x":
            tmp = s.popleft()
        else:
            tmp = s.pop()
        cnt += 1
    elif len(s) <= 1:
        break
    else:
        s.popleft()
        s.pop()

print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)

for d in D:
    memo[d] += 1

for t in T:
    memo[t] -= 1

memo.sort()

print("YES" if memo[0] >= 0 else "NO")

Fixed submission:
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)

for d in D:
    memo[d] += 1

for t in T:
    memo[t] -= 1

memo = list(memo.values())
memo.sort()

print("YES" if memo[0] >= 0 else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(input())


for i in range(1, 3500):
    for j in range(1, 3500):
        # 分子
        rest = 4 * i * j - n * i - n * j
        if rest > 0:
            ans = n * i * j / rest
            if ans.is_integer():
                print(i, j, int(ans))
                sys.exit()

Fixed submission:
import sys

n = int(input())


for i in range(1, 3500):
    for j in range(1, 3500):
        # 分子
        rest = 4 * i * j - n * i - n * j
        if rest > 0:
            ans = n * i * j / rest
            if ans.is_integer():
                print(i, j, int(ans))
                sys.exit()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
arr = list(map(int, input().split()))

d = defaultdict(int)

for x in arr:
    d[x] += 1

ans = []
for i in range(1, max(arr)):
    ans.append(d[i - 1] + d[i] + d[i + 1])

print(max(ans))

Fixed submission:
from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split()))

d = defaultdict(int)

for x in arr:
    d[x] += 1

ans = []
for i in range(1, max(arr)):
    ans.append(d[i - 1] + d[i] + d[i + 1])

print(max(ans))

Fixed submission:
from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])

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

ans = 0

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

print(ans)

Fixed submission:
from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))

ans = 0

for i in range(N):
    tmp = a.copy()
    tmp = np.abs(tmp - tmp[i])
    ans = max(ans, np.where(tmp<=1)[0].shape[0])

print(ans)

Fixed submission:
from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = np.array(list(map(int, input().split())))

ans = 0

for i in range(N):
    tmp = a.copy()
    tmp = np.abs(tmp - tmp[i])
    ans = max(ans, np.where(tmp<=1)[0].shape[0])

print(ans)

Fixed submission:
from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])