Language: C++

#include <iostream>
#include <set>
#include <algorithm>
 
using namespace std;

#define int long long; 

int main() {
    int W, H;
    cin >> W >> H;
    set<pair<int, bool>> S;
    for (int i = 0; i < W; i++) {
        int k;
        cin >> k;
        S.insert(make_pair(k, true));
    }
    for (int i = 0; i < H; i++) {
        int k;
        cin >> k;
        S.insert(make_pair(k, false));
    }
   
    long long res = 0;
    W++; H++;
    while (!S.empty()) {
        auto it = S.begin();
        if (it->second) {
            res += max(H, 0) * it->first;
            W--;
        } else {
            res += max(W, 0) * it->first;
            H--;
        }
        S.erase(S.begin());
    }
    cout << res << endl;
}


Compiler output:
a.cc:7:18: error: declaration does not declare anything [-fpermissive]
    7 | #define int long long;
      |                  ^~~~
a.cc:9:1: note: in expansion of macro 'int'
    9 | int main() {
      | ^~~
a.cc:9:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:7:18: error: declaration does not declare anything [-fpermissive]
    7 | #define int long long;
      |                  ^~~~
a.cc:10:5: note: in expansion of macro 'int'
   10 |     int W, H;
      |     ^~~
a.cc:10:9: error: 'W' was not declared in this scope
   10 |     int W, H;
      |         ^
a.cc:10:12: error: 'H' was not declared in this scope
   10 |     int W, H;
      |            ^
a.cc:7:18: error: wrong number of template arguments (1, should be 2)
    7 | #define int long long;
      |                  ^~~~
a.cc:12:14: note: in expansion of macro 'int'
   12 |     set<pair<int, bool>> S;
      |              ^~~
In file included from /usr/include/c++/14/string:48,
                 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,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:12:9: error: template argument 1 is invalid
   12 |     set<pair<int, bool>> S;
      |         ^
a.cc:12:9: error: template argument 2 is invalid
a.cc:12:9: error: template argument 3 is invalid
a.cc:12:17: error: expected primary-expression before ',' token
   12 |     set<pair<int, bool>> S;
      |                 ^
a.cc:12:19: error: expected primary-expression before 'bool'
   12 |     set<pair<int, bool>> S;
      |                   ^~~~
a.cc:7:18: error: declaration does not declare anything [-fpermissive]
    7 | #define int long long;
      |                  ^~~~
a.cc:13:10: note: in expansion of macro 'int'
   13 |     for (int i = 0; i < W; i++) {
      |          ^~~
a.cc:13:14: error: 'i' was not declared in this scope
   13 |     for (int i = 0; i < W; i++) {
      |              ^
a.cc:13:26: error: expected ')' before ';' token
   13 |     for (int i = 0; i < W; i++) {
      |         ~                ^
      |                          )
a.cc:13:28: error: 'i' was not declared in this scope
   13 |     for (int i = 0; i < W; i++) {
      |                            ^
a.cc:7:18: error: declaration does not declare anything [-fpermissive]
    7 | #define int long long;
      |                  ^~~~
a.cc:18:10: note: in expansion of macro 'int'
   18 |     for (int i = 0; i < H; i++) {
      |          ^~~
a.cc:18:26: error: expected ')' before ';' token
   18 |     for (int i = 0; i < H; i++) {
      |         ~                ^
      |                          )
a.cc:26:13: error: 'S' was not declared in this scope
   26 |     while (!S.empty()) {
      |             ^