Buggy python submission (verdict: Time Limit Exceeded):
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*H
wNum = [0]*W

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h-1]+=1
    wNum[w-1]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(H):
    if(hmax == hNum[i]):
        hMaxList.append(i)
for i in range(W):
    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
for w in wMaxList:
    for h in hMaxList:
        for k in hw:
            if(not([h+1,w+1] in hw)):
                print(ans)
                exit()
print(ans -1)


Fixed submission:
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*H
wNum = [0]*W

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h-1]+=1
    wNum[w-1]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(H):
    if(hmax == hNum[i]):
        hMaxList.append(i)
for i in range(W):
    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
count = 0
for i in hw:
    if(hNum[i[0]-1] == hmax and wNum[i[1]-1] == wmax):
        count += 1
if(hNum.count(hmax) * wNum.count(wmax) == count):
    ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*10
wNum = [0]*10

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h]+=1
    wNum[w]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(10):
    if(hmax == hNum[i]):
        hMaxList.append(i)

    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
for i in range(10):
    if([i,i] in hw and i in hMaxList and i in wMaxList):
        ans -= 1
if(len(hw) < 10 and (hmax ==  1 or  wmax ==  1 )):
    ans += 1
print(ans)


Fixed submission:
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*H
wNum = [0]*W

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h-1]+=1
    wNum[w-1]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(H):
    if(hmax == hNum[i]):
        hMaxList.append(i)
for i in range(W):
    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
count = 0
for i in hw:
    if(hNum[i[0]-1] == hmax and wNum[i[1]-1] == wmax):
        count += 1
if(hNum.count(hmax) * wNum.count(wmax) == count):
    ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*10
wNum = [0]*10

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h]+=1
    wNum[w]+=1
hmax = -1
hMaxList = []
wmax = -1
wMaxList = []
for i in range(10):
    if(hmax <= hNum[i]):
        if(hmax == hNum[i]):
            hMaxList.append(i)
        else:
            hMaxList = [i]
        hmax = hNum[i]

    if(wmax <= wNum[i]):
        if(wmax == wNum[i]):
            wMaxList.append(i)
        else:
            wMaxList = [i]
        wmax = wNum[i]

ans = wmax + hmax
# print(ans)
# for i in range(10):
#     if([i,i] in hw and i in hMaxList and i in wMaxList):
#         ans -= 1
# if(len(hw) < 10 and (hmax ==  1 or  wmax ==  1 )):
#     ans += 1
print(ans)


Fixed submission:
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*H
wNum = [0]*W

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h-1]+=1
    wNum[w-1]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(H):
    if(hmax == hNum[i]):
        hMaxList.append(i)
for i in range(W):
    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
count = 0
for i in hw:
    if(hNum[i[0]-1] == hmax and wNum[i[1]-1] == wmax):
        count += 1
if(hNum.count(hmax) * wNum.count(wmax) == count):
    ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*10
wNum = [0]*10

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h]+=1
    wNum[w]+=1
hmax = -1
hMaxList = []
wmax = -1
wMaxList = []
for i in range(10):
    if(hmax <= hNum[i]):
        if(hmax == hNum[i]):
            hMaxList.append(i)
        else:
            hMaxList = [i]
        hmax = hNum[i]

    if(wmax <= wNum[i]):
        if(wmax == wNum[i]):
            wMaxList.append(i)
        else:
            wMaxList = [i]
        wmax = wNum[i]

ans = wmax + hmax
# print(ans)
for i in range(10):
    if([i,i] in hw and i in hMaxList and i in wMaxList):
        ans -= 1
if(len(hw) < 10 and (hmax ==  1 or  wmax ==  1 )):
    ans += 1
print(ans)


Fixed submission:
H,W,M = [int(x) for x in input().split()]
hw = []
hNum = [0]*H
wNum = [0]*W

for i in range(M):
    h,w = [int(x) for x in input().split()]
    hw.append([h,w])
    hNum[h-1]+=1
    wNum[w-1]+=1

hmax = max(hNum)
hMaxList = []
wmax = max(wNum)
wMaxList = []

for i in range(H):
    if(hmax == hNum[i]):
        hMaxList.append(i)
for i in range(W):
    if(wmax == wNum[i]):
        wMaxList.append(i)

ans = wmax + hmax
count = 0
for i in hw:
    if(hNum[i[0]-1] == hmax and wNum[i[1]-1] == wmax):
        count += 1
if(hNum.count(hmax) * wNum.count(wmax) == count):
    ans -= 1
print(ans)