Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H,W,M = map(int,input().split())
    list = []
    dict_H = {key:0 for key in range(1,H+1,1)}
    dict_W = {key:0 for key in range(1,W+1,1)}
    for i in range(M):
        h,w = map(int,input().split())
        dict_H[h] += 1
        dict_W[w] += 1
        list.append((h,w))
    #print(list)
    maxH = max(dict_H.values())
    maxW = max(dict_W.values())
    wi = [i for i in range(1,W+1,1) if dict_W[i] == maxW]
    #print(retuH,gyoW,wi)
    for h in [i for i in range(1,H+1,1) if dict_H[i] == maxH]:
        for w in wi:
            if ((h,w) not in list):
                return maxH + maxW
    return maxH + maxW -1

print(main())


Fixed submission:
def main():
    H,W,M = map(int,input().split())
    dict_gyo = {key: 0 for key in range(H)}
    dict_retu = {key: 0 for key in range(W)}
    dict_ichi = {}
    for i in range(M):
        h,w = map(int,input().split())
        dict_gyo[h-1] += 1
        dict_retu[w-1] += 1
        dict_ichi[(h-1,w-1)] = 1

    #print(dict_gyo,dict_ichi)

    maxgyo = max(dict_gyo.values())
    maxretu = max(dict_retu.values())
    #maxgyo_k = max(dict_gyo, key = dict_gyo.get)
    #maxretu_k = max(dict_retu, key = dict_gyo.get)
    #print(maxgyo_k,maxretu_k)
    result = maxgyo + maxretu - 1
    wi = [i for i in range(W) if dict_retu[i] == maxretu]
    for h in [i for i in range(H) if dict_gyo[i] == maxgyo]:
        for w in wi:
            if (h,w) not in dict_ichi:
                result = maxgyo + maxretu
                return result

    return result




print(main())

Buggy python submission (verdict: Runtime Error):
def main():
    H,W,M = map(int,input().split())
    list = []
    dict_H = {key:0 for key in range(1,H+1,1)}
    dict_W = {key:0 for key in range(1,W+1,1)}
    for i in range(M):
        h,w = map(int,input().split())
        dict_H[h] += 1
        dict_W[w] += 1
        list.append((h,w))
    #print(list)
    maxH = max(dict_H.values())
    maxW = max(dict_W.values())
    wi = [i for i in range(1,W+1,1) if dict_H[i] == maxW]
    #print(retuH,gyoW,wi)
    for h in [i for i in range(1,H+1,1) if dict_W[i] == maxH]:
        for w in wi:
            if ((h,w) not in list):
                return maxH + maxW
    return maxH + maxW -1

print(main())


Fixed submission:
def main():
    H,W,M = map(int,input().split())
    dict_gyo = {key: 0 for key in range(H)}
    dict_retu = {key: 0 for key in range(W)}
    dict_ichi = {}
    for i in range(M):
        h,w = map(int,input().split())
        dict_gyo[h-1] += 1
        dict_retu[w-1] += 1
        dict_ichi[(h-1,w-1)] = 1

    #print(dict_gyo,dict_ichi)

    maxgyo = max(dict_gyo.values())
    maxretu = max(dict_retu.values())
    #maxgyo_k = max(dict_gyo, key = dict_gyo.get)
    #maxretu_k = max(dict_retu, key = dict_gyo.get)
    #print(maxgyo_k,maxretu_k)
    result = maxgyo + maxretu - 1
    wi = [i for i in range(W) if dict_retu[i] == maxretu]
    for h in [i for i in range(H) if dict_gyo[i] == maxgyo]:
        for w in wi:
            if (h,w) not in dict_ichi:
                result = maxgyo + maxretu
                return result

    return result




print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H,W,M = map(int,input().split())
    list = []
    retuH = [0]*(H+1)
    gyoW = [0]*(W+1)
    for i in range(M):
        h,w = map(int,input().split())
        retuH[h] += 1
        gyoW[w] += 1
        list.append((h,w))
    #print(list)
    maxH = max(retuH)
    maxW = max(gyoW)
    wi = [i for i in range(1,W+1,1) if gyoW[i] == maxW]

    for h in [i for i in range(1,H+1,1) if retuH[i] == maxH]:
        for w in wi:
            if ((h,w) not in list):
                return maxH + maxW
    return maxH + maxW -1

print(main())


Fixed submission:
def main():
    H,W,M = map(int,input().split())
    dict_gyo = {key: 0 for key in range(H)}
    dict_retu = {key: 0 for key in range(W)}
    dict_ichi = {}
    for i in range(M):
        h,w = map(int,input().split())
        dict_gyo[h-1] += 1
        dict_retu[w-1] += 1
        dict_ichi[(h-1,w-1)] = 1

    #print(dict_gyo,dict_ichi)

    maxgyo = max(dict_gyo.values())
    maxretu = max(dict_retu.values())
    #maxgyo_k = max(dict_gyo, key = dict_gyo.get)
    #maxretu_k = max(dict_retu, key = dict_gyo.get)
    #print(maxgyo_k,maxretu_k)
    result = maxgyo + maxretu - 1
    wi = [i for i in range(W) if dict_retu[i] == maxretu]
    for h in [i for i in range(H) if dict_gyo[i] == maxgyo]:
        for w in wi:
            if (h,w) not in dict_ichi:
                result = maxgyo + maxretu
                return result

    return result




print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H,W,M = map(int,input().split())
    list = []
    retuH = [0]*(H+1)
    gyoW = [0]*(W+1)
    for i in range(M):
        h,w = map(int,input().split())
        retuH[h] += 1
        gyoW[w] += 1
        list.append((h,w))
    #print(list)
    maxH = max(retuH)
    maxW = max(gyoW)

    for h in [i for i in range(1,H+1,1) if retuH[i] == maxH]:
        for w in [i for i in range(1,W+1,1) if gyoW[i] == maxW]:
            if ((h,w) not in list):
                return maxH + maxW
    return maxH + maxW -1

print(main())


Fixed submission:
def main():
    H,W,M = map(int,input().split())
    dict_gyo = {key: 0 for key in range(H)}
    dict_retu = {key: 0 for key in range(W)}
    dict_ichi = {}
    for i in range(M):
        h,w = map(int,input().split())
        dict_gyo[h-1] += 1
        dict_retu[w-1] += 1
        dict_ichi[(h-1,w-1)] = 1

    #print(dict_gyo,dict_ichi)

    maxgyo = max(dict_gyo.values())
    maxretu = max(dict_retu.values())
    #maxgyo_k = max(dict_gyo, key = dict_gyo.get)
    #maxretu_k = max(dict_retu, key = dict_gyo.get)
    #print(maxgyo_k,maxretu_k)
    result = maxgyo + maxretu - 1
    wi = [i for i in range(W) if dict_retu[i] == maxretu]
    for h in [i for i in range(H) if dict_gyo[i] == maxgyo]:
        for w in wi:
            if (h,w) not in dict_ichi:
                result = maxgyo + maxretu
                return result

    return result




print(main())