Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:
            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)

    print(result)


calculate(H, W, M, ARR)


Fixed submission:
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)

Buggy python submission (verdict: Runtime Error):
import numpy as np

# H, W, M = 3, 3, 4
# ARR = [
#     [3, 3],
#     [3, 1],
#     [1, 1],
#     [1, 2],
# ]

H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    srr = np.zeros((h, w))

    for i in range(m):
        c0 = arr[i][0] - 1
        c1 = arr[i][1] - 1
        srr[c0][c1] = 1

    res0 = np.sum(srr, axis=0)
    res1 = np.sum(srr, axis=1)

    res0Max = np.max(res0)
    res1Max = np.max(res1)
    res0MaxIndex = np.argwhere(res0 == res0Max)
    res1MaxIndex = np.argwhere(res1 == res1Max)

    result = 0

    for mH in res1MaxIndex:
        for mW in res0MaxIndex:
            result = max(result,res0Max + res1Max - srr[mH[0]][mW[0]])

    print(int(result))

calculate(H, W, M, ARR)

Fixed submission:
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)

Buggy python submission (verdict: Runtime Error):
import numpy as np

H, W, M = 5, 5, 10
ARR = [
    [2, 5],
    [4, 3],
    [2, 3],
    [5, 5],
    [2, 2],
    [5, 4],
    [5, 3],
    [5, 1],
    [3, 5],
    [1, 4]
]

H, W, M = map(int,input().split())
ARR = []
for i in range(M):
    ARR.append(list(map(int,input().split())))


# H, W, M = 2, 3, 3
# ARR = [
#     [2, 2],
#     [1, 1],
#     [1, 3]
# ]


def calculate(h, w, m, arr):
    srr = np.zeros((h,w))

    for ar in arr:
        h = ar[0] - 1
        w = ar[1] - 1
        srr[h][w] = 1

    res1 = np.sum(srr, axis=1)

    largestHIndex = np.argmax(res1)

    res2 = np.sum(srr, axis=0)
    trr = res2 - srr[largestHIndex]

    largestWIndex = np.argmax(trr)
    print(int(trr[largestWIndex] + res1[largestHIndex]))

calculate(H, W, M, ARR)


Fixed submission:
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)

Buggy python submission (verdict: Runtime Error):
import numpy as np

H, W, M = 5, 5, 10
ARR = [
    [2, 5],
    [4, 3],
    [2, 3],
    [5, 5],
    [2, 2],
    [5, 4],
    [5, 3],
    [5, 1],
    [3, 5],
    [1, 4]
]

H, W, M = map(int,input().split())
ARR = []
for i in range(M):
    ARR.append(list(map(int,input().split())))


# H, W, M = 2, 3, 3
# ARR = [
#     [2, 2],
#     [1, 1],
#     [1, 3]
# ]


def calculate(h, w, m, arr):
    srr = np.zeros((h,w))

    for ar in arr:
        h = ar[0] - 1
        w = ar[1] - 1
        srr[h][w] = 1

    res1 = np.sum(srr, axis=1)

    largestHIndex = np.argmax(res1)

    res2 = np.sum(srr, axis=0)
    trr = res2 - srr[largestHIndex]

    largestWIndex = np.argmax(trr)
    print(int(trr[largestWIndex] + res1[largestHIndex]))

calculate(H, W, M, ARR)


Fixed submission:
H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)