Buggy python submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
bombmat = [[0]*(W+1) for _ in range(H+1)]
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(lambda x: int(x)-1, input().split())
    bombmat[h][w] = 1
    bombmat[H][w] += 1
    bombmat[h][W] += 1
    
    bomb_row[i] = h
    bomb_col[i] = w

row_H = bombmat[H]
maxcol = 0
for col in range(W):
    maxcol = max(maxcol, row_H[col])

maxcollist = [False]*W
for col in range(W):
    if row_H[col] == maxcol:
        maxcollist[col] = True

maxrow = 0
for row in range(H):
    maxrow = max(maxrow, bombmat[row][W])

maxrowlist = [False]*H
for row in range(H):
    if bombmat[row][W] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[i]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)

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

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

sum_row = [0]*H; sum_col = [0]*W
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(int, input().split())
    sum_row[h-1] += 1
    sum_col[w-1] += 1
    
    bomb_row[i] = h-1
    bomb_col[i] = w-1

maxcol = max(sum_col)
maxcollist = [False]*W
for col in range(W):
    if sum_col[col] == maxcol:
        maxcollist[col] = True

maxrow = max(sum_row)
maxrowlist = [False]*H
for row in range(H):
    if sum_row[row] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[i]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)

Buggy python submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
bombmat = [[0]*(W+1) for _ in range(H+1)]
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(lambda x: int(x)-1, input().split())
    bombmat[h][w] = 1
    bombmat[H][w] += 1
    bombmat[h][W] += 1
    
    bomb_row[i] = h
    bomb_col[i] = w

row_H = bombmat[H]
maxcol = 0
for col in range(W):
    maxcol = max(maxcol, row_H[col])

maxcollist = [False]*W
for col in range(W):
    if row_H[col] == maxcol:
        maxcollist[col] = True

maxrow = 0
for row in range(H):
    maxrow = max(maxrow, bombmat[row][W])

maxrowlist = [False]*H
for row in range(H):
    if bombmat[row][W] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[w]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)

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

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

sum_row = [0]*H; sum_col = [0]*W
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(int, input().split())
    sum_row[h-1] += 1
    sum_col[w-1] += 1
    
    bomb_row[i] = h-1
    bomb_col[i] = w-1

maxcol = max(sum_col)
maxcollist = [False]*W
for col in range(W):
    if sum_col[col] == maxcol:
        maxcollist[col] = True

maxrow = max(sum_row)
maxrowlist = [False]*H
for row in range(H):
    if sum_row[row] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[i]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)