Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

h_max = 0
w_max = 0
for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1
    h_max = max(h_max, n_target_h[h - 1])
    w_max = max(w_max, n_target_w[w - 1])

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

ans = h_max + w_max - 1
for h in bomb_h:
    for w in bomb_w:
        if not (h, w) in targets:
            ans = h_max + w_max
            break
    else:
        continue
    break

print(ans)

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

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

count = len(bomb_h) * len(bomb_w)
for target in targets:
    if (n_target_h[target[0] - 1] == h_max) and (n_target_w[target[1] - 1] == w_max):
        count -= 1

if count > 0:
    ans = h_max + w_max
else:
    ans = h_max + w_max - 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1
    h_max = max(h_max, n_target_h[h - 1])
    w_max = max(w_max, n_target_w[w - 1])

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

ans = h_max + w_max - 1
for h in bomb_h:
    for w in bomb_w:
        if not (h, w) in targets:
            ans = h_max + w_max
            break
    else:
        continue
    break

print(ans)

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

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

count = len(bomb_h) * len(bomb_w)
for target in targets:
    if (n_target_h[target[0] - 1] == h_max) and (n_target_w[target[1] - 1] == w_max):
        count -= 1

if count > 0:
    ans = h_max + w_max
else:
    ans = h_max + w_max - 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())

targets = [[0] * W for _ in range(H)]
n_target_h = [0] * H
n_target_w = [0] * W
h_max = 0
w_max = 0

for i in range(M):
    h, w = map(int, input().split())
    targets[h - 1][w - 1] = 1
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1
    h_max = max(h_max, n_target_h[h - 1])
    w_max = max(w_max, n_target_w[w - 1])

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

ans = h_max + w_max - 1
for h in bomb_h:
    for w in bomb_w:
        if targets[h - 1][w - 1] == 0:
            ans = h_max + w_max
            break
    else:
        continue
    break

print(ans)

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

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

count = len(bomb_h) * len(bomb_w)
for target in targets:
    if (n_target_h[target[0] - 1] == h_max) and (n_target_w[target[1] - 1] == w_max):
        count -= 1

if count > 0:
    ans = h_max + w_max
else:
    ans = h_max + w_max - 1

print(ans)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())

targets = [[0] * W for _ in range(H)]
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets[h - 1][w - 1] = 1
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

ans = h_max + w_max - 1
for h in bomb_h:
    for w in bomb_w:
        if targets[h - 1][w - 1] == 0:
            ans = h_max + w_max
            break
    else:
        continue
    break

print(ans)

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

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

count = len(bomb_h) * len(bomb_w)
for target in targets:
    if (n_target_h[target[0] - 1] == h_max) and (n_target_w[target[1] - 1] == w_max):
        count -= 1

if count > 0:
    ans = h_max + w_max
else:
    ans = h_max + w_max - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

ans = h_max + w_max - 1
for h in bomb_h:
    for w in bomb_w:
        if not (h, w) in targets:
            ans = h_max + w_max
            break
    else:
        continue
    break

print(ans)

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

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

count = len(bomb_h) * len(bomb_w)
for target in targets:
    if (n_target_h[target[0] - 1] == h_max) and (n_target_w[target[1] - 1] == w_max):
        count -= 1

if count > 0:
    ans = h_max + w_max
else:
    ans = h_max + w_max - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

ans = 0
for h in bomb_h:
    for w in bomb_w:
        if (h, w) in targets:
            ans = max(h_max + w_max - 1, ans)
        else:
            ans = h_max + w_max

print(ans)

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

targets = []
n_target_h = [0] * H
n_target_w = [0] * W

for i in range(M):
    h, w = map(int, input().split())
    targets.append((h, w))
    n_target_h[h - 1] += 1
    n_target_w[w - 1] += 1

h_max = max(n_target_h)
w_max = max(n_target_w)

bomb_h = [i + 1 for i, h in enumerate(n_target_h) if h == h_max]
bomb_w = [i + 1 for i, w in enumerate(n_target_w) if w == w_max]

count = len(bomb_h) * len(bomb_w)
for target in targets:
    if (n_target_h[target[0] - 1] == h_max) and (n_target_w[target[1] - 1] == w_max):
        count -= 1

if count > 0:
    ans = h_max + w_max
else:
    ans = h_max + w_max - 1

print(ans)