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

h = [0] * H
w = [0] * W

hw = []

for _ in range(H):
    hw.append([0] * W)

for _ in range(M):
    a,b = list(map(int,input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    hw[a - 1][b - 1] += 1
    
hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        if hw[x][y] == 0:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)



Fixed submission:

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

h = [0] * H
w = [0] * W

hw = {}

for _ in range(M):
    a, b = list(map(int, input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    temp = "x" + str(a - 1) + "y" + str(b - 1)
    hw[temp] = 1

hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        temp = "x" + str(x) + "y" + str(y)
        if temp not in hw:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)

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

h = [0] * H
w = [0] * W

hw = []

for _ in range(H):
    hw.append([0] * W)

for _ in range(M):
    a,b = list(map(int,input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    hw[a - 1][b - 1] += 1
    
hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        if hw[x][y] == 0:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)



Fixed submission:

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

h = [0] * H
w = [0] * W

hw = {}

for _ in range(M):
    a, b = list(map(int, input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    temp = "x" + str(a - 1) + "y" + str(b - 1)
    hw[temp] = 1

hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        temp = "x" + str(x) + "y" + str(y)
        if temp not in hw:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)

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

h = [0] * H
w = [0] * W

hw = []

for _ in range(M):
    a,b = list(map(int,input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    hw.append([a,b])

hp = [i for i, v in enumerate(h) if v == max(h)]
wp = [i for i, v in enumerate(w) if v == max(w)]

for x in hp:
    for y in wp:
        if [x+1,y+1] in hw:
            pass
        else:
            print(max(h) + max(w))
            exit()
else:
    print(max(h) + max(w) - 1)


Fixed submission:

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

h = [0] * H
w = [0] * W

hw = {}

for _ in range(M):
    a, b = list(map(int, input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    temp = "x" + str(a - 1) + "y" + str(b - 1)
    hw[temp] = 1

hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        temp = "x" + str(x) + "y" + str(y)
        if temp not in hw:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)

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

h = [0] * H
w = [0] * W

hw = []

for _ in range(M):
    a,b = list(map(int,input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    hw.append([a,b])

hp = [i for i, v in enumerate(h) if v == max(h)]
wp = [i for i, v in enumerate(w) if v == max(w)]

for x in hp:
    for y in wp:
        if [x+1,y+1] in hw:
            pass
        else:
            print(max(h) + max(w))
            exit()
else:
    print(max(h) + max(w) - 1)


Fixed submission:

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

h = [0] * H
w = [0] * W

hw = {}

for _ in range(M):
    a, b = list(map(int, input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    temp = "x" + str(a - 1) + "y" + str(b - 1)
    hw[temp] = 1

hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        temp = "x" + str(x) + "y" + str(y)
        if temp not in hw:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)