Buggy python submission (verdict: Time Limit Exceeded):
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

index_max_H = []
index_max_W = []

for ih in range(H+1):
    if bomH[ih] == max_bomH:
        index_max_H.append(ih)

for iw in range(W+1):
    if bomW[iw] == max_bomW:
        index_max_W.append(iw)

point = itertools.product(index_max_H,index_max_W)#置き場所候補
sPoint = set(point)
sBom = set(bom)
#爆弾が置き場所候補から爆弾場所を消す,すべてなくなれば、-1,どこか残れば0
for sb in sBom:
    sPoint.discard(sb)

print(max_bomH+max_bomW - (len(sPoint)==0) )
    


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))

point_bom = [[0]*(W+1) for _ in range(H+1)]
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
#point_bom = np.array(point_bom)
#row_bom = point_bom.sum(axis=0)
#col_bom = point_bom.sum(axis=1)
row_bom = []
for rb in point_bom:
    row_bom.append(sum(rb))
col_bom = [sum(x) for x in zip(*point_bom)]
    
max_row = max(row_bom)
max_col = max(col_bom)

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mr][mc] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))

point_bom = [[0]*(W+1) for _ in range(H+1)]
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
#point_bom = np.array(point_bom)
#row_bom = point_bom.sum(axis=0)
#col_bom = point_bom.sum(axis=1)
row_bom = []
for rb in point_bom:
    row_bom.append(sum(rb))
col_bom = [sum(x) for x in zip(*point_bom)]
    
max_row = max(row_bom)
max_col = max(col_bom)

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys,math,collections,itertools
import numpy as np


input = sys.stdin.readline
H,W,M=list(map(int,input().split()))

point_bom = np.array([[0]*(W+1) for _ in range(H+1)])
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
#point_bom = np.array(point_bom)
#row_bom = point_bom.sum(axis=0)
#col_bom = point_bom.sum(axis=1)
row_bom = []
for rb in point_bom:
    row_bom.append(sum(rb))
col_bom = [sum(x) for x in zip(*point_bom)]
    
max_row = max(row_bom)
max_col = max(col_bom)

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys,math,collections,itertools
import numpy as np
from numba import jit

@jit
def main()
    input = sys.stdin.readline
    H,W,M=list(map(int,input().split()))

    point_bom = np.array([[0]*(W+1) for _ in range(H+1)])
    for _ in range(M):
        h,w = map(int,input().split())
        point_bom[h][w]=1
    point_bom = np.array(point_bom)
    row_bom = point_bom.sum(axis=0)
    col_bom = point_bom.sum(axis=1)
    max_row = row_bom.max()
    max_col = col_bom.max()

    ind_max_row =[]
    ind_max_col = []

    for i in range(len(row_bom)):
        if row_bom[i] == max_row:
             ind_max_row.append(i)
    for i in range(len(col_bom)):
        if col_bom[i] == max_col:
            ind_max_col.append(i)

    flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
    for mr in ind_max_row:
        for mc in ind_max_col:
            if point_bom[mc][mr] == 0:
                flag = 0
                break
        if flag == 0:
            break
    print(max_row+max_col - flag)

main()


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys,math,collections,itertools
import numpy as np
from numba import jit
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
@jit
point_bom = np.array([[0]*(W+1) for _ in range(H+1)])
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
point_bom = np.array(point_bom)
row_bom = point_bom.sum(axis=0)
col_bom = point_bom.sum(axis=1)
max_row = row_bom.max()
max_col = col_bom.max()

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys,math,collections,itertools
import numpy as np
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
point_bom = [[0]*(W+1) for _ in range(H+1)]
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
point_bom = np.array(point_bom)
row_bom = point_bom.sum(axis=0)
col_bom = point_bom.sum(axis=1)
max_row = row_bom.max()
max_col = col_bom.max()

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))

Buggy python submission (verdict: Runtime Error):
#abc176-e
import sys,math,collections,itertools
import numpy as np
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
point_bom = [[0]*(W+1) for _ in range(H+1)]
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
point_bom = np.array(point_bom)
row_bom = point_bom.sum(axis=0)
col_bom = point_bom.sum(axis=1)
max_row = row_bom.max()
max_col = col_bom.max()

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))