Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
for h in range(H):
    if hsum[h] == hmax:
        for w in range(W):
            if wsum[w] == wmax and (h,w) not in bombs:
                cross_w_zero = True
                break
    if cross_w_zero:
        break
if cross_w_zero:
    print(hmax + wmax)
else:
    print(hmax + wmax - 1)

Fixed submission:
# from sys import stdin
# input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
hargmax = sum(1 for x in hsum if x == hmax)
wargmax = sum(1 for x in wsum if x == wmax)
cnt = sum(1 for h,w in bombs if hsum[h] == hmax and wsum[w] == wmax)
if hargmax * wargmax == cnt:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)

Buggy python submission (verdict: Time Limit Exceeded):
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
for h in range(H):
    if hsum[h] == hmax:
        for w in range(W):
            if wsum[w] == wmax and (h,w) not in bombs:
                cross_w_zero = True
                break
    if cross_w_zero:
        break
if cross_w_zero:
    print(hmax + wmax)
else:
    print(hmax + wmax - 1)

Fixed submission:
# from sys import stdin
# input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
hargmax = sum(1 for x in hsum if x == hmax)
wargmax = sum(1 for x in wsum if x == wmax)
cnt = sum(1 for h,w in bombs if hsum[h] == hmax and wsum[w] == wmax)
if hargmax * wargmax == cnt:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)

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

(H,W,M) = map(int, input().split())
# hsum = [0]*H
# wsum = [0]*W
grid = np.zeros((H,W), dtype='int')
for _ in range(M):
    h,w = map(int, input().split())
    grid[h-1][w-1] = 1

row = grid.sum(axis=0)
col = grid.sum(axis=1)

cm = col.max()
rm = row.max()
if grid[col==cm][:, row==rm].min() == 0:
    print(cm+rm)
else:
    print(cm+rm-1)

Fixed submission:
# from sys import stdin
# input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
hargmax = sum(1 for x in hsum if x == hmax)
wargmax = sum(1 for x in wsum if x == wmax)
cnt = sum(1 for h,w in bombs if hsum[h] == hmax and wsum[w] == wmax)
if hargmax * wargmax == cnt:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)

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

(H,W,M) = map(int, input().split())
# hsum = [0]*H
# wsum = [0]*W
grid = np.zeros((H,W), dtype='int')
for _ in range(M):
    h,w = map(int, input().split())
    grid[h-1][w-1] = 1

row = grid.sum(axis=0)
col = grid.sum(axis=1)

cm = col.max()
rm = row.max()
if grid[col == cm, row == rm].min() == 0:
    print(cm+rm)
else:
    print(cm+rm-1)

Fixed submission:
# from sys import stdin
# input = stdin.readline
(H,W,M) = map(int, input().split())
hsum = [0]*H
wsum = [0]*W
bombs = set()
for _ in range(M):
    h,w = map(int, input().split())
    hsum[h-1] += 1
    wsum[w-1] += 1
    bombs.add((h-1,w-1))

hmax = max(hsum)
wmax = max(wsum)

cross_w_zero = False
hargmax = sum(1 for x in hsum if x == hmax)
wargmax = sum(1 for x in wsum if x == wmax)
cnt = sum(1 for h,w in bombs if hsum[h] == hmax and wsum[w] == wmax)
if hargmax * wargmax == cnt:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)