Buggy python submission (verdict: Time Limit Exceeded):
import numpy
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
matrix =[0]*h
for i in range(h):
    matrix[i] = [0]*w
for i in range(m):
    hi,wi = map(int,input().split())
    hight[hi-1] += 1
    width[wi-1] += 1
    matrix[hi-1][wi-1] += 1
max_vh = max(hight)
max_vw = max(width)
max_h = list()
max_w = list()
for i in range(len(hight)):
    if(hight[i] == max_vh):
        max_h.append(i)
for i in range(len(width)):
    if(width[i] == max_vw):
        max_w.append(i)
# print(max_h,max_w)
if(len(max_h)==0 and len(max_w)):
    print(hight[max_h[0]]+width[max_w[0]]-matrix[max_h[0]][max_w[0]])
elif(len(max_h)!=0 and len(max_w)==0):
    ans = 0
    for i in range(len(max_h)):
        ans = max(ans,hight[max_h[i]]+width[max_w][0]-matrix[max_h[i]][max_w][0])
    print(ans)
elif(len(max_h)==0 and len(max_w)!=0):
    ans = 0
    for i in range(len(max_w)):
        ans = max(ans,hight[max_h[0]]+width[max_w[i]]-matrix[max_h[0]][max_w[i]])
    print(ans)
else:
    ans = 0
    for i in range(len(max_h)):
        for j in range(len(max_w)):
            ans = max(ans,hight[max_h[i]]+width[max_w[j]]-matrix[max_h[i]][max_w[j]])
    print(ans)



Fixed submission:
import sys
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
S = set()

for i in range(m):
    hi,wi = map(int,input().split())
    S.add((hi-1,wi-1))
    hight[hi-1] += 1
    width[wi-1] += 1

max_vh = max(hight)
max_vw = max(width)

max_h = [i for i in range(h) if hight[i] == max_vh]
max_w = [i for i in range(w) if width[i] == max_vw]
for i in max_h:
    for j in max_w:
        if not(i,j) in S:
            print(max_vh+max_vw)
            sys.exit()

print(max_vh+max_vw-1)

Buggy python submission (verdict: Runtime Error):
import numpy
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
matrix =[0]*h
for i in range(h):
    matrix[i] = [0]*w
for i in range(m):
    hi,wi = map(int,input().split())
    hight[hi-1] += 1
    width[wi-1] += 1
    matrix[hi-1][wi-1] += 1
max_vh = numpy.argmax(hight)
max_vw = numpy.argmax(width)
f = 1
for i in range(m):
    if(matrix[max_vh][i] == 0):
        f = 0
        break
 
print(hight[max_vh] + width[max_vw]-f)

# 3 2 22
# 3 2
# 1 2



Fixed submission:
import sys
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
S = set()

for i in range(m):
    hi,wi = map(int,input().split())
    S.add((hi-1,wi-1))
    hight[hi-1] += 1
    width[wi-1] += 1

max_vh = max(hight)
max_vw = max(width)

max_h = [i for i in range(h) if hight[i] == max_vh]
max_w = [i for i in range(w) if width[i] == max_vw]
for i in max_h:
    for j in max_w:
        if not(i,j) in S:
            print(max_vh+max_vw)
            sys.exit()

print(max_vh+max_vw-1)

Buggy python submission (verdict: Runtime Error):
import numpy
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
matrix =[0]*w
for i in range(w):
    matrix[i] = [0]*h
for i in range(m):
    hi,wi = map(int,input().split())
    hight[hi-1]+=1
    width[wi-1]+=1
    matrix[wi-1][hi-1] += 1
# print(matrix)
max_vh = numpy.argmax(hight)
max_vw = numpy.argmax(width)
print(hight[max_vh]+width[max_vh]-matrix[max_vw][max_vh])


Fixed submission:
import sys
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
S = set()

for i in range(m):
    hi,wi = map(int,input().split())
    S.add((hi-1,wi-1))
    hight[hi-1] += 1
    width[wi-1] += 1

max_vh = max(hight)
max_vw = max(width)

max_h = [i for i in range(h) if hight[i] == max_vh]
max_w = [i for i in range(w) if width[i] == max_vw]
for i in max_h:
    for j in max_w:
        if not(i,j) in S:
            print(max_vh+max_vw)
            sys.exit()

print(max_vh+max_vw-1)