Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const  long long mod = 1007050321;
const  long long base = 521;
const  long long N = 2e5 + 5;
const  long long MOD = 1e9 + 7;
const  long long inf = 2e9;

 long long x,y,a,b,c;
pair < long long, long long> p[N],q[N];
 long long r[N];

bool cmp (pair < long long, long long> a,pair < long long, long long> b) {
    if (a.fi == b.fi)
        return a.se > b.se;
    return a.fi > b.fi;
}

 main() {
    ios_base :: sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin >> x >> y >> a >> b >> c;
    for ( long long i = 1; i <= a; ++i)
        cin >> p[i].fi,p[i].se = 1;
    for ( long long i = 1; i <= b; ++i)
        cin >> q[i].fi,q[i].se = 1;
    for ( long long i = 1; i <= c; ++i)
        cin >> r[i];
    for ( long long i = 1; i <= c; ++i) {
        p[i+a] = {r[i],0};
        q[i+b] = {r[i],0};
    }

    sort(p+1,p+1+a+c,cmp);
    sort(q+1,q+1+b+c,cmp);

     long long ans = 0,dem1 = 0,dem2 = 0;
     long long po long longer = 1;
    for ( long long i = 1; i <= a + c; ++i) {
        if (dem1 == x)
            break;
        if (p[i].se == 1)
            ans += p[i].fi,dem1++;
        else {
            while (q[po long longer].se == 1 && dem2 < y && po long longer <= b+c)
                ans += q[po long longer++].fi,dem2++;
            if (a+c-i <= b+c-po long longer)
                ans += q[po long longer++].fi,dem2++;
            else
                ans += q[i].fi,dem1++;
        }
    }

    while (dem2 < y)
        ans += q[po long longer++].fi,dem2++;

    cout << ans;

    return 0;
}


Compiler output:
a.cc:23:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 |  main() {
      |  ^~~~
a.cc: In function 'int main()':
a.cc:42:19: error: expected initializer before 'long'
   42 |      long long po long longer = 1;
      |                   ^~~~
a.cc:49:22: error: 'po' was not declared in this scope; did you mean 'pow'?
   49 |             while (q[po long longer].se == 1 && dem2 < y && po long longer <= b+c)
      |                      ^~
      |                      pow
a.cc:49:24: error: expected ']' before 'long'
   49 |             while (q[po long longer].se == 1 && dem2 < y && po long longer <= b+c)
      |                        ^~~~~
      |                        ]
a.cc:49:24: error: expected ')' before 'long'
   49 |             while (q[po long longer].se == 1 && dem2 < y && po long longer <= b+c)
      |                   ~    ^~~~~
      |                        )
a.cc:49:36: error: expected initializer before ']' token
   49 |             while (q[po long longer].se == 1 && dem2 < y && po long longer <= b+c)
      |                                    ^
a.cc:51:30: error: 'po' was not declared in this scope; did you mean 'pow'?
   51 |             if (a+c-i <= b+c-po long longer)
      |                              ^~
      |                              pow
a.cc:51:32: error: expected ')' before 'long'
   51 |             if (a+c-i <= b+c-po long longer)
      |                ~               ^~~~~
      |                                )
a.cc:52:28: error: expected ']' before 'long'
   52 |                 ans += q[po long longer++].fi,dem2++;
      |                            ^~~~~
      |                            ]
a.cc:59:18: error: 'po' was not declared in this scope; did you mean 'pow'?
   59 |         ans += q[po long longer++].fi,dem2++;
      |                  ^~
      |                  pow
a.cc:59:20: error: expected ']' before 'long'
   59 |         ans += q[po long longer++].fi,dem2++;
      |                    ^~~~~
      |                    ]