Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append([h,w])
  hmax = max(hcount)
  wmax = max(wcount)
  for h in range(H):
    for w in range(W):
      if hcount[h] != hmax or wcount[w] != wmax or [h,w] in s:
        continue
      else:
        return hmax + wmax
  return hmax + wmax - 1

if __name__ == '__main__':
    print(calc())

Fixed submission:
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())

Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append([h,w])
  hmax = max(hcount)
  wmax = max(wcount)
  for h in range(H):
    for w in range(W):
      if hcount[h] != hmax or wcount[w] != wmax or [h,w] in s:
        continue
      else:
        return hmax + wmax
  return hmax + wmax - 1

if __name__ == '__main__':
    print(calc())

Fixed submission:
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())

Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append([h,w])
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = []
  wmode = []
  for h in range(H):
    if hcount[h] == hmax:
      hmode.append(h)
  for w in range(W):
    if wcount[w] == wmax:
      wmode.append(w)
  for h in hmode:
    for w in wmode:
      if ([h,w] in s):
        continue
      return hmax + wmax
  return hmax + wmax - 1

if __name__ == '__main__':
    print(calc())

Fixed submission:
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())

Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append([h,w])
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = []
  wmode = []
  for h in range(H):
    if hcount[h] == hmax:
      hmode.append(h)
  for w in range(W):
    if wcount[w] == wmax:
      wmode.append(w)
  for h in hmode:
    for w in wmode:
      if ([h,w] in s):
        continue
      return hmax + wmax
  return hmax + wmax - 1

if __name__ == '__main__':
    print(calc())

Fixed submission:
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import statistics
H,W,M = map(int, input().split())
S = np.array([list([int(s) for s in input().split()]) for i in range(M)]) - 1
Hlist = S[:,0]
Wlist = S[:,1]
Hunique,Hcount = np.unique(Hlist, return_counts=True)
Wunique,Wcount = np.unique(Wlist, return_counts=True)
Hmode = np.array(list(Hunique[Hcount == max(Hcount)]))
Wmode = np.array(list(Wunique[Wcount == max(Wcount)]))
judge = -1
slist = []
for m in range(M):
  slist.append(list(S[m,:]))
for h in Hmode:
  for w in Wmode:
    if ([h,w] in slist) == False:
      judge = 0
      break
print(max(Hcount) + max(Wcount) + judge)

Fixed submission:
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import statistics
H,W,M = map(int, input().split())
S = np.array([list([int(s) for s in input().split()]) for i in range(M)]) - 1
Hlist = S[:,0]
Wlist = S[:,1]
Hunique,Hcount = np.unique(Hlist, return_counts=True)
Wunique,Wcount = np.unique(Wlist, return_counts=True)
Hmode = np.array(list(Hunique[Hcount == max(Hcount)]))
Wmode = np.array(list(Wunique[Wcount == max(Wcount)]))
judge = -1
for h in Hmode:
  for w in Wmode:
    c = True
    for m in range(M):
      if (S[m,0] == h and S[m,1] == w):
        c = False
    if c:
      judge = 0
print(max(Hcount) + max(Wcount) + judge)

Fixed submission:
def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())