Buggy python submission (verdict: Runtime Error):
import collections

h,w,m = map(int,input().split())
l=[]
x=[]
y=[]
for i in range(m):
    hw=list(map(int,input().split()))
    l.append(hw)
    y.append(hw[0])
    x.append(hw[1])

xc = collections.Counter(x)
yc = collections.Counter(y)

tuplex = xc.most_common()[0]
tupley = yc.most_common()[0]

mostx=tuplex[0]
mosty=tupley[0]

if tuplex[1]>tupley[1]:
    y=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y.append(l[i][0])
    yc = collections.Counter(y)
    tupley = yc.most_common()[0]
    mosty=tupley[0]
    ans=0
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx:
            ans+=1
    print(ans)

elif tuplex[1]<tupley[1]:
    x=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x.append(l[i][1])
    xc = collections.Counter(x)
    tuplex = xc.most_common()[0]
    mostx=tuplex[0]
    ans=0
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx:
            ans+=1
    print(ans)

else:
    #y基準
    ans1=0
    x1=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x1.append(l[i][1])
    x1c = collections.Counter(x1)
    tuplex1 = x1c.most_common()[0]
    mostx1=tuplex1[0]
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx1:
            ans1+=1
    #x基準
    ans2=0
    y1=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y1.append(l[i][0])
    y1c =collections.Counter(y1)
    tupley1 = y1c.most_common()[0]
    mosty1=tupley1[0]
    for j in range(m):
        if l[j][0] == mosty1 or l[j][1] == mostx:
            ans2+=1
    print(max(ans1,ans2))

Fixed submission:
import collections

h,w,m = map(int,input().split())
l=[]
x=[]
y=[]
for i in range(m):
    hw=list(map(int,input().split()))
    l.append(hw)
    y.append(hw[0])
    x.append(hw[1])

xc = collections.Counter(x)
yc = collections.Counter(y)

tuplex = xc.most_common()[0]
tupley = yc.most_common()[0]

mostx=tuplex[0]
mosty=tupley[0]

if tuplex[1]>tupley[1]:
    y=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y.append(l[i][0])
    if len(y) != 0:
        yc = collections.Counter(y)
    tupley = yc.most_common()[0]
    mosty=tupley[0]
    ans=0
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx:
            ans+=1
    print(ans)

elif tuplex[1]<tupley[1]:
    x=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x.append(l[i][1])
    if len(x) != 0:
        xc = collections.Counter(x)
    tuplex = xc.most_common()[0]
    mostx=tuplex[0]
    ans=0
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx:
            ans+=1
    print(ans)

else:
    #y基準
    ans1=0
    x1=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x1.append(l[i][1])
    if len(x1) != 0:
        x1c = collections.Counter(x1)
    else:
        x1c = collections.Counter(x)
    tuplex1 = x1c.most_common()[0]
    mostx1=tuplex1[0]
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx1:
            ans1+=1
    #x基準
    ans2=0
    y1=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y1.append(l[i][0])
    if len(y1) != 0:
        y1c =collections.Counter(y1)
    else:
        y1c = collections.Counter(y)
    tupley1 = y1c.most_common()[0]
    mosty1=tupley1[0]
    for j in range(m):
        if l[j][0] == mosty1 or l[j][1] == mostx:
            ans2+=1
    print(max(ans1,ans2))

Buggy python submission (verdict: Runtime Error):
import collections

h,w,m = map(int,input().split())
l=[]
x=[]
y=[]
for i in range(m):
    hw=list(map(int,input().split()))
    hw[0]-=1
    hw[1]-=1
    l.append(hw)
    y.append(hw[0])
    x.append(hw[1])

xc = collections.Counter(x)
yc = collections.Counter(y)

tuplex = xc.most_common()[0]
tupley = yc.most_common()[0]

mostx=tuplex[0]
mosty=tupley[0]

if tuplex[1]>tupley[1]:
    y=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y.append(l[i][0])
    yc = collections.Counter(y)
    tupley = yc.most_common()[0]
    mosty=tupley[0]
    ans=0
    for j in range(m):
        if l[i][0] == mosty or l[i][1] == mostx:
            ans+=1
    print(ans)

elif tuplex[1]<tupley[1]:
    x=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x.append(l[i][1])
    xc = collections.Counter(x)
    tuplex = xc.most_common()[0]
    mostx=tuplex[0]
    ans=0
    for j in range(m):
        if l[i][0] == mosty or l[i][1] == mostx:
            ans+=1
    print(ans)

else:
    #y基準
    ans1=0
    x1=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x1.append(l[i][1])
    x1c = collections.Counter(x1)
    tuplex1 = x1c.most_common()[0]
    mostx1=tuplex1[0]
    for j in range(m):
        if l[i][0] == mosty or l[i][1] == mostx1:
            ans1+=1
    #x基準
    ans2=0
    y1=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y1.append(l[i][0])
    y1c =collections.Counter(y1)
    tupley1 = y1c.most_common()[0]
    mosty1=tupley1[0]
    for j in range(m):
        if l[i][0] == mosty1 or l[i][1] == mostx:
            ans2+=1
    print(max(ans1,ans2))

Fixed submission:
import collections

h,w,m = map(int,input().split())
l=[]
x=[]
y=[]
for i in range(m):
    hw=list(map(int,input().split()))
    l.append(hw)
    y.append(hw[0])
    x.append(hw[1])

xc = collections.Counter(x)
yc = collections.Counter(y)

tuplex = xc.most_common()[0]
tupley = yc.most_common()[0]

mostx=tuplex[0]
mosty=tupley[0]

if tuplex[1]>tupley[1]:
    y=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y.append(l[i][0])
    if len(y) != 0:
        yc = collections.Counter(y)
    tupley = yc.most_common()[0]
    mosty=tupley[0]
    ans=0
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx:
            ans+=1
    print(ans)

elif tuplex[1]<tupley[1]:
    x=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x.append(l[i][1])
    if len(x) != 0:
        xc = collections.Counter(x)
    tuplex = xc.most_common()[0]
    mostx=tuplex[0]
    ans=0
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx:
            ans+=1
    print(ans)

else:
    #y基準
    ans1=0
    x1=[]
    for i in range(m):
        if l[i][0]!=mosty:
            x1.append(l[i][1])
    if len(x1) != 0:
        x1c = collections.Counter(x1)
    else:
        x1c = collections.Counter(x)
    tuplex1 = x1c.most_common()[0]
    mostx1=tuplex1[0]
    for j in range(m):
        if l[j][0] == mosty or l[j][1] == mostx1:
            ans1+=1
    #x基準
    ans2=0
    y1=[]
    for i in range(m):
        if l[i][1]!=mostx:
            y1.append(l[i][0])
    if len(y1) != 0:
        y1c =collections.Counter(y1)
    else:
        y1c = collections.Counter(y)
    tupley1 = y1c.most_common()[0]
    mosty1=tupley1[0]
    for j in range(m):
        if l[j][0] == mosty1 or l[j][1] == mostx:
            ans2+=1
    print(max(ans1,ans2))