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

h, w, m = map(int,input().split())

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

rind = [i for i,v in enumerate(row) if v == rmax]
cind = [i for i,v in enumerate(col) if v == cmax]

ans = 0
for r in rind:
    for c in cind:
        if (r, c) in enemy:
            ans = max(ans, rmax+cmax-1)
        else:
            ans = max(ans, rmax+cmax)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

h, w, m = map(int,input().split())

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

on_r = row.count(rmax)
on_c = col.count(cmax)

on = 0
for hh, ww in enemy:
    if row[hh] == rmax and col[ww] == cmax:
        on += 1
if on == on_r*on_c:
    print(rmax+cmax-1)
else:
    print(rmax+cmax)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

h, w, m = map(int,input().split())

row = [0]*w
col = [0]*h
maze = [[0 for _ in range(w)] for _ in range(h)]

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    maze[hh][ww] = 1

rmax = max(row)
cmax = max(col)
 
rind = [n for n, v in enumerate(row) if v == rmax]
cind = [n for n, v in enumerate(col) if v == cmax]
 
#print(rind)
#print(cind)
ans = 0
 
for r in rind:
    for c in cind:
        if maze[r][c] == 1:
            ans = rmax+cmax-1
        else:
            ans = rmax+cmax
            print(ans)
            exit()
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

h, w, m = map(int,input().split())

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

on_r = row.count(rmax)
on_c = col.count(cmax)

on = 0
for hh, ww in enemy:
    if row[hh] == rmax and col[ww] == cmax:
        on += 1
if on == on_r*on_c:
    print(rmax+cmax-1)
else:
    print(rmax+cmax)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, m = map(int,input().split())
maze = [[0 for _ in range(w)] for _ in range(h)]
for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    maze[hh][ww] = 1

#print(maze)

#yoko
row = [0]*h
for r in range(h):
    row[r] = sum(maze[r])
#tate
col = [0]*w
for c in range(w):
    tmp = 0
    for r in range(h):
        tmp += maze[r][c]
    col[c] = tmp

rmax = max(row)
cmax = max(col)

rind = [n for n, v in enumerate(row) if v == rmax]
cind = [n for n, v in enumerate(col) if v == cmax]

#print(rind)
#print(cind)
ans = 0

for r in rind:
    for c in cind:
        if maze[r][c] == 1:
            ans = rmax+cmax-1
        else:
            ans = rmax+cmax
            print(ans)
            exit()
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

h, w, m = map(int,input().split())

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

on_r = row.count(rmax)
on_c = col.count(cmax)

on = 0
for hh, ww in enemy:
    if row[hh] == rmax and col[ww] == cmax:
        on += 1
if on == on_r*on_c:
    print(rmax+cmax-1)
else:
    print(rmax+cmax)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, m = map(int,input().split())
maze = [[0 for _ in range(w)] for _ in range(h)]
for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    maze[hh][ww] = 1

#yoko
row = [0]*h
for r in range(h):
    row[r] = sum(maze[r])
#tate
col = [0]*w
for c in range(w):
    tmp = 0
    for r in range(h):
        tmp += maze[r][c]
    col[c] = tmp

rmax = max(row)
cmax = max(col)
ans = 0
for i,r in enumerate(row):
    if r == rmax:
        for j,c in enumerate(col):
            if c == cmax:
                if maze[i][j] == 1:
                    ans = max(ans, rmax+cmax-1)
                else:
                    ans = max(ans,rmax+cmax)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

h, w, m = map(int,input().split())

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

on_r = row.count(rmax)
on_c = col.count(cmax)

on = 0
for hh, ww in enemy:
    if row[hh] == rmax and col[ww] == cmax:
        on += 1
if on == on_r*on_c:
    print(rmax+cmax-1)
else:
    print(rmax+cmax)