Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = list(map(int,input().split()))

bombDict = dict()
bombDictH = dict()
bombDictW = dict()


for i in range(h+1):
    bombDict[i] = set()
    bombDictH[i] = 0

for i in range(w+1):
    bombDictW[i] = 0


for i in range(m):
    bombH,bombW = list(map(int,input().split()))
    bombDictH[bombH] += 1
    bombDictW[bombW] += 1
    bombDict[bombH].add(bombW)

maxH = max(bombDictH,key = bombDictH.get)
maxW = max(bombDictW,key = bombDictW.get)
maxHV = max(bombDictH.values())
maxWV = max(bombDictW.values())

hList = list(bombDictH.values())
wList = list(bombDictW.values())

maxHList = []
maxWList = []

if hList.count(maxHV) > 1:
    for i in range(h+1):
        if hList[i] == maxHV:
            maxHList.append(i)
else:
    maxHList.append(maxH)

if wList.count(maxWV) > 1:
    for i in range(w+1):
        if wList[i] == maxWV:
            maxWList.append(i)
else:
    maxWList.append(maxW)

ans = 0

for i in maxHList:
    for j in maxWList:
        if j in bombDict[i]:
            ans = max(ans,bombDictH[i] + bombDictW[j] - 1)
        else:
            ans = max(ans,bombDictH[i] + bombDictW[j])

print(ans)

Fixed submission:
h,w,m = list(map(int,input().split()))

bombDict = dict()
bombDictH = dict()
bombDictW = dict()


for i in range(h+1):
    bombDict[i] = set()
    bombDictH[i] = 0

for i in range(w+1):
    bombDictW[i] = 0


for i in range(m):
    bombH,bombW = list(map(int,input().split()))
    bombDictH[bombH] += 1
    bombDictW[bombW] += 1
    bombDict[bombH].add(bombW)

maxH = max(bombDictH,key = bombDictH.get)
maxW = max(bombDictW,key = bombDictW.get)
maxHV = max(bombDictH.values())
maxWV = max(bombDictW.values())

hList = list(bombDictH.values())
wList = list(bombDictW.values())

maxHList = []
maxWList = []

if hList.count(maxHV) > 1:
    for i in range(h+1):
        if hList[i] == maxHV:
            maxHList.append(i)
else:
    maxHList.append(maxH)

if wList.count(maxWV) > 1:
    for i in range(w+1):
        if wList[i] == maxWV:
            maxWList.append(i)
else:
    maxWList.append(maxW)

ans = 0

for i in maxHList:
    for j in maxWList:
        if j in bombDict[i]:
            ans = max(ans,bombDictH[i] + bombDictW[j] - 1)
        else:
            ans = max(ans,bombDictH[i] + bombDictW[j])
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = list(map(int,input().split()))

bombDict = dict()
bombDictH = dict()
bombDictW = dict()


for i in range(h+1):
    bombDict[i] = set()
    bombDictH[i] = 0

for i in range(w+1):
    bombDictW[i] = 0


for i in range(m):
    bombH,bombW = list(map(int,input().split()))
    bombDictH[bombH] += 1
    bombDictW[bombW] += 1
    bombDict[bombH].add(bombW)

maxH = max(bombDictH,key = bombDictH.get)
maxW = max(bombDictW,key = bombDictW.get)
maxHV = max(bombDictH.values())
maxWV = max(bombDictW.values())

hList = list(bombDictH.values())
wList = list(bombDictW.values())

maxHList = []
maxWList = []

if hList.count(maxHV) > 1:
    for i in range(h+1):
        if hList[i] == maxHV:
            maxHList.append(i)
else:
    maxHList.append(maxH)

if wList.count(maxWV) > 1:
    for i in range(w+1):
        if wList[i] == maxWV:
            maxWList.append(i)
else:
    maxWList.append(maxW)

ans = 0

for i in maxHList:
    for j in maxWList:
        if j in bombDict[i]:
            ans = max(ans,bombDictH[i] + bombDictW[j] - 1)
        else:
            ans = max(ans,bombDictH[i] + bombDictW[j])

print(ans)

Fixed submission:
h,w,m = list(map(int,input().split()))

bombDict = dict()
bombDictH = dict()
bombDictW = dict()


for i in range(h+1):
    bombDict[i] = set()
    bombDictH[i] = 0

for i in range(w+1):
    bombDictW[i] = 0


for i in range(m):
    bombH,bombW = list(map(int,input().split()))
    bombDictH[bombH] += 1
    bombDictW[bombW] += 1
    bombDict[bombH].add(bombW)

maxH = max(bombDictH,key = bombDictH.get)
maxW = max(bombDictW,key = bombDictW.get)
maxHV = max(bombDictH.values())
maxWV = max(bombDictW.values())

hList = list(bombDictH.values())
wList = list(bombDictW.values())

maxHList = []
maxWList = []

if hList.count(maxHV) > 1:
    for i in range(h+1):
        if hList[i] == maxHV:
            maxHList.append(i)
else:
    maxHList.append(maxH)

if wList.count(maxWV) > 1:
    for i in range(w+1):
        if wList[i] == maxWV:
            maxWList.append(i)
else:
    maxWList.append(maxW)

ans = 0

for i in maxHList:
    for j in maxWList:
        if j in bombDict[i]:
            ans = max(ans,bombDictH[i] + bombDictW[j] - 1)
        else:
            ans = max(ans,bombDictH[i] + bombDictW[j])
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = list(map(int,input().split()))

bombDict = dict()
bombDictH = dict()
bombDictW = dict()


for i in range(h+1):
    bombDict[i] = set()
    bombDictH[i] = 0

for i in range(w+1):
    bombDictW[i] = 0


for i in range(m):
    bombH,bombW = list(map(int,input().split()))
    bombDictH[bombH] += 1
    bombDictW[bombW] += 1
    bombDict[bombH].add(bombW)

maxH = max(bombDictH,key = bombDictH.get)
maxW = max(bombDictW,key = bombDictW.get)
maxHV = max(bombDictH.values())
maxWV = max(bombDictW.values())

hList = list(bombDictH.values())
wList = list(bombDictW.values())

maxHList = []
maxWList = []

if hList.count(maxHV) > 1:
    for i in range(h+1):
        if hList[i] == maxHV:
            maxHList.append(i)
else:
    maxHList.append(maxH)

if wList.count(maxWV) > 1:
    for i in range(w+1):
        if wList[i] == maxWV:
            maxWList.append(i)
else:
    maxWList.append(maxW)

ans = 0

for i in maxHList:
    for j in maxWList:
        if j in bombDict[i]:
            ans = max(ans,bombDictH[i] + bombDictW[j] - 1)
        else:
            ans = max(ans,bombDictH[i] + bombDictW[j])

print(ans)

Fixed submission:
h,w,m = list(map(int,input().split()))

bombDict = dict()
bombDictH = dict()
bombDictW = dict()


for i in range(h+1):
    bombDict[i] = set()
    bombDictH[i] = 0

for i in range(w+1):
    bombDictW[i] = 0


for i in range(m):
    bombH,bombW = list(map(int,input().split()))
    bombDictH[bombH] += 1
    bombDictW[bombW] += 1
    bombDict[bombH].add(bombW)

maxH = max(bombDictH,key = bombDictH.get)
maxW = max(bombDictW,key = bombDictW.get)
maxHV = max(bombDictH.values())
maxWV = max(bombDictW.values())

hList = list(bombDictH.values())
wList = list(bombDictW.values())

maxHList = []
maxWList = []

if hList.count(maxHV) > 1:
    for i in range(h+1):
        if hList[i] == maxHV:
            maxHList.append(i)
else:
    maxHList.append(maxH)

if wList.count(maxWV) > 1:
    for i in range(w+1):
        if wList[i] == maxWV:
            maxWList.append(i)
else:
    maxWList.append(maxW)

ans = 0

for i in maxHList:
    for j in maxWList:
        if j in bombDict[i]:
            ans = max(ans,bombDictH[i] + bombDictW[j] - 1)
        else:
            ans = max(ans,bombDictH[i] + bombDictW[j])
            break

print(ans)