Buggy python submission (verdict: Runtime Error):
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[0]*h
wk=[0]*w
for i in range(len(hc)):
	if hc[i]==hcm:
		hk[i]=1
for i in range(len(wc)):
	if wc[i]==wcm:
		wk[i]=1
c=0
for i in range(len(a)):
	if a[i][0]==wk[i] and a[i][1]==hk[i]:
		c+=1
if c==len(hk)*len(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)

Fixed submission:
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[0]*w
wk=[0]*h
for i in range(len(hc)):
	if hc[i]==hcm:
		hk[i]=1
for i in range(len(wc)):
	if wc[i]==wcm:
		wk[i]=1
c=0
for i in range(len(a)):
	if wk[a[i][0]]==1 and hk[a[i][1]]==1:
		c+=1
if c==sum(hk)*sum(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[]
wk=[]
for i in range(len(hc)):
	if hc[i]==hcm:
		hk.extend([i])
for i in range(len(wc)):
	if wc[i]==wcm:
		wk.extend([i])
c=0
for i in range(len(a)):
	if a[i][0] in wk:
		if a[i][1] in hk:
			c+=1
if c==len(hk)*len(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)

Fixed submission:
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[0]*w
wk=[0]*h
for i in range(len(hc)):
	if hc[i]==hcm:
		hk[i]=1
for i in range(len(wc)):
	if wc[i]==wcm:
		wk[i]=1
c=0
for i in range(len(a)):
	if wk[a[i][0]]==1 and hk[a[i][1]]==1:
		c+=1
if c==sum(hk)*sum(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int, input().split())
a = [0]*m
hc=[0 for i in range(w)]
wc=[0 for i in range(h)]
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[]
wk=[]
for i in range(len(hc)):
	if hc[i]==hcm:
		hk.extend([i])
for i in range(len(wc)):
	if wc[i]==wcm:
		wk.extend([i])
for i in range(len(hk)):
	for j in range(len(wk)):
		if [wk[j],hk[i]] not in a:
			print(hcm+wcm)
			exit()
print(hcm+wcm-1)

Fixed submission:
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[0]*w
wk=[0]*h
for i in range(len(hc)):
	if hc[i]==hcm:
		hk[i]=1
for i in range(len(wc)):
	if wc[i]==wcm:
		wk[i]=1
c=0
for i in range(len(a)):
	if wk[a[i][0]]==1 and hk[a[i][1]]==1:
		c+=1
if c==sum(hk)*sum(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)

Buggy python submission (verdict: Runtime Error):
h,w,m=map(int, input().split())
a = [[0 for j in range(w)] for i in range(h)]
for i in range(m):
	x,y=map(int, input().split())
	a[x-1][y-1]+=1
hc=[0 for i in range(w)]
wc=[0 for i in range(h)]
for i in range(w):
	for j in range(h):
		hc[i] += a[j][i]
for i in range(h):
	for j in range(w):
		wc[i] += a[i][j]
ans=0
for i in range(len(hc)):
	for j in range(len(wc)):
		if a[i][j]==1:
			if ans<hc[i]+wc[j]-1:
				ans=hc[i]+wc[j]-1
		else:
			if ans<hc[i]+wc[j]:
				ans=hc[i]+wc[i]
print(ans)

Fixed submission:
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[0]*w
wk=[0]*h
for i in range(len(hc)):
	if hc[i]==hcm:
		hk[i]=1
for i in range(len(wc)):
	if wc[i]==wcm:
		wk[i]=1
c=0
for i in range(len(a)):
	if wk[a[i][0]]==1 and hk[a[i][1]]==1:
		c+=1
if c==sum(hk)*sum(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)

Buggy python submission (verdict: Runtime Error):
h,w,m=map(int, input().split())
a = [[0 for j in range(w)] for i in range(h)]
for i in range(m):
	x,y=map(int, input().split())
	a[x-1][y-1]+=1
hc=[0 for i in range(w)]
wc=[0 for i in range(h)]
for i in range(w):
	for j in range(h):
		hc[i] += a[j][i]
for i in range(h):
	for j in range(w):
		wc[i] += a[i][j]
ans=0
for i in range(len(hc)):
	for j in range(len(wc)):
		if a[i][j]==1:
			if ans<hc[i]+wc[j]-1:
				ans=hc[i]+wc[j]-1
		else:
			if ans<hc[i]+wc[j]:
				ans=hc[i]+wc[i]
print(ans)

Fixed submission:
h,w,m=map(int, input().split())
a=[0]*m
hc=[0]*w
wc=[0]*h
for i in range(m):
	x,y=map(int, input().split())
	a[i]=[x-1,y-1]
	hc[y-1]+=1
	wc[x-1]+=1
hcm=max(hc)
wcm=max(wc)
hk=[0]*w
wk=[0]*h
for i in range(len(hc)):
	if hc[i]==hcm:
		hk[i]=1
for i in range(len(wc)):
	if wc[i]==wcm:
		wk[i]=1
c=0
for i in range(len(a)):
	if wk[a[i][0]]==1 and hk[a[i][1]]==1:
		c+=1
if c==sum(hk)*sum(wk):
	print(hcm+wcm-1)		
else:
	print(hcm+wcm)