Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import sys
from itertools import permutations

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 3色を全探索
N, COLOR = lr()
D = [lr() for _ in range(COLOR)]
C = [lr() for _ in range(N)]

answer = 10 ** 10
for comb in permutations(range(COLOR), 3):
    temp = 0
    for i in range(N):
        for j in range(N):
            num = (i+j)%3
            color = comb[num]
            temp += D[C[i][j]-1][color]
    if temp < answer:
        answer = temp

print(answer)
# 15


Fixed submission:
import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, C = lr()
D = np.array([lr() for _ in range(C)])

grid = [lr() for _ in range(N)]
three = [[0] * C for _ in range(3)]
for i in range(N):
    for j in range(N):
        remain = (i+j) % 3
        three[remain][grid[i][j]-1] += 1

three = np.array(three)
answer = 10 ** 10
for x, y, z in itertools.permutations(range(C), 3):
    # three[0]をxの色にする
    result = 0
    for i in range(3):
        s = [x, y, z][i]
        result += (three[i] * D[:, s]).sum()
    if result < answer:
        answer = result

print(answer)
# 35
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
bit_list = []
for i in range(20):
    l = []
    for j in range(N):
        l.append(A[j]>>i & 1)
    bit_list.append(l)

answer = N
for l, r in itertools.combinations(range(N), 2):
    for i in range(20):
        if sum(bit_list[i][l:r+1]) > 1:
            break
    else:
        answer += 1

print(answer)
# 54

Fixed submission:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()

cur = A[0]
l = 0
answer = 1 #一番左の１つの数字
for i in range(1, N):
    x = A[i]
    while cur^x != cur + x:
        cur -= A[l]
        l += 1
    answer += i - l + 1
    cur += x

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] != 0:
    print(-1)
    exit()
answer = 0
dp = [0 for _ in range(N)]
for i in range(len(A)-1, -1, -1):
    if A[i] == 0:
        continue
    add = 0
    j = i - 1
    k = A[i] - 1
    while j >= 0:
        if A[j] == k or dp[j] == k:
            add = i - j
            break
        elif A[j] > k:
            dp[j] = k
            j -= 1
            k -= 1
        else:
            print(-1)
            exit()
    answer += add
print(answer)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)] + [0], dtype='int64')

x = (A[:-1][A[:-1] >= A[1:]]).sum()

if A[0] != 0:
    x = -1
if (A[1:] >= A[:-1] + 2).any():
    x = -1

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] != 0:
    print(-1)
    exit()
answer = 0
dp = [0 for _ in range(N)]
for i in range(len(A)-1, -1, -1):
    if A[i] == 0:
        continue
    add = A[i] - dp[i]
    j = i - 1
    k = A[i] - 1
    while j >= 0:
        if A[j] == k or dp[j] == k:
            add = i - j
            break
        elif A[j] > k:
            dp[j] = k
            j -= 1
            k -= 1
        else:
            print(-1)
            exit()
    answer += add
print(answer)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)] + [0], dtype='int64')

x = (A[:-1][A[:-1] >= A[1:]]).sum()

if A[0] != 0:
    x = -1
if (A[1:] >= A[:-1] + 2).any():
    x = -1

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] != 0:
    print(-1)
    exit()
answer = 0
dp = [0 for _ in range(N)]
for i in range(len(A)-1, -1, -1):
    if A[i] == 0:
        continue
    add = A[i] - dp[i]
    j = i - 1
    k = A[i] - 1
    while j >= 0:
        if A[j] == k or dp[j] == k:
            add = i - j
            break
        elif A[j] > k:
            dp[j] = k
            if j > 0:
                j -= 1
                k -= 1
            else:
                
                print(-1)
                exit()
        else:
            
            print(-1)
            exit()
    answer += add
    
print(answer)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)] + [0], dtype='int64')

x = (A[:-1][A[:-1] >= A[1:]]).sum()

if A[0] != 0:
    x = -1
if (A[1:] >= A[:-1] + 2).any():
    x = -1

print(x)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
K = ir()
cand = [set() for _ in range(26)]
length = len(S)
for i in range(length):
    index = ord(S[i]) - ord('a')
    for j in range(i+1, length+1):
        cand[index].add(S[i:j])

x = 0
while len(cand[x]) < K:
    K -= len(cand[x])
    x += 1

y = sorted(list(cand[x]))
answer = y[K-1]
print(answer)


Fixed submission:
S = list(input())
K = int(input())
st = set()
for i in range(len(S)):
    for j in range(6):
        st.add(''.join(S[i:i+j]))

st_list = sorted(list(st))
if '' in st_list:
    st_list.remove('')
print(st_list[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
K = ir()
cand = set()
length = len(S)
for i in range(length):
    for j in range(i+1, length+1):
        cand.add(S[i:j])

cand = sorted(list(cand))
answer = cand[K-1]
print(answer)


Fixed submission:
S = list(input())
K = int(input())
st = set()
for i in range(len(S)):
    for j in range(6):
        st.add(''.join(S[i:i+j]))

st_list = sorted(list(st))
if '' in st_list:
    st_list.remove('')
print(st_list[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 重なるところに注意
A, B, K = lr()
answer = [x for x in range(A, B+1) if x < A+K or x > B-K]
print('\n'.join(map(str, answer)))

Fixed submission:
A, B, K = map(int, input().split())
K = min(K, B - A + 1)
print(*sorted(set([i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)])), sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 重なるところに注意
A, B, K = lr()
answer = [x for x in range(A, B+1) if x < A+K or x > B-K]
print('\n'.join(map(str, answer)))

Fixed submission:
A, B, K = map(int, input().split())
K = min(K, B - A + 1)
print(*sorted(set([i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)])), sep='\n')

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
l = list(range(A, B+1))
print(*sorted(set(l[:K] + l[-K:])), sep='\n')


Fixed submission:
A, B, K = map(int, input().split())
K = min(K, B - A + 1)
print(*sorted(set([i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)])), sep='\n')

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
l = list(range(A, B+1))
print(*sorted(set(l[:K] + l[-K:])), sep='\n')

Fixed submission:
A, B, K = map(int, input().split())
K = min(K, B - A + 1)
print(*sorted(set([i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)])), sep='\n')
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 10 for _ in range(5)] + [['#'] * 10 for _ in range(5)]
for i in range(B-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[9-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]
for i in range(B-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[99-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56

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

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 10 for _ in range(5)] + [['#'] * 10 for _ in range(5)]
for i in range(B-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 5)
    row *= 2
    column *= 2
    grid[9-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]
for i in range(B-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[99-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, D = lr()
A = [lr() for _ in range(H)]
Q = ir()
grid = [None] * (H*W + 1) # 1-indexed
for i in range(H):
    for j in range(W):
        grid[A[i][j]] = (i, j)

next_D = [0] * (H*W + 1)
for i in range(1, H*W + 1 - D):
    next_D[i] = abs(grid[i+D][0] - grid[i][0]) + abs(grid[i+D][1] - grid[i][1])

for i in range(Q):
    l, r = lr()
    answer = sum(next_D[l:r:D])
    print(answer)

# 49

Fixed submission:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, D = lr()
A = [lr() for _ in range(H)]
Q = ir()
grid = [None] * (H*W + 1) # 1-indexed
for i in range(H):
    for j in range(W):
        grid[A[i][j]] = (i, j)

next_D = [0] * (H*W + 1)
for i in range(1+D, H*W + 1):
    next_D[i] = abs(grid[i][0] - grid[i-D][0]) + abs(grid[i][1] - grid[i-D][1])
    next_D[i] += next_D[i-D]

for i in range(Q):
    l, r = lr()
    answer = next_D[r] - next_D[l]
    print(answer)

# 49

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, D = lr()
A = [lr() for _ in range(H)]
Q = ir()
grid = [None] * (H*W + 1) # 1-indexed
for i in range(H):
    for j in range(W):
        grid[A[i][j]] = (i, j)

next_D = [0] * (H*W + 1)
for i in range(1, H*W + 1 - D):
    next_D[i] = abs(grid[i+D][0] - grid[i][0]) + abs(grid[i+D][1] - grid[i][1])

for i in range(Q):
    l, r = lr()
    answer = sum(next_D[l:r:D])
    print(answer)

# 49

Fixed submission:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, D = lr()
A = [lr() for _ in range(H)]
Q = ir()
grid = [None] * (H*W + 1) # 1-indexed
for i in range(H):
    for j in range(W):
        grid[A[i][j]] = (i, j)

next_D = [0] * (H*W + 1)
for i in range(1+D, H*W + 1):
    next_D[i] = abs(grid[i][0] - grid[i-D][0]) + abs(grid[i][1] - grid[i-D][1])
    next_D[i] += next_D[i-D]

for i in range(Q):
    l, r = lr()
    answer = next_D[r] - next_D[l]
    print(answer)

# 49
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=int(input())
print('Yes' if n%500<==a else 'No')

Fixed submission:
n=int(input())
a=int(input())
print('Yes' if n%500<=a else 'No')
Buggy python submission (verdict: Runtime Error):
print('Even' if int(input())*int(input())%2==0 else 'Odd')

Fixed submission:
a,b=map(int,input().split())
print('Even' if a*b%2==0 else 'Odd')
Buggy python submission (verdict: Runtime Error):
N, H = map(int, input().split())
sword_list = [list(map(int, input().split())) for i in range(N)]
a_list = [i[0] for i in sword_list]
b_list = [i[1] for i in sword_list]
b_list.sort()
a_max = max(a_list)
index1 = 0
# Aの攻撃がBのいくつかの攻撃より強い場合、どの場所のBかを知っておく
for i in range(0, len(b_list)):
    if b_list[i] <= a_max and b_list[i + 1] > a_max:
        index1 = i + 1
ans = 0
# 全てBの攻撃で倒す場合    
if H - sum(b_list[index1:]) <= 0:
    count = 0
    for j in range(N - 1, -1, -1):
        count += b_list[j]   
        if count >= H:          
            ans = N - j
            break
# Aの攻撃を使う    
else:   
    ans = ((H - sum(b_list[index1:])) + a_max - 1) // a_max + N - index1

print(ans)

Fixed submission:
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
amax = max(A)
B = list(filter(lambda x: x > amax, B))
B.sort()
ans = 0
while H > 0:
    if B:
        H -= B.pop()
    else:
        ans += math.ceil(H / amax)
        break
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
print(sum(int(input())))

Fixed submission:
print(sum(map(int,input())))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(l) for l in input().split()]

count = 0
while True:
    for i in range(N):
        if A[i]/2** k % 2 !=0:
            break
    else:
        count += 1    
        continue
    break

print(count)

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

min_a = min(a_list)
count = 0
while min_a % 2 == 0:
    min_a /= 2
    count += 1
#print(count)
for a in a_list:
    if a % 2 ** count != 0:
        a_count = 0
        while a % 2 == 0:
            a /= 2
            a_count += 1
        count = a_count

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right

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

answer = 0
for b in B:
    ai = bisect_left(A, b)
    ci = bisect_right(C, b)
    answer += len(A[:ai]) * len(C[ci:])
print(answer)


Fixed submission:
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

answer = 0
for b in B:
    ai = bisect.bisect_left(A, b)
    ci = bisect.bisect_right(C, b)
    answer += ai * (N - ci)

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):


import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

answer = 0
for a in A:
    bi = bisect.bisect_right(B, a)
    for i in range(bi, N):
        ci = bisect.bisect_right(C, B[i])
        answer += N - ci

print(answer)

Fixed submission:
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

answer = 0
for b in B:
    ai = bisect.bisect_left(A, b)
    ci = bisect.bisect_right(C, b)
    answer += ai * (N - ci)

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
S = input()

answer = 0

def F(s):
    global answer
    if len(s) <= 1:
        return
    if s[0] == 'x':
        if s[-1] == 'x':
            F(s[1:-1])
        else:
            answer += 1
            F(s[1:])
    else:
        if s[-1] == 'x':
            answer += 1
            F(s[:-1])
        elif s[0] == s[-1]:
            F(s[1:-1])
        else:
            print(-1)
            exit()

F(S)
print(answer)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
S = input()

answer = 0
left = 0
right = len(S) - 1
while left < right:
    if S[left] == S[right]:
        left += 1
        right -= 1
    elif S[left] == 'x':
        left += 1
        answer += 1
    elif S[right] == 'x':
        right -= 1
        answer += 1
    else:
        print(-1)
        exit()
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input()

answer = 0

def F(s):
    global answer
    if len(s) <= 1:
        return
    if s[0] == 'x':
        if s[-1] == 'x':
            F(s[1:-1])
        else:
            answer += 1
            F(s[1:])
    else:
        if s[-1] == 'x':
            answer += 1
            F(s[:-1])
        elif s[0] == s[-1]:
            F(s[1:-1])
        else:
            print(-1)
            exit()

F(S)
print(answer)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
S = input()

answer = 0
left = 0
right = len(S) - 1
while left < right:
    if S[left] == S[right]:
        left += 1
        right -= 1
    elif S[left] == 'x':
        left += 1
        answer += 1
    elif S[right] == 'x':
        right -= 1
        answer += 1
    else:
        print(-1)
        exit()
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for i, j in itertools.permutations(list(range(N)), repeat=2):
    xleft = XY[i][0]
    xright = XY[j][0]
    if xright < xleft: xleft, xright = xright, xleft
    candidate = [(x, y) for x, y in XY if xleft <= x <= xright]
    if len(candidate) < K:
        continue
    candidate.sort(key=lambda z: z[1])
    for s in range(len(candidate) - K + 1):
        yup = candidate[s+K-1][1]
        ylow = candidate[s][1]
    area = (xright - xleft) * (yup - ylow)
    if area < answer:
        answer = area

print(answer)
# 31


Fixed submission:
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
XY = [lr() for _ in range(N)]
XY.sort()
answer = float('inf')
# 端の4点、まずはx軸の2点を選ぶ
for left,right in itertools.combinations(range(N),2):
  width = XY[right][0] - XY[left][0]
  pts = sorted(XY[left:right+1], key = lambda xy: xy[1])
  for D in range(len(pts)):
    if D + K - 1 >= len(pts):
      break
    y_max = pts[D+K-1][1]
    y_min = pts[D][1]
    area = (y_max - y_min) * width
    if area < answer:
      answer = area
    
print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int,input().split())

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

graph = [[] for _ in range(N)]
for a,b in AB:
    graph[a−1].append(b-1)
    graph[b-1].append(a-1)

# 二部グラフかどうかの判定
color = [None] * N
color[0] = 0
q = [0]
while q:
    x = q.pop()
    for y in graph[x]:
        if color[y] is None:
            color[y] = 1 - color[x]
            q.append(y)

# 二部グラフかどうか
bg = all(color[a] != color[b] for a, b in AB)

if bg:
    # 完全二部グラフにする
    x = sum(color)
    y = N - x
    answer = x*y - M
else:
    # 完全グラフにする(奇数長のパスがある場合は必ず2ずつ減らしていけば長さが3になる)
    answer = N*(N-1)//2 - M

print(answer)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
graph = [[] for _ in range(N)]

for a, b in AB:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

# 二部グラフかどうかの判定
color = [None] * N
color[0] = 0
q = [0]
while q:
    x = q.pop()
    for y in graph[x]:
        if color[y] is None:
            color[y] = 1 - color[x]
            q.append(y)

# 二部グラフかどうか
is_bg = all(color[a-1] != color[b-1] for a, b in AB)

if is_bg:
    # 完全二部グラフにする
    x = sum(color)
    y = N - x
    answer = x*y - M
else:
    # 完全グラフにする(奇数長のパスがある場合は必ず2ずつ減らしていけば長さが3になる)
    answer = N*(N-1)//2 - M

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

S = set(A)
S2 = set(A)
for s in S:
    if A.count(s)%2 == 0:
        S2.remove(s)
print(len(S2))


Fixed submission:
N = int(input())
S = set()
for i in range(N):
    S^={input()}
print(len(S))
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
A = np.array(rl())
answer = 0
c = np.bincount(A)

for i in range(1, len(c)):
    result = c[i-1] + c[i] + c[i+1]
    if result > answer:
        answer = result

print(answer)
# 32

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
A = np.array(rl())
c = np.bincount(A)
answer = c[0]

for i in range(1, len(c)-1):
    result = c[i-1] + c[i] + c[i+1]
    if result > answer:
        answer = result

print(answer)
# 32
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A = list(rs())
answer = 1
for i in range(len(A)-1):
    for j in range(i, len(A)):
        if A[i] != A[j]:
            answer += 1

print(answer)
# 53

Fixed submission:
import sys
#import numpy as np
from collections import Counter

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A = list(rs())
answer = 1
c = Counter(A)
for i in range(len(A)):
    answer += len(A) - i - c[A[i]]
    c[A[i]] -= 1

print(answer)
# 53
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())

print('ABC' + N)


Fixed submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())

print('ABC' + str(N))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
edges = {}
flag = 'IMPOSSIBLE'
for a, b in AB:
    if a in edges:
        edges[a].append(b)
    else:
        edges[a] = [b]
for i in edges[1]:
    if N in edges[i]:
        flag = 'POSSIBLE'
        break

print(flag)

Fixed submission:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
edges = {}
flag = 'IMPOSSIBLE'
for a, b in AB:
    if a in edges:
        edges[a].append(b)
    else:
        edges[a] = [b]
for i in edges[1]:
    if i not in edges:
        continue
    if N in edges[i]:
        flag = 'POSSIBLE'
        break

print(flag)