Buggy python submission (verdict: Time Limit Exceeded):
import sys

H, W, M = map(int, input().split())
h = [0] * M
w = [0] * M

h_bom = [0] * H
w_bom = [0] * W

for i in range(M):
    h[i], w[i] = map(int, input().split())

    h_bom[h[i] - 1] += 1
    w_bom[w[i] - 1] += 1

h_max = max(h_bom)
w_max = max(w_bom)

h_list = []
w_list = []

for i in range(len(h_bom)):
    if h_bom[i] == h_max:
        h_list.append(i)

for i in range(len(w_bom)):
    if w_bom[i] == w_max:
        w_list.append(i)

for y in h_list:
    for x in w_list:
        flag = True
        for i in range(M):
            if y == (h[i] - 1) and x == (w[i] - 1):
                flag = False

        if flag:
            print(h_max + w_max)
            sys.exit()

print(h_max + w_max - 1)


Fixed submission:
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
from collections import defaultdict

H, W,M = map(int, input().split())
h = [0] * M
w = [0] * M
mine = [[0] * W for i in range(H)]
for i in range(M):
    x, y = map(int, input().split())
    w[x-1] += 1
    h[y-1] += 1
    mine[x-1][y-1] = 1

w_max = max(w)
h_max = max(h)

w_list = []
h_list = []
for i in range(M):
    if w[i] == w_max:
        w_list.append(i)
    if h[i] == h_max:
        h_list.append(i)

for y in h_list:
    for x in w_list:
        if mine[y][x] == 0:
            print(w_max + h_max)
            sys.exit()

print(w_max+h_max-1)

Fixed submission:
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
from collections import defaultdict

H, W,M = map(int, input().split())
h = [0] * M
w = [0] * M
for i in range(M):
    x, y = map(int, input().split())
    w[x-1] += 1
    h[y-1] += 1

w_max = max(w)
h_max = max(h)

print(w_max+h_max-1)

Fixed submission:
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
from collections import defaultdict

H, W,M = map(int, input().split())
h = [0] * M
w = [0] * M
mine = 
for i in range(M):
    x, y = map(int, input().split())
    w[x-1] += 1
    h[y-1] += 1

w_max = max(w)
h_max = max(h)

print(w_max+h_max-1)

Fixed submission:
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)