Problem p02580 (python)

Fixed submission:
H,W,M = list(map(int, input().split()))

hw = set()
w = [0] * 3*10**5
h = [0] * 3*10**5

for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.add((h_i-1) + (w_j-1)*3*10**6)
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = max(h)
mxw_v = max(w)

x = [i for i,j in enumerate(h) if j == mxh_v]
y = [i for i,j in enumerate(w) if j == mxw_v]

for i in x:
    for j in y:
        if not(i + j*3*10**6 in hw):
            print(mxh_v+mxw_v)
            exit()
print(mxh_v+mxw_v-d)

Buggy submission (verdict: Runtime Error):
H,W,M = list(map(int, input().split()))

hw = set()
w = [0] * 3*10**5
h = [0] * 3*10**5

for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.add([h_i-1, w_j-1])
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = max(h)
mxw_v = max(w)

x = [i for i,j in enumerate(h) if j == mxh_v]
y = [i for i,j in enumerate(w) if j == mxw_v]

for i in x:
    for j in y:
        if not([i,j] in hw):
            print(mxh_v+mxw_v)
            exit()
print(mxh_v+mxw_v-d)

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

read = sys.stdin.buffer.read

H,W,M = list(map(int, input().split()))

hw = []
# w = np.zeros(3*10**5,dtype=np.int64)
# h = np.zeros(3*10**5,dtype=np.int64)
w = [0] * 3*10**5
h = [0] * 3*10**5

for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.append([h_i-1, w_j-1])
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = max(h)
mxw_v = max(w)

x = [i for i,j in enumerate(h) if j == mxh_v]
y = [i for i,j in enumerate(w) if j == mxw_v]

for i in x:
    for j in y:
        if not([i,j] in hw):
            d = 0
    if d == 0:
        break
print(mxh_v+mxw_v-d)

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

read = sys.stdin.buffer.read

H,W,M = list(map(int, input().split()))

hw = np.zeros((3*10**5,3*10**5),dtype=np.int64)
w = np.zeros(3*10**5,dtype=np.int64)
h = np.zeros(3*10**5,dtype=np.int64)
 
for i in range(M):
    h_i, w_j = map(int, input().split())
    hw[h_i-1, w_j-1] = 1
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 0
for i in np.where(h==h.max())[0]:
    for j in np.where(w==w.max())[0]:
        mxh_v = h[i]
        mxw_v = w[j]
        d = hw[i, j]
        # print(i,j,a, mxh_v , mxw_v , d)
        a = max(a, mxh_v + mxw_v - d)
    if d == 0:
        break
print(a)

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

read = sys.stdin.buffer.read

H,W,M = list(map(int, input().split()))

hw = np.zeros((H+1,W+1),dtype=np.int64)
w = np.zeros(3*10**5,dtype=np.int64)
h = np.zeros(3*10**5,dtype=np.int64)
 
for i in range(M):
    h_i, w_j = map(int, input().split())
    hw[h_i-1, w_j-1] = 1
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 0
for i in np.where(h==h.max())[0]:
    for j in np.where(w==w.max())[0]:
        mxh_v = h[i]
        mxw_v = w[j]
        d = hw[i, j]
        # print(i,j,a, mxh_v , mxw_v , d)
        a = max(a, mxh_v + mxw_v - d)
    if d == 0:
        break
print(a)

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

read = sys.stdin.buffer.read

H,W,M = list(map(int, input().split()))

hw = np.zeros((H+1,W+1),dtype=np.int64)
w = np.zeros(3*10**5,dtype=np.int64)
h = np.zeros(3*10**5,dtype=np.int64)
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i, w_j] = 1
    h[h_i] += 1
    w[w_j] += 1

a = 0
d = 0
for i in np.where(h==h.max())[0]:
    for j in np.where(w==w.max())[0]:
        mxh_v = h[i]
        mxw_v = w[j]
        d = hw[i, j]
        # print(i,j,a, mxh_v , mxw_v , d)
        a = max(a, mxh_v + mxw_v - d)
    if d == 0:
        break
print(a)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
 
H,W,M = list(map(int, input().split()))

hw = np.zeros((H+1,W+1),dtype=np.int32)
w = np.zeros(W+1,dtype=np.int32)
h = np.zeros(H+1,dtype=np.int32)
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i, w_j] = 1
    h[h_i] += 1
    w[w_j] += 1

a = 0
d = 0
for i in np.where(h==h.max())[0]:
    for j in np.where(w==w.max())[0]:
        mxh_v = h[i]
        mxw_v = w[j]
        d = hw[i, j]
        # print(i,j,a, mxh_v , mxw_v , d)
        a = max(a, mxh_v + mxw_v - d)
    if d == 0:
        break
print(a)

Buggy submission (verdict: Runtime Error):
import sys
 
H,W,M = list(map(int, input().split()))

hw = [[0] * (W+1) for _ in range(H+1)]
 
w = [0] * (W+1)
h = [0] * (H+1)
mxw = []
mxw_v = 0
mxh = []
mxh_v = 0
 
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1
    if mxw_v < w[w_j]:
        mxw_v = w[w_j]
        mxw = [w_j]
    elif mxw_v == w[w_j]:
        mxw.append(w_j)
 
    if mxh_v < h[h_i]:
        mxh_v = h[h_i]
        mxh = [h_i]
    elif mxh_v == h[h_i]:
        mxh.append(h_i)
a = 0
d = 0
for i in mxh:
    for j in mxw:
        d = hw[i][j]
        a = max(a, mxh_v + mxw_v - d)
    if d == 0:
        break
print(a)

Buggy submission (verdict: Runtime Error):
import sys
 
H,W,M = list(map(int, input().split()))

hw = [[0] * (W+1) for _ in range(H+1)]
 
w = [0] * (W+1)
h = [0] * (H+1)
mxw = []
mxw_v = 0
mxh = []
mxh_v = 0
 
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1
    if mxw_v < w[w_j]:
        mxw_v = w[w_j]
        mxw = [w_j]
    elif mxw_v == w[w_j]:
        mxw.append(w_j)
 
    if mxh_v < h[h_i]:
        mxh_v = h[h_i]
        mxh = [h_i]
    elif mxh_v == h[h_i]:
        mxh.append(h_i)
a = 0
for i in mxh:
    for j in mxw:
        d = hw[i][j]
        a = max(a, mxh_v + mxw_v - d)
print(a)

Buggy submission (verdict: Runtime Error):
import sys
 
H,W,M = list(map(int, input().split()))
U = 3 * 10**5
hw = [[0] * (U) for _ in range(U)]
 
w = [0] * (U)
h = [0] * (U)
mxw = []
mxw_v = 0
mxh = []
mxh_v = 0
 
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1
    if mxw_v < w[w_j]:
        mxw_v = w[w_j]
        mxw = [w_j]
    elif mxw_v == w[w_j]:
        mxw.append(w_j)
 
    if mxh_v < h[h_i]:
        mxh_v = h[h_i]
        mxh = [h_i]
    elif mxh_v == h[h_i]:
        mxh.append(h_i)
a = 0
for i in mxh:
    for j in mxw:
        d = hw[i][j]
        a = max(a, mxh_v + mxw_v - d)
print(a)

Buggy submission (verdict: Runtime Error):
import sys
 
H,W,M = list(map(int, input().split()))
U = 3 * 10**5
hw = [[0] * (U) for _ in range(U)]
 
w = [0] * (U)
h = [0] * (U)
mxw = []
mxw_v = 0
mxh = []
mxh_v = 0
 
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1
    if mxw_v < w[w_j]:
        mxw_v = w[w_j]
        mxw = [w_j]
    elif mxw_v == w[w_j]:
        mxw.append(w_j)
 
    if mxh_v < h[h_i]:
        mxh_v = h[h_i]
        mxh = [h_i]
    elif mxh_v == h[h_i]:
        mxh.append(h_i)
a = 0
for i in mxh:
    for j in mxw:
        d = hw[i][j]
        a = max(a, h[i]+w[j]-d)
print(a)

Buggy submission (verdict: Runtime Error):
import sys
 
H,W,M = list(map(int, input().split()))
 
hw = [[0] * (W+30) for _ in range(H+30)]
 
w = [0] * (W+1)
h = [0] * (H+1)
mxw = []
mxw_v = 0
mxh = []
mxh_v = 0
 
 
for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1
    if mxw_v < w[w_j]:
        mxw_v = w[w_j]
        mxw = [w_j]
    elif mxw_v == w[w_j]:
        mxw.append(w_j)
 
    if mxh_v < h[h_i]:
        mxh_v = h[h_i]
        mxh = [h_i]
    elif mxh_v == h[h_i]:
        mxh.append(h_i)

a = 0
for i in mxh:
    for j in mxw:
        d = hw[i][j]
        a = max(a, h[i]+w[j]-d)
print(a)

Buggy submission (verdict: Runtime Error):
import sys

H,W,M = list(map(int, input().split()))

hw = [[0] * (W+1) for _ in range(H+1)]

w = [0] * (W+1)
h = [0] * (H+1)
mxw = []
mxw_v = 0
mxh = []
mxh_v = 0


for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1
    if mxw_v < w[w_j]:
        mxw_v = w[w_j]
        mxw = [w_j]
    elif mxw_v == w[w_j]:
        mxw.append(w_j)

    if mxh_v < h[h_i]:
        mxh_v = h[h_i]
        mxh = [h_i]
    elif mxh_v == h[h_i]:
        mxh.append(h_i)

a = 0
for i in mxh:
    for j in mxw:
        d = hw[i][j]
        a = max(a, h[i]+w[j]-d)
print(a)

Buggy submission (verdict: Runtime Error):
import sys

H,W,M = list(map(int, input().split()))

hw = [[0] * (W+1) for _ in range(H+1)]

w = [0] * (W+1)
h = [0] * (H+1)


for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i][w_j] = 1
    h[h_i] += 1
    w[w_j] += 1

a = 0
for i in [i for i, x in enumerate(h) if x == max(h)]:
    for j in [j for j, y in enumerate(w) if y == max(w)]:
        d = hw[i][j]
        a = max(a, h[i]+w[j]-d)
print(a)

Buggy submission (verdict: Runtime Error):
import sys

H,W,M = list(map(int, input().split()))

hw = [[0] * W for _ in range(H)]

w = [0] * W
h = [0] * H

for i in range(M):
    h_i, w_j = list(map(int, input().split()))
    hw[h_i-1][w_j-1] = 1
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
for i in range(H):
    for j in range(W):
        d = hw[i][j]
        a = max(a, h[i]+w[j]-d)
print(a)