Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=[0]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp[i]=[s[i],t[i]]
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if [maxs[i]+1,maxt[j]+1] not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Fixed submission:
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Buggy python submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=[]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp[i]=[s[i],t[i]]
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Fixed submission:
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=[]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.append(tuple([s[i],t[i]]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)
c=0
for i in range(len(maxs)):
  for j in range(len(maxt)):
    if (maxs[i]+1,maxt[j]+1) not in temp:
      print(ans)
      exit()
else:
  print(ans-1)

Fixed submission:
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=[0]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp[i]=[s[i],t[i]]
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)
c=0
for i in range(len(maxs)):
  for j in range(len(maxt)):
    if ([maxs[i]+1,maxt[j]+1]) not in temp:
      print(ans)
      exit()
else:
  print(ans-1)

Fixed submission:
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=[0]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp[i]=[s[i],t[i]]
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)
c=0
for i in range(len(maxs)):
  for j in range(len(maxt)):
    if ([maxs[i]+1,maxt[j]+1]) not in temp:
      print(ans)
      exit()
else:
  print(ans-1)

Fixed submission:
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Buggy python submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
s=[0]*m
st=[0]*m
t=[0]*m
tt=[0]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  st[i]=sm
  t[i]=tm
  tt[i]=tm
  
import statistics
temp=statistics.mode(s)
ans1=s.count(temp)
for i in range(m):
  if s[i]==temp:
    tt[i]=999999999999999999
while 999999999999999999 in tt:tt.remove(999999999999999999)
temp=statistics.mode(tt)
ans1=ans1+tt.count(temp)

temp=statistics.mode(t)
ans2=t.count(temp)
for i in range(m):
  if t[i]==temp:
    st[i]=999999999999999999
while 999999999999999999 in st:st.remove(999999999999999999)
temp=statistics.mode(st)
ans2=ans2+st.count(temp)

print(max(ans1,ans2))

Fixed submission:
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)