Buggy python submission (verdict: Time Limit Exceeded):
H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
#bomb=[0]*M
bset=set()
#for k in range(M):
    #bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    #bomb[j][0]=h-1
    #bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
flag=0
for i in range(H):
    if height[i]==hmax:
        for h in range(W):
            if width[h]==wmax:
                if (i,h) not in bset:
                    flag=1
                    break
if flag==1:
    print(hmax+wmax)
else:
    print(hmax+wmax-1)

Fixed submission:
H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
#bomb=[0]*M
bset=set()
#for k in range(M):
    #bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    #bomb[j][0]=h-1
    #bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
hindex=0
windex=0
for i in range(H):
    if height[i]==hmax:
        #print(i)
        hindex+=1
for h in range(W):
    if width[h]==wmax:
        #print(h)
        windex+=1
kouho=hindex*windex
equalbomb=0
for p in bset:
    if height[p[0]]==hmax and width[p[1]]==wmax:
        #print(p)
        equalbomb+=1

if kouho==equalbomb:
    print(hmax+wmax-1)
else:
    print(hmax+wmax)

Buggy python submission (verdict: Time Limit Exceeded):
H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
#bomb=[0]*M
bset=set()
#for k in range(M):
    #bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    #bomb[j][0]=h-1
    #bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
flag=0
for i in range(H):
    if height[i]==hmax:
        for h in range(W):
            if width[h]==wmax:
                if (i,h) not in bset:
                    flag=1
                    break
if flag==1:
    print(hmax+wmax)
else:
    print(hmax+wmax-1)

Fixed submission:
H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
#bomb=[0]*M
bset=set()
#for k in range(M):
    #bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    #bomb[j][0]=h-1
    #bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
hindex=0
windex=0
for i in range(H):
    if height[i]==hmax:
        #print(i)
        hindex+=1
for h in range(W):
    if width[h]==wmax:
        #print(h)
        windex+=1
kouho=hindex*windex
equalbomb=0
for p in bset:
    if height[p[0]]==hmax and width[p[1]]==wmax:
        #print(p)
        equalbomb+=1

if kouho==equalbomb:
    print(hmax+wmax-1)
else:
    print(hmax+wmax)

Buggy python submission (verdict: Time Limit Exceeded):

H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
bomb=[0]*M
bset=set()
for k in range(M):
    bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    bomb[j][0]=h-1
    bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
ans=0
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
flag=0
for i in range(H):
    if height[i]==hmax:
        for h in range(W):
            if width[h]==wmax:
                if (i,h) not in bset:
                    flag=1
                    break
if flag==1:
    print(hmax+wmax)
else:
    print(hmax+wmax-1)

Fixed submission:
H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
#bomb=[0]*M
bset=set()
#for k in range(M):
    #bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    #bomb[j][0]=h-1
    #bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
hindex=0
windex=0
for i in range(H):
    if height[i]==hmax:
        #print(i)
        hindex+=1
for h in range(W):
    if width[h]==wmax:
        #print(h)
        windex+=1
kouho=hindex*windex
equalbomb=0
for p in bset:
    if height[p[0]]==hmax and width[p[1]]==wmax:
        #print(p)
        equalbomb+=1

if kouho==equalbomb:
    print(hmax+wmax-1)
else:
    print(hmax+wmax)

Buggy python submission (verdict: Time Limit Exceeded):

H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
bomb=[0]*M
bset=set()
for k in range(M):
    bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    bomb[j][0]=h-1
    bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
ans=0
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
flag=0
for i in range(H):
    if height[i]==hmax:
        for h in range(W):
            if width[h]==wmax:
                if (i,h) not in bset:
                    flag=1
                    break
if flag==1:
    print(hmax+wmax)
else:
    print(hmax+wmax-1)

Fixed submission:
H,W,M=map(int,input().split())
height=[0]*H
width=[0]*W
#bomb=[0]*M
bset=set()
#for k in range(M):
    #bomb[k]=[0]*2
for j in range(M):
    h,w=map(int,input().split())
    bset.add((h-1,w-1))
    #bomb[j][0]=h-1
    #bomb[j][1]=w-1
    height[h-1]+=1
    width[w-1]+=1
#print(bomb)
#print(height)
#print(width)
hmax=max(height)
wmax=max(width)
hindex=0
windex=0
for i in range(H):
    if height[i]==hmax:
        #print(i)
        hindex+=1
for h in range(W):
    if width[h]==wmax:
        #print(h)
        windex+=1
kouho=hindex*windex
equalbomb=0
for p in bset:
    if height[p[0]]==hmax and width[p[1]]==wmax:
        #print(p)
        equalbomb+=1

if kouho==equalbomb:
    print(hmax+wmax-1)
else:
    print(hmax+wmax)