Buggy python submission (verdict: Time Limit Exceeded):
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

W, H, N = map(int, input().split())
X = []
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    for z in range(1,x+1):
      for j in range(1,H+1):
        X.append([z,j])
        X = get_unique_list(X)
  elif a == 2:
    for z in range(x+1,W+1):
      for j in range(1,H+1):
        X.append([z,j])
        X = get_unique_list(X)
  elif a == 3:
    for z in range(1,y+1):
      for i in range(1,W+1):
        X.append([i,z])
        X = get_unique_list(X)
  else:
    for z in range(y+1,H+1):
      for i in range(1,W+1):
        X.append([i,z])
        X = get_unique_list(X)
print(W*H - len(get_unique_list(X)))

Fixed submission:
W, H, N = map(int, input().split())
X = [0, 0, W, 0, H]
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    X[a] = max(x,X[a])
  elif a == 2:
    X[a] = min(x,X[a])
  elif a == 3:
    X[a] = max(y,X[a])
  else:
    X[a] = min(y,X[a])
tate = X[4] - X[3]
yoko = X[2] - X[1]
ans = tate*yoko
if tate<0 or yoko<0:
  print(0)
else:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
W, H, N = map(int, input().split())
X = []
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    for z in range(1,x+1):
      for j in range(1,H+1):
        X.append([z,j])
  elif a == 2:
    for z in range(x+1,W+1):
      for j in range(1,H+1):
        X.append([z,j])
  elif a == 3:
    for z in range(1,y+1):
      for i in range(1,W+1):
        X.append([i,z])
  else:
    for z in range(y+1,H+1):
      for i in range(1,W+1):
        X.append([i,z])
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
print(W*H - len(get_unique_list(X)))

Fixed submission:
W, H, N = map(int, input().split())
X = [0, 0, W, 0, H]
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    X[a] = max(x,X[a])
  elif a == 2:
    X[a] = min(x,X[a])
  elif a == 3:
    X[a] = max(y,X[a])
  else:
    X[a] = min(y,X[a])
tate = X[4] - X[3]
yoko = X[2] - X[1]
ans = tate*yoko
if tate<0 or yoko<0:
  print(0)
else:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
W, H, N = map(int, input().split())
X = []
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    for z in range(1,x+1):
      for j in range(1,H+1):
        if [z,j] not in X:
          X.append([z,j])
  elif a == 2:
    for z in range(x+1,W+1):
      for j in range(1,H+1):
        if [z,j] not in X:
          X.append([z,j])
  elif a == 3:
    for z in range(1,y+1):
      for i in range(1,W+1):
        if [i,z] not in X:
          X.append([i,z])
  else:
    for z in range(y+1,H+1):
      for i in range(1,W+1):
        if [i,z] not in X:
          X.append([i,z])
print(W*H - len(X))

Fixed submission:
W, H, N = map(int, input().split())
X = [0, 0, W, 0, H]
for k in range(N):
  x,y,a = map(int, input().split())
  if a == 1:
    X[a] = max(x,X[a])
  elif a == 2:
    X[a] = min(x,X[a])
  elif a == 3:
    X[a] = max(y,X[a])
  else:
    X[a] = min(y,X[a])
tate = X[4] - X[3]
yoko = X[2] - X[1]
ans = tate*yoko
if tate<0 or yoko<0:
  print(0)
else:
  print(ans)