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

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

h = np.zeros(H + 1, np.int64)
w = np.zeros(W + 1, np.int64)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

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

h_idx = np.where(h == h_max)[0]
w_idx = np.where(w == w_max)[0]


@njit
def solve(h_max, w_max, boms):
    minus = -1
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus = 0
                break
    return h_max + w_max + max(minus)


print(solve(h_max, w_max, boms))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_idx + minus)

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

h = [0] * (H + 1)
w = [0] * (W + 1)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]


def solve(h_max, w_max, boms):
    minus = []
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus.append(-1)
            else:
                minus.append(0)
    return h_max + w_max + max(minus)


print(solve(h_max, w_max, boms))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

h = [0] * (H + 1)
w = [0] * (W + 1)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]


def solve(h_max, w_max, boms):
    minus = []
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus.append(-1)
            else:
                minus.append(0)
    return h_max + w_max + max(minus)


print(solve(h_max, w_max, boms))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

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

h = np.zeros(H + 1, np.int64)
w = np.zeros(W + 1, np.int64)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

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

h_idx = np.where(h == h_max)[0]
w_idx = np.where(w == w_max)[0]


@njit
def solve(h_max, w_max, boms):
    minus = []
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus.append(-1)
            else:
                minus.append(0)
    return h_max + w_max + max(minus)


print(solve(h_max, w_max, boms))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

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

h = np.zeros(H + 1, np.int64)
w = np.zeros(W + 1, np.int64)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

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

h_idx = np.where(h == h_max)[0]
w_idx = np.where(w == w_max)[0]

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

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

h = defaultdict(int)
w = defaultdict(int)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

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

h_idx = [x for (x, y) in h.items() if y == h_max]
w_idx = [x for (x, y) in w.items() if y == w_max]

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

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

h = defaultdict(int)
w = defaultdict(int)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

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

h_idx = [x for (x, y) in h.items() if y == h_max]
w_idx = [x for (x, y) in w.items() if y == w_max]

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

h = []
w = []
boms = set()
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)
    boms.add((x, y))

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

h = []
w = []
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

boms = set([(x, y) for x, y in zip(h, w)])

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

h = []
w = []
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

boms = set([(x, y) for x, y in zip(h, w)])

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Runtime Error):
from collections import Counter

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

h = []
w = []
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

boms = set([(x, y) for x, y in zip(h, w)])

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)

print(h_max + w_max + max(minus))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

Buggy python submission (verdict: Runtime Error):
from numba import njit

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

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


@njit
def solve(arr):
    ans = 0
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            tmp = max(ans, sum([x == i or y == j for (x, y) in arr]))
            if ans < tmp:
                ans = tmp
    return ans


print(solve(arr))

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)

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

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

ans = 0

for i in range(1, H + 1):
    for j in range(1, W + 1):
        ans = max(ans, sum([x == i or y == j for (x, y) in arr]))

print(ans)

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

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

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)