Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = [0] * M
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g[i] = [h[i],w[i]]

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

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if [i,j] not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Fixed submission:
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = set()
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g.add((h[i],w[i]))

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

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if (i,j) not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = [0] * M
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g[i] = [h[i],w[i]]

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

hi = [i for i in ch.keys() if ch[i] == max(ch.values())]
wi = [i for i in cw.keys() if cw[i] == max(cw.values())]

for i in hi:
    for j in wi:
        if [i,j] not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Fixed submission:
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = set()
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g.add((h[i],w[i]))

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

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if (i,j) not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = [[0] * W for i in range(H)]
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g[h[i]-1][w[i]-1] = 1

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

hi = [i for i in ch.keys() if ch[i] == max(ch.values())]
wi = [i for i in cw.keys() if cw[i] == max(cw.values())]

for i in hi:
    for j in wi:
        if g[i-1][j-1] == 0:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Fixed submission:
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = set()
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g.add((h[i],w[i]))

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

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if (i,j) not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = [[0] * W for i in range(H)]
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g[h[i]-1][w[i]-1] = 1

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

hi = [i for i in ch.keys() if ch[i] == max(ch.values())]
wi = [i for i in cw.keys() if cw[i] == max(cw.values())]

for i in hi:
    for j in wi:
        if g[i-1][j-1] == 0:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Fixed submission:
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = set()
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g.add((h[i],w[i]))

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

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if (i,j) not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = [[0] * M for i in range(M)]
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g[h[i]-1][w[i]-1] = 1

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

hi = [i for i in ch.keys() if ch[i] == max(ch.values())]
wi = [i for i in cw.keys() if cw[i] == max(cw.values())]

for i in hi:
    for j in wi:
        if g[i-1][j-1] == 0:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)

Fixed submission:
from collections import Counter
H, W, M = [int(i) for i in input().split()]
g = set()
h = [0] * M
w = [0] * M
for i in range(M):
    h[i], w[i] = [int(j) for j in input().split()]
    g.add((h[i],w[i]))

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

chm = max(ch.values())
cwm = max(cw.values())
hi = [i for i in ch.keys() if ch[i] == chm]
wi = [i for i in cw.keys() if cw[i] == cwm]

for i in hi:
    for j in wi:
        if (i,j) not in g:
            print(ch[i] + cw[j])
            exit()
print(ch[hi[0]] + cw[wi[0]] - 1)