Buggy python submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
Hb = [0] * H
Wb = [0] * W
B = [[0] * W for _ in range(H)]
for _ in range(M):
    h, w = map(int, input().split())
    Hb[h - 1] += 1
    Wb[w - 1] += 1
    B[h - 1][w - 1] = 1
HB = max(Hb)
WB = max(Wb)
BB = [0] * W
for i in range(H):
    if Hb[i] == HB:
        for j in range(W):
            if B[i][j] == 1:
                BB[j] = 1
for i in range(W):
    if Wb[i] == WB:
        if BB[i] == 0:
            print(HB + WB)
            sys.exit()
print(HB + WB - 1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
Hb = [0] * H
Wb = [0] * W
B = set()
for _ in range(M):
    h, w = map(int, input().split())
    Hb[h - 1] += 1
    Wb[w - 1] += 1
    B.add((h - 1, w - 1))
HB = max(Hb)
WB = max(Wb)
x = set()
y = set()
for i in range(H):
    if Hb[i] == HB:
        y.add(i)
for i in range(W):
    if Wb[i] == WB:
        x.add(i)
for i in y:
    for j in x:
        if (i, j) not in B:
            print(HB + WB)
            sys.exit()
print(HB + WB - 1)

Buggy python submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
Hb = [0] * H
Wb = [0] * W
B = [[0] * W for _ in range(H)]
for _ in range(M):
    h, w = map(int, input().split())
    Hb[h - 1] += 1
    Wb[w - 1] += 1
    B[h - 1][w - 1] = 1
HB = max(Hb)
WB = max(Wb)
print(HB + WB)
BB = [0] * W
for i in range(H):
    if Hb[i] == HB:
        for j in range(W):
            if B[i][j] == 1:
                BB[j] = 1
for i in range(W):
    if Wb[i] == WB:
        if BB[i] == 0:
            print(HB + WB)
            sys.exit()
print(HB + WB - 1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
Hb = [0] * H
Wb = [0] * W
B = set()
for _ in range(M):
    h, w = map(int, input().split())
    Hb[h - 1] += 1
    Wb[w - 1] += 1
    B.add((h - 1, w - 1))
HB = max(Hb)
WB = max(Wb)
x = set()
y = set()
for i in range(H):
    if Hb[i] == HB:
        y.add(i)
for i in range(W):
    if Wb[i] == WB:
        x.add(i)
for i in y:
    for j in x:
        if (i, j) not in B:
            print(HB + WB)
            sys.exit()
print(HB + WB - 1)

Buggy python submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
Hb = [0] * H
Wb = [0] * W
B = [[0] * W for _ in range(H)]
for _ in range(M):
    h, w = map(int, input().split())
    Hb[h - 1] += 1
    Wb[w - 1] += 1
    B[h - 1][w - 1] = 1
HB = max(Hb)
WB = max(Wb)
x = set()
y = set()
for i in range(H):
    if Hb[i] == HB:
        y.add(i)
for i in range(W):
    if Wb[i] == WB:
        x.add(i)
for i in y:
    for j in x:
        if B[i][j] == 0:
            print(HB + WB)
            sys.exit()
print(HB + WB - 1)

Fixed submission:
import sys
H, W, M = map(int, input().split())
Hb = [0] * H
Wb = [0] * W
B = set()
for _ in range(M):
    h, w = map(int, input().split())
    Hb[h - 1] += 1
    Wb[w - 1] += 1
    B.add((h - 1, w - 1))
HB = max(Hb)
WB = max(Wb)
x = set()
y = set()
for i in range(H):
    if Hb[i] == HB:
        y.add(i)
for i in range(W):
    if Wb[i] == WB:
        x.add(i)
for i in y:
    for j in x:
        if (i, j) not in B:
            print(HB + WB)
            sys.exit()
print(HB + WB - 1)