Problem p02580 (python)

Fixed submission:
from collections import defaultdict

H, W, M = map(int, input().split())
h = [0] * M
w = [0] * M

nh = [0] * H  # number of h == i+1
nw = [0] * W  # number of w == i+1
dic = defaultdict(bool)

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1
    dic["{}-{}".format(h[i],w[i])] = True

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

for h1 in mh:
    for w1 in mw:
        if not dic["{}-{}".format(h1,w1)]:
            print(mnh + mnw)
            exit()
print(mnh + mnw - 1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M

nh = [0] * M # number of h == i+1
nw = [0] * M # number of w == i+1

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

hw = list(zip(h,w))
for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in hw:
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M

nh = [0] * M # number of h == i+1
nw = [0] * M # number of w == i+1

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

hw = list(zip(h,w))
for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in hw:
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M

nh = [0] * M # number of h == i+1
nw = [0] * M # number of w == i+1

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

hw = list(zip(h,w))
for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in hw:
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M

nh = [0] * M # number of h == i+1
nw = [0] * M # number of w == i+1

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in zip(h,w):
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M

nh = [0] * M # number of h == i+1
nw = [0] * M # number of w == i+1

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in zip(h,w):
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)

Buggy submission (verdict: Runtime Error):
import collections

H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M
for i in range(M):
    h[i], w[i] = map(int, input().split())
ch = collections.Counter(h).most_common()
mh = [ch[0][0]]
mnh = ch[0][1]
for i in range(1,len(ch)):
    if mnh == ch[i][1]:
        mh.append(ch[i][0])
        continue
    else:
        break
    break
cw = collections.Counter(w).most_common()
mw = [cw[0][0]]
mnw = cw[0][1]
for i in range(1,len(mh)):
    if mnw == cw[i][1]:
        mw.append(cw[i][0])
        continue
    else:
        break
    break
for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in zip(h,w):
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)

Buggy submission (verdict: Runtime Error):
import collections

H,W,M = map(int, input().split())
h = [0]*M
w = [0]*M
for i in range(M):
    h[i], w[i] = map(int, input().split())
ch = collections.Counter(h).most_common()
mh = [ch[0][0]]
mnh = ch[0][1]
for i in range(1,len(ch)):
    if mnh == ch[i][1]:
        mh.append(ch[i][0])
        continue
    else:
        break
    break
cw = collections.Counter(w).most_common()
mw = [cw[0][0]]
mnw = cw[0][1]
for i in range(1,len(mh)):
    if mnw == cw[i][1]:
        mw.append(cw[i][0])
        continue
    else:
        break
    break
for h1 in mh:
    for w1 in mw:
        if (h1,w1) not in zip(h,w):
            print(mnh+mnw)
            exit()
print(mnh+mnw-1)