Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  bomb[i] = [h - 1, w - 1]
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_index = []
W_index = []
for i in range(H):
  if H_list[i] == H_max:
    H_index.append(i)
    
for i in range(W):
  if W_list[i] == W_max:
    W_index.append(i)
    

x = 1
for i in H_index:
  for j in W_index:
    if [i, j] not in bomb:
      x = 0
      
print(H_max + W_max - x)      
    
    
    
    






Fixed submission:
H, W, M = map(int, input().split())
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  bomb[i] = [h - 1, w - 1]
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_count = H_list.count(H_max)
W_count = W_list.count(W_max)
HW_max = H_max + W_max

count = 0
for i, j in bomb:
  if H_list[i] + W_list[j] == HW_max:
    count += 1
    
if count == H_count * W_count:
  x = 1
else:
  x = 0
  
print(HW_max - x)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
HW = [[0] * W for i in range(H)]
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  HW[h - 1][w - 1] = 1
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_index = []
W_index = []
for i in range(H):
  if H_list[i] == H_max:
    H_index.append(i)
    
for i in range(W):
  if W_list[i] == W_max:
    W_index.append(i)
    

x = 1
for i in H_index:
  for j in W_index:
    if HW[i][j] == 0:
      x = 0
      
print(H_max + W_max - x)      
    
    
    
    






Fixed submission:
H, W, M = map(int, input().split())
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  bomb[i] = [h - 1, w - 1]
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_count = H_list.count(H_max)
W_count = W_list.count(W_max)
HW_max = H_max + W_max

count = 0
for i, j in bomb:
  if H_list[i] + W_list[j] == HW_max:
    count += 1
    
if count == H_count * W_count:
  x = 1
else:
  x = 0
  
print(HW_max - x)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
HW = [[0] * W for i in range(H)]
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  HW[h - 1][w - 1] = 1
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_index = []
W_index = []
for i in range(H):
  if H_list[i] == H_max:
    H_index.append(i)
    
for i in range(W):
  if W_list[i] == W_max:
    W_index.append(i)
    

x = 1
for i in H_index:
  for j in W_index:
    if HW[i][j] == 0:
      x = 0
      
print(H_max + W_max - x)      
    
    
    
    






Fixed submission:
H, W, M = map(int, input().split())
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  bomb[i] = [h - 1, w - 1]
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_count = H_list.count(H_max)
W_count = W_list.count(W_max)
HW_max = H_max + W_max

count = 0
for i, j in bomb:
  if H_list[i] + W_list[j] == HW_max:
    count += 1
    
if count == H_count * W_count:
  x = 1
else:
  x = 0
  
print(HW_max - x)