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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
dpcol = [0]*w
dprow = [0]*h
ypos = []
xpos = []
hw = [list(map(lambda x: int(x) - 1, input().split())) for i in range(m)]

for i, j in hw:
    dpcol[j] += 1
    dprow[i] += 1

maxcol = max(dpcol)
maxrow = max(dprow)

for i in range(w): #列の最大値
    if dpcol[i] == maxcol:
        xpos.append(i)

for i in range(h):
    if dprow[i] == maxrow:
        ypos.append(i)

ans = maxcol + maxrow - 1

for i in ypos:
    for j in xpos:
        if [i, j] not in hw:
            ans += 1
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, m = map(int, input().split())
dpcol = [0]*w
dprow = [0]*h
ypos = []
xpos = []
hw = [list(map(lambda x: int(x) - 1, input().split())) for i in range(m)]

for i, j in hw:
    dpcol[j] += 1
    dprow[i] += 1

maxcol = max(dpcol)
maxrow = max(dprow)

for i in range(w): #列の最大値
    if dpcol[i] == maxcol:
        xpos.append(i)

for i in range(h):
    if dprow[i] == maxrow:
        ypos.append(i)

for i in ypos:
    for j in xpos:
        if [i, j] in hw:
            ans = maxcol + maxrow - 1
        else:
            ans = maxcol + maxrow
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w, m = map(int, input().split())
dpcol = [0]*w
dprow = [0]*h
ypos = []
xpos = []
anscol = 0
ansrow = 0
ans = 0
hw = [list(map(lambda x: int(x) - 1, input().split())) for i in range(m)]

for i, j in hw:
    dpcol[j] += 1
    dprow[i] += 1

for i in range(w): #列の最大値
    if dpcol[i] > anscol:
        anscol = dpcol[i]
        xpos = [i]
    elif dpcol[i] == anscol:
        xpos.append(i)

for i in range(h):
    if dprow[i] > ansrow:
        ansrow = dprow[i]
        ypos = [i]
    elif dprow[i] == ansrow:
        ypos.append(i)

for i in ypos:
    for j in xpos:
        if [i, j] in hw:
            ans = anscol + ansrow - 1
        else:
            ans = anscol + ansrow
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
dp= [[0]*w for i in range(h)]
dpcol = [0]*w
dprow = [0]*h
ypos = []
xpos = []
anscol = 0
ansrow = 0
ans = 0

for i in range(m):
    H, W = map(lambda x: int(x) - 1, input().split())
    dp[H][W] = 1
    dpcol[W] += 1
    dprow[H] += 1

for i in range(w): #列の最大値
    if dpcol[i] > anscol:
        anscol = dpcol[i]
        xpos = [i]
    elif dpcol[i] == anscol:
        xpos.append(i)

for i in range(h):
    if dprow[i] > ansrow:
        ansrow = dprow[i]
        ypos = [i]
    elif dprow[i] == ansrow:
        ypos.append(i)

for i in ypos:
    for j in xpos:
        if dp[i][j] == 1:
            ans = anscol + ansrow - 1
        else:
            ans = anscol + ansrow
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
dp= [[0]*w for i in range(h)]
dpcol = [0]*w
dprow = [0]*h
ypos = []
xpos = []
anscol = 0
ansrow = 0
ans = 0

for i in range(m):
    H, W = map(lambda x: int(x) - 1, input().split())
    dp[H][W] = 1
    dpcol[W] += 1
    dprow[H] += 1

for i in range(w): #列の最大値
    if dpcol[i] > anscol:
        anscol = dpcol[i]
        xpos = [i]
    elif dpcol[i] == anscol:
        xpos.append(i)

for i in range(h):
    if dprow[i] > ansrow:
        ansrow = dprow[i]
        ypos = [i]
    elif dprow[i] == ansrow:
        ypos.append(i)

for i in range(len(ypos)):
    for j in range(len(xpos)):
        if dp[ypos[i]][xpos[j]] == 1:
            ans = anscol + ansrow - 1
        else:
            ans = anscol + ansrow
            print(ans)
            exit()
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
dp= [[0]*W for i in range(H)]
dph = [0]*W
dpw = [0]*H
dphpos = []
dpwpos = []
ansh = 0
answ = 0
ans = 0

for i in range(M):
    h, w = map(lambda x: int(x) - 1, input().split())
    dp[h][w] = 1
    dph[w] += 1
    dpw[h] += 1

for i in range(W): #列の最大値
    if dph[i] > ansh:
        ansh = dph[i]
        dphpos = [i]
    elif dph[i] == ansh:
        dphpos.append(i)

for i in range(H):
    if dpw[i] > answ:
        answ = dpw[i]
        dpwpos = [i]
    elif dpw[i] == answ:
        dpwpos.append(i)

for i in range(len(dphpos)):
    for j in range(len(dpwpos)):
        if dp[dpwpos[j]][dphpos[i]] == 1:
            ans = max(ans, ansh + answ - 1)
        else:
            ans = ansh + answ
print(ans)

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

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

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

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)