Buggy python submission (verdict: Runtime Error):
def resolve():
    h,w,m = map(int, input().split())
    mine = []
    mineh = [0]*h
    minew = [0]*w
    for i in range(m):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        mine.append((a,b))
        mineh[a] += 1
        minew[b] += 1
    mine = set(mine)
    maxh = max(mineh)
    hnum = []
    maxw = max(minew)
    wnum = []
    for i in range(h):
        if mineh[i] == maxh:
            hnum.append(i)
        if minew[i] == maxw:
            wnum.append(i)
    hnum = set(hnum)
    wnum = set(wnum)
    NO = 0
    for i, j in mine:
        if i in hnum and j in wnum:
            NO += 1
    if len(hnum)*len(wnum) > NO:
        print(maxw+maxh)
    else:
        print(maxw+maxh-1)
resolve()

Fixed submission:
def resolve():
    h,w,m = map(int, input().split())
    mine = []
    mineh = [0]*h
    minew = [0]*w
    for i in range(m):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        mine.append((a,b))
        mineh[a] += 1
        minew[b] += 1
    mine = set(mine)
    maxh = max(mineh)
    hnum = []
    maxw = max(minew)
    wnum = []
    for i in range(h):
        if mineh[i] == maxh:
            hnum.append(i)
    for i in range(w):
        if minew[i] == maxw:
            wnum.append(i)
    hnum = set(hnum)
    wnum = set(wnum)
    NO = 0
    for i, j in mine:
        if i in hnum and j in wnum:
            NO += 1
    if len(hnum)*len(wnum) > NO:
        print(maxw+maxh)
    else:
        print(maxw+maxh-1)
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    h,w,m = map(int, input().split())
    mine = []
    mineh = [0]*h
    minew = [0]*w
    for i in range(m):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        mine.append((a,b))
        mineh[a] += 1
        minew[b] += 1
    mine = set(mine)
    maxh = max(mineh)
    hnum = []
    maxw = max(minew)
    wnum = []
    for i in range(h):
        if mineh[i] == maxh:
            hnum.append(i)
        if minew[i] == maxw:
            wnum.append(i)
    for i in hnum:
        for j in wnum:
            if [i,j] in mine:
                continue
            else:
                print(maxw+maxh)
                exit()
    print(maxw+maxh-1)
resolve()

Fixed submission:
def resolve():
    h,w,m = map(int, input().split())
    mine = []
    mineh = [0]*h
    minew = [0]*w
    for i in range(m):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        mine.append((a,b))
        mineh[a] += 1
        minew[b] += 1
    mine = set(mine)
    maxh = max(mineh)
    hnum = []
    maxw = max(minew)
    wnum = []
    for i in range(h):
        if mineh[i] == maxh:
            hnum.append(i)
    for i in range(w):
        if minew[i] == maxw:
            wnum.append(i)
    hnum = set(hnum)
    wnum = set(wnum)
    NO = 0
    for i, j in mine:
        if i in hnum and j in wnum:
            NO += 1
    if len(hnum)*len(wnum) > NO:
        print(maxw+maxh)
    else:
        print(maxw+maxh-1)
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    h,w,m = map(int, input().split())
    mine = []
    mineh = [0]*h
    minew = [0]*w
    for i in range(m):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        mine.append([a,b])
        mineh[a] += 1
        minew[b] += 1
    maxh = max(mineh)
    hnum = []
    maxw = max(minew)
    wnum = []
    for i in range(h):
        if mineh[i] == maxh:
            hnum.append(i)
        if minew[i] == maxw:
            wnum.append(i)
    for i in hnum:
        for j in wnum:
            if [i,j] in mine:
                continue
            else:
                print(maxw+maxh)
                exit()
    print(maxw+maxh-1)
resolve()

Fixed submission:
def resolve():
    h,w,m = map(int, input().split())
    mine = []
    mineh = [0]*h
    minew = [0]*w
    for i in range(m):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        mine.append((a,b))
        mineh[a] += 1
        minew[b] += 1
    mine = set(mine)
    maxh = max(mineh)
    hnum = []
    maxw = max(minew)
    wnum = []
    for i in range(h):
        if mineh[i] == maxh:
            hnum.append(i)
    for i in range(w):
        if minew[i] == maxw:
            wnum.append(i)
    hnum = set(hnum)
    wnum = set(wnum)
    NO = 0
    for i, j in mine:
        if i in hnum and j in wnum:
            NO += 1
    if len(hnum)*len(wnum) > NO:
        print(maxw+maxh)
    else:
        print(maxw+maxh-1)
resolve()