Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[]:
    X=w-max(xmin)
elif ymax==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0) 


Fixed submission:
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[] and xmin==[]:
    X=w
elif xmax==[]:
    X=w-max(xmin)
elif xmin==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[] and ymin==[]:
    Y=h
elif ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0)

Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]
for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])
if xmax==[]:
    X=w-max(xmin)
elif ymax==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0) 


Fixed submission:
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[] and xmin==[]:
    X=w
elif xmax==[]:
    X=w-max(xmin)
elif xmin==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[] and ymin==[]:
    Y=h
elif ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0)

Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]
for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])
X=min(xmax)-max(xmin)
Y=min(ymax)-max(ymin)
print(X*Y) if (X > 0 and Y > 0) else print(0) 


Fixed submission:
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[] and xmin==[]:
    X=w
elif xmax==[]:
    X=w-max(xmin)
elif xmin==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[] and ymin==[]:
    Y=h
elif ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0)