Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
bom = [[0]*W for _ in range(H)]
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1][w-1] += 1
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

max_ix_row = [i for i, v in enumerate(row) if v == max_row]
max_ix_col = [i for i, v in enumerate(col) if v == max_col]

flag = False
"""
for i in max_ix_row:
    for j in max_ix_col:
        if not bom[i][j]:
            ans += 1
            flag = True
            break
    
    if flag:
        break"""

print(ans)


Fixed submission:
H, W, M = map(int, input().split())
bom = set()
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom.add((h-1, w-1))
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

p, q = [], []

for i in range(H):
    if row[i] == max_row:
        p.append(i)

for j in range(W):
    if col[j] == max_col:
        q.append(j)

flag = False
for i in p:
    for j in q:
        if (i, j) not in bom:
            ans += 1
            flag = True
            break
    if flag:
        break

print(ans)

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

H, W, M = map(int, input().split())
bom = [[0]*W for _ in range(H)]
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1][w-1] += 1
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

max_ix_row = [i for i, v in enumerate(row) if v == max_row]
max_ix_col = [i for i, v in enumerate(col) if v == max_col]

flag = False

for i in max_ix_row:
    for j in max_ix_col:
        if not bom[i][j]:
            ans += 1
            flag = True
            break
    
    if flag:
        break

print(ans)

Fixed submission:
H, W, M = map(int, input().split())
bom = set()
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom.add((h-1, w-1))
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

p, q = [], []

for i in range(H):
    if row[i] == max_row:
        p.append(i)

for j in range(W):
    if col[j] == max_col:
        q.append(j)

flag = False
for i in p:
    for j in q:
        if (i, j) not in bom:
            ans += 1
            flag = True
            break
    if flag:
        break

print(ans)

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

H, W, M = map(int, input().split())
bom = [[0]*W for _ in range(H)]
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1][w-1] += 1
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

max_ix_row = [i for i, v in enumerate(row) if v == max_row]
max_ix_col = [i for i, v in enumerate(col) if v == max_col]

flag = False

for i in max_ix_row:
    for j in max_ix_col:
        if not bom[i][j]:
            ans += 1
            flag = True
            break
    
    if flag:
        break

print(ans)

Fixed submission:
H, W, M = map(int, input().split())
bom = set()
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom.add((h-1, w-1))
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

p, q = [], []

for i in range(H):
    if row[i] == max_row:
        p.append(i)

for j in range(W):
    if col[j] == max_col:
        q.append(j)

flag = False
for i in p:
    for j in q:
        if (i, j) not in bom:
            ans += 1
            flag = True
            break
    if flag:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, W, M = map(int, input().split())
bom = [[0]*W for _ in range(H)]
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1][w-1] += 1
    row[h-1] += 1
    col[w-1] += 1

ans = 0

for i in range(H):
    cnt = row[i]
    r = bom[i]

    tmp = np.array(col) - np.array(r)
    maxi = np.max(tmp)

    ans = max(ans, (cnt + maxi))

print(ans)


Fixed submission:
H, W, M = map(int, input().split())
bom = set()
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom.add((h-1, w-1))
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

p, q = [], []

for i in range(H):
    if row[i] == max_row:
        p.append(i)

for j in range(W):
    if col[j] == max_col:
        q.append(j)

flag = False
for i in p:
    for j in q:
        if (i, j) not in bom:
            ans += 1
            flag = True
            break
    if flag:
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
bom = [[0]*W for _ in range(H)]
# row = [[] for _ in range(H)]
# col = [[] for _ in range(W)]
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom[h-1][w-1] += 1
    # row[h-1].append(w)
    # col[w-1].append(h)
    row[h-1] += 1
    col[w-1] += 1

col_max = max(col)
col_max_ix = [i for i, v in enumerate(col) if v == col_max]
ans = 0

# print('bom: ', bom)
# print('col_max_ix: ', col_max_ix)

for i in range(H):
    r = row[i]
    # print('r: ', r)
    # print('col_max: ', col_max)
    r += col_max
    r -= 1

    for ix in col_max_ix:
        if not bom[i][ix]:
            r += 1
            break
    # print('r: ', r)
    # print()
    ans = max(ans, r)

print(ans)

Fixed submission:
H, W, M = map(int, input().split())
bom = set()
row = [0] * H
col = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    bom.add((h-1, w-1))
    row[h-1] += 1
    col[w-1] += 1

max_row = max(row)
max_col = max(col)
ans = max_row + max_col - 1

p, q = [], []

for i in range(H):
    if row[i] == max_row:
        p.append(i)

for j in range(W):
    if col[j] == max_col:
        q.append(j)

flag = False
for i in p:
    for j in q:
        if (i, j) not in bom:
            ans += 1
            flag = True
            break
    if flag:
        break

print(ans)