Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()
for _ in range(m):
    c_h, c_w = map(int, input().split())
    h_cnt[c_h-1] +=1
    w_cnt[c_w-1]+=1
    bomb.add(((c_h-1),(c_w-1)))
    
h_max = max(h_cnt)
w_max = max(w_cnt)
    
max_h = [i for i in range(h) if h_cnt[i] == h_max]
max_w = [i for i in range(w) if w_cnt[i] == w_max]

flg = 0
for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = 1
            break

if flg:
    print(max_h + max_w)
else:
    print(max_h + max_w -1)

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()
for _ in range(m):
    c_h, c_w = map(int, input().split())
    h_cnt[c_h-1] +=1
    w_cnt[c_w-1]+=1
    bomb.add(((c_h-1),(c_w-1)))
    
h_max = max(h_cnt)
w_max = max(w_cnt)
    
max_h = [i for i in range(len(h_cnt)) if h_cnt[i] == h_max]
max_w = [i for i in range(len(w_cnt)) if h_cnt[i] == w_max]

flg = 0
for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = 1
            break

if flg:
    print(max_h + max_w)
else:
    print(max_h + max_w -1)

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()
for _ in range(m):
    c_h, c_w = map(int, input().split())
    h_cnt[c_h-1] +=1
    w_cnt[c_w-1]+=1
    bomb.add(((c_h-1),(c_w-1)))

max_h = [i for i in range(len(h_cnt)) if h_cnt[i] == max(h_cnt)]
max_w = [i for i in range(len(w_cnt)) if h_cnt[i] == max(w_cnt)]

ans = []
for i in max_h:
    for j in max_w:
        if (i,j) in bomb:
            ans.append(h_cnt[i] + w_cnt[j] -1)
        else:
            ans.append(h_cnt[i] + w_cnt[j])

print(max(ans))

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()
for _ in range(m):
    c_h, c_w = map(int, input().split())
    h_cnt[c_h-1] +=1
    w_cnt[c_w-1]+=1
    bomb.add(((c_h-1),(c_w-1)))

max_h = [i for i in range(len(h_cnt)) if h_cnt[i] == max(h_cnt)]
max_w = [i for i in range(len(w_cnt)) if h_cnt[i] == max(w_cnt)]

ans = []
for i in max_h:
    for j in max_w
    if (i,j) in bomb:
        ans.append(h_cnt[i] + w_cnt[j] -1)
    else:
        ans.append(h_cnt[i] + w_cnt[j])

print(max(ans))

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h, w], dtype=np.int8)
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1
    
row_sum = np.sum(arr, axis=1)
col_sum = np.sum(arr, axis=0)
row_max_pos = np.argwhere(row_sum == np.max(row_sum))
col_max_pos = np.argwhere(col_sum == np.max(col_sum))
    
row_max = int(max(row_sum))
col_max = int(max(col_sum))

ans = []
for i in row_max_pos:
    for j in col_max_pos:
        if arr[i,j] == 1:
            ans.append(row_max + col_max-1)
        else:
            ans.append(row_max + col_max-1)

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h, w], dtype=np.int8)
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1
    
row_sum = np.sum(arr, axis=1)
col_sum = np.sum(arr, axis=0)
row_max_pos = np.argwhere(row_sum == np.max(row_sum))
col_max_pos = np.argwhere(col_sum == np.max(col_sum))
    
row_max = int(max(row_sum))
col_max = int(max(col_sum))

ans = []
for i in row_max_pos:
    for j in col_max_pos:
        if arr[i,j] == 1:
            ans.append(row_max + col_max-1)
        else
            ans.append(row_max + col_max-1)

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h,w])

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h,w])
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h,w])
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1
    
row_sum = np.sum(arr, axis=1)
col_sum = np.sum(arr, axis=0)
row_max_pos = np.argwhere(row_sum == np.max(row_sum))
col_max_pos = np.argwhere(col_sum == np.max(col_sum))

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h,w])
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1
    
row_sum = np.sum(arr, axis=1)
col_sum = np.sum(arr, axis=0)
row_max_pos = np.argwhere(row_sum == np.max(row_sum))
col_max_pos = np.argwhere(col_sum == np.max(col_sum))
    
row_max = int(max(row_sum))
col_max = int(max(col_sum))
ans = row_max + col_max

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
h, w, m = map(int, input().split())
arr = np.zeros([h,w])
for _ in range(m):
    c_h, c_w = map(int, input().split())
    arr[c_h-1, c_w-1] = 1
    
row_sum = np.sum(arr, axis=1)
col_sum = np.sum(arr, axis=0)
row_max_pos = np.argwhere(row_sum == np.max(row_sum))
col_max_pos = np.argwhere(col_sum == np.max(col_sum))
    
row_max = int(max(row_sum))
col_max = int(max(col_sum))
ans = row_max + col_max

if sum(sum(arr[row_max_pos, col_max_pos] == 0)) > 0:
    print(ans)
else:
    print(ans-1)

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)