Problem p02580 (python)

Fixed submission:
import numpy as np
import numba
import sys
from numba import njit, b1, i4, i8, f8

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


@njit((i8, i8, i8[:]), cache=True)
def main(Height, Width, XY):
    UP = 300010
    row = np.zeros(UP, np.int64)
    col = np.zeros(UP, np.int64)
    
    for i in range(0, len(XY), 2):
        x, y = XY[i:i + 2] - 1
        row[x] += 1
        col[y] += 1
    
    row_max = row.max()
    col_max = col.max()

    judge = np.sum(row == row_max) * np.sum(col == col_max)

    for i in range(0, len(XY), 2):
        x, y = XY[i:i + 2] - 1
        
        if (row[x] == row_max and col[y] == col_max):
            judge -= 1
    
    summ = row_max + col_max
    
    return (summ if judge else summ - 1)


Height, Width, M_ko = map(int, readline().split())
XY = np.array(read().split(), np.int64)

ans = main(Height, Width, XY)
print(ans)

Buggy submission (verdict: Runtime Error):
from numba import njit

@njit
def main():
    import collections
 
    H, W, M_ko = map(int, input().split())
 
    zahyou = [[0 for i in range(W)] for j in range(H)]
    zahyou_H = [0 for i in range(H)]
    zahyou_W = [0 for i in range(W)]
 
    for i in range(M_ko):
        height, width = map(int, input().split())
 
        zahyou[height - 1][width - 1] = 1
        
        zahyou_H[height - 1] += 1
        zahyou_W[width - 1] += 1
 
    CTR_H = collections.Counter(zahyou_H)
    CTR_W = collections.Counter(zahyou_W)
 
    max_h = max(zahyou_H)
    max_w = max(zahyou_W)
 
    len_h = CTR_H[max_h]
    len_w = CTR_W[max_w]
 
    index_h = [i for i, x in enumerate(zahyou_H) if x == max_h]
    index_w = [i for i, x in enumerate(zahyou_W) if x == max_w]
 
 
    maxi = max_h + max_w
    FLAG = False
 
 
    if (len_h == 1 and len_w == 1):    
        maxi -= zahyou[index_h[0]][index_w[0]]
 
 
    else:
        for i in range(len_h):        
            for j in range(len_w):
                val = zahyou[index_h[i]][index_w[j]]
                
                if (val == 0):
                    FLAG = True
                    break
        
        if (not FLAG):
            maxi -= 1
 
    print(maxi)
 
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import collections
    import numpy as np

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

    zahyou = [[0 for i in range(W)] for j in range(H)]
    zahyou_H = [0 for i in range(H)]
    zahyou_W = [0 for i in range(W)]

    np_zahyou = np.array(zahyou)
    np_zahyou_H = np.array(zahyou_H)
    np_zahyou_W = np.array(zahyou_W)
    

    for i in range(M_ko):
        height, width = map(int, input().split())

        zahyou[height - 1][width - 1] = 1
        
        zahyou_H[height - 1] += 1
        zahyou_W[width - 1] += 1

    CTR_H = collections.Counter(zahyou_H)
    CTR_W = collections.Counter(zahyou_W)

    max_h = max(zahyou_H)
    max_w = max(zahyou_W)

    len_h = CTR_H[max_h]
    len_w = CTR_W[max_w]

    index_h = [i for i, x in enumerate(zahyou_H) if x == max_h]
    index_w = [i for i, x in enumerate(zahyou_W) if x == max_w]


    maxi = max_h + max_w
    FLAG = False


    if (len_h == 1 and len_w == 1):    
        maxi -= zahyou[index_h[0]][index_w[0]]


    else:
        for i in range(len_h):        
            for j in range(len_w):
                val = zahyou[index_h[i]][index_w[j]]
                
                if (val == 0):
                    FLAG = True
                    break
        
        if (not FLAG):
            maxi -= 1

    print(maxi)


if __name__ == '__main__':
    main()