Language: C++

#include<iostream>

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int left = 0;
  int right = W;
  int bottom = 0;
  int top = H;
  for(int i=0; i<N; i++){
    int x, y, a;
    cin >> x >> y >> a;
    switch(a){
      case 1:
        left = max(left, x);
      case 2:
        right = min(right, x);
      case 3:
        bottom = max(bottom, y);
      case 4:
        bottom = min(bottom, y);
  }
  if(right-left<0 || top-bottom<0){
    cout << 0 << endl;
  }else{
    cout << (right-left)*(top-bottom) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin >> W >> H >> N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:15:16: error: 'max' was not declared in this scope; did you mean 'std::max'?
   15 |         left = max(left, x);
      |                ^~~
      |                std::max
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:17:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   17 |         right = min(right, x);
      |                 ^~~
      |                 std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:24:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |     cout << 0 << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   24 |     cout << 0 << endl;
      |                  ^~~~
      |                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:26:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |     cout << (right-left)*(top-bottom) << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:26:42: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |     cout << (right-left)*(top-bottom) << endl;
      |                                          ^~~~
      |                                          std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^