Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,M = map(int,input().split())
#h = np.empty(M,dtype=np.int)
#w = np.empty(M,dtype=np.int)
bomb = set()
hh = np.zeros(H+1,dtype=np.int)
ww = np.zeros(W+1,dtype=np.int)

for i in range(M):
    h,w = map(int,input().split())
    bomb.add((h,w))
    hh[h] += 1
    ww[w] += 1

#print(bomb)
h_max = np.max(hh)
w_max = np.max(ww)

h_max_ids = list()
w_max_ids = list()
for i in range(1,H+1):
    if hh[i] == h_max:
      h_max_ids.append(i)
for j in range(1,W+1):
    if ww[j] == w_max:
      w_max_ids.append(j)
b=1
for i in h_max_ids:
  for j in w_max_ids:
    if not (i,j) in bomb:
      b = 0

#print("hmax:{} wmax:{}".format(h_max_id, w_max_id))
#print("hmax:{} wmax:{}".format(hh[h_max_id], ww[w_max_id]))
print(h_max + w_max - b)


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,M = map(int,input().split())
#h = np.empty(M,dtype=np.int)
#w = np.empty(M,dtype=np.int)
bomb = set()
hh = np.zeros(H+1,dtype=np.int32)
ww = np.zeros(W+1,dtype=np.int32)

for i in range(M):
    h,w = map(int,input().split())
    bomb.add((h,w))
    hh[h] += 1
    ww[w] += 1

#print(bomb)
h_max = np.max(hh)
w_max = np.max(ww)

b = 1
for i in range(1,H+1):
  for j in range(1,W+1):
    if hh[i] == h_max and ww[j] == w_max:
      if not (i,j) in bomb:
        b = 0
      #else:
        #print("[{}, {}] exists".format(i,j))
#print("hmax:{} wmax:{}".format(h_max_id, w_max_id))
#print("hmax:{} wmax:{}".format(hh[h_max_id], ww[w_max_id]))
print(h_max + w_max - b)


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,M = map(int,input().split())
#h = np.empty(M,dtype=np.int)
#w = np.empty(M,dtype=np.int)
bomb = [0,0]*M
hh = np.zeros(H+1,dtype=np.int32)
ww = np.zeros(W+1,dtype=np.int32)

for i in range(M):
    h,w = map(int,input().split())
    bomb[i] = [h,w]
    hh[h] += 1
    ww[w] += 1

#print(bomb)
h_max = np.max(hh)
w_max = np.max(ww)

b = 1
for i in range(1,H+1):
  for j in range(1,W+1):
    if hh[i] == h_max and ww[j] == w_max:
      if not [i,j] in bomb[:]:
        b = 0
      #else:
        #print("[{}, {}] exists".format(i,j))
#print("hmax:{} wmax:{}".format(h_max_id, w_max_id))
#print("hmax:{} wmax:{}".format(hh[h_max_id], ww[w_max_id]))
print(h_max + w_max - b)


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1)

if __name__ == '__main__':
    main()