Language: C

/*
とりあえずソースコード見る前に推し見ていってください。
                                                                                   ` ....J&wZTUUWc
                                                                             `...JZY"!~-._<~~~~_d'
                                                                       ` ..-Z"=~`..._~___::~~~_J\
       ........                                                    ` ..dY=````..~~__::::::::~_J\
  .KY"=<<<<<<<?77"YTXa-..                                      `  .JY=`````.-<~--::<<~~~~<:<_d^
   W,~~~_______<~-..`.. ?7TG+...`         ` ` `  `   ....   `  .v"~`````.-<~-JT1__........_-d'
    T,_~:::;:<z+-~~~~<-..``.`._?TSJ.. ..JVYT7TTTTTY"=<<<?7"TQJ=~`.``...?~~__(<~_......... .#`
     (h_~:<::((+v___._.~~?<.`````.`_?TG-__...___.__....` ..?~```.` .J!~~_..-~<7_......._ .P
      .W,_~~~_?71-.````` _~~?i..````````.``.```..```````._```.. .J>_~_`   ?<<__.......  (%
        ?p _..._._-z.,  ``` _~_?<- .`.````````````.``.````` _<1>_~~~~._ --(i-......._ .V!
         .W, ......(>~<~+-....~~~(t<!`.`.`.`.``.```.``.``` `   .<-~~((?1~?=_......_ .J=
           7e .........!_.C~-(>(?`  ` ````````````````````  `     ?(~_`` ``....  `.-Y
            .W, .......```` ~(<`   ` `   ` ``````````      `  `     ?-_.    ``` .J"
             `?h.     ` ` .~J! ` `     `  `   ` ` `   `  `   `  `  `  1__    ..J=
                7a,     .~_J`     ` ` `  ` ``   `  `  `   `    `  `  ` 1-_ (d=`
                  ?TGgJ<<_J`` ` `  ` - `  ```` ``` `  `(   `  `     ` .wWc<W_
                      .5g-$`   `     >  `````  ``` ` ` (-  `    `  `   _7HHXb.
                       .@H=`     ` `.l` ````  `  ```` `(<-`  _ `  `   `  j ?NHm,`
                    `.dHMF ` ` ` . `.$```` `    `` ````(~(.(<J- `  ` `   (  W7HHm,
                   `.@Ht,P` `   ._  (1_. `  ` `   `` .(T!_<-`?W+  `  ````(  d, (UHh.`
                `  .M#!  b``  ` ,Sv7TOo.  `  `   ` _~. <`` <. ({`  `` ` .<   h   .UH&`
                 `.MD`   O-`````vl  v.1__ ``` ``````.;.:``` 1 J1 ` ````.i! ` J;    ?Mh.
                 .WF     .n...``.?- > ->.-`````````..I+.`` ..e:(- . ```.V-  `.b      UN. `
                `(F      (C<~(<..l(1c` ?z1---....._jjA.JJadHYW@.> < ``.c(} `  d.      ?N.
               `.@`     .@  <((-_vM#HmQmq8?1&-~~~(J!`  WHMHMb `.>.> ._J~(!` ``(]       ,b   `
                ,>      d!`  ` v+(_`.HHMMb. `????````  XxdHMH~` >(iJO!_(> ```_ K        ,`
                .      .F` ` ``.c1s..HdMMH~````````````(BXVY=``.O>`.c_(>_````(-W
                      `J{;``` ``(+> `-77"= ```.````````````   ````..+>~~_````.}d
                       H(:```````.3 ..````````.````````````` `.` .>~~~({__ ``.Pd
                     ` Dd_```.....I ``````````_````````````````.v~~:~:(P_~_ ((bK
                       WM{ ...~~~~(o.``````````````` ..````` .?`(<:~(-+#_~~_1dH%
                       dvr-l..~~_s_w7+.``.<(-. ?!``~~..-<1.?!` J<+~:(iWH~::(kWF
                         X_w~~~(jM:Wc_O?42``` ?&+-;+<~``.(:` .4~(D~(Id!H~_(V!!
                         .hdm_~(d?hdNz-_(>``.._(_.(>_..``(:`` (1H%(uV! HV"!
                           7:?4uD.K~.._?z>`.._(JSjk-__`.`(C<<!_7H#"!
                                .dI:__-.I?&Jv=_+?>?l_?4v?> -< ...?h.
                    `        .JHz?1<:::J<(l ` J?1J<1_ `(:..?_...._Jb
                        `..v"!``(>(1+:(>~~(1.<(1<iJ><..C<_--1(:::+CJN.
                        J=````.` (a+g0Ws:::_:_::(<___<(~___(C~:<z<1>-Ta,`
                       `?e````.z@!     X<:::::::<+:::::?1+jdYTYAaZ!``` ?4a.`    `
                         (n.````Oe    .D_~~~:::::::::::::(W!     ?U, ````.To.      `
                          .4,````?Hka.f_....__~~::~:~:~~~_d;       (W,`` `` 7a.
                            ?N,  `-_4D..............~.~..._W,        ?NJ. ` ` ?4dYBh, `
                             JD?-   +_......................W.         _TS&,   `  ` TmJN`
                             .UR-...<z+-_-............-__-((dL             _Wn. `  .! (t   `
                            ` J8!_.2____<?<<<+(-(--(+<<1<<(_<jL             .N..`.J!  ?W&
                              d&J?` ~?<+-_(-~(-:(_: <.<(-(<7!_?o             ?B9Tn.` (4kdb
                        ` `.dY!   ` `./` ` _(????!!~!` ``(_``..?L                .4,m,iW.
                            .U,    `.!   `  !  `` `. `` ` < `...?r                 Wd?BY`
                              (N&.`.!` `   <  ```` _ ` ```(_`..(JV`   `  `
                             `(8-.?=<?1+-..+... ```(.......f<~?r          ` ` ......
                             .K`.?<-.   __(K<D__<?TC~~~~__```.-S.  ....-&ZY""777?77""9GJ,`   `
                            `J}````` _??<d= J{~~~~~(i.....-<<~`(Y77<~_``.```.```````.`.(XHa.    `
                        `   .K`````````.d^  X~~.~.~~_1. ````.`` I_....```.````.``.`````_dWqHm,
                           `(%``.`.```.Y    R~~~.~.~~~<-`````.``(-~~.....`.`````.``.``.(dWqkHh
                           .K_```.``.J^     S_~~~~~.~~~?:``.``.`.l~~~~...``.`.``````.``_zWkqkHb`
                        ` .d'`..```.Y`      q{~.~.~~.~.~(i ````.`(/.~~.....```.``.```.`.dWqqqqH[
                         .d!`~~_-.J^        .b_~.~~.~~~~~_1.  ..``?+~~~~....````````.` (WkHHM#H#
                         d!` __?(f`          ?n~~~.~~.~~~~~?i_.````?/~~.~..`.``.``.``._jkY"7=
                     `  .D``` `.%             ?h,~~~~.~..~~~~1, ``` j_~~....``.``.``.-V=`
                       `(}`   (\                Tm,~~~~~.~.~~~?- `` .>~~....``.``..JY`
               `   `   .g`   ('                   ?W&-~~~~~.~.~(>  ` 1_~~....`..JT^
                      d=<  .,Nx                      THaJ-_~~~~~(l   (o.(((JZ"^`
                `    .@   `?`.H.                        _"YBHmggk<!`` > W>
                      4eJ>:1.(t                                 W+.<(. .(D           `
                      ({?<!~db                                   W$<<jY4F`
                      ,h. _`.W`                                 (5..J=.d`
                    `   7TUY"`                                  4,...(Y!
                                                                  ~~`                         `

	でかいですね。
	更にかわいいときた。
	うん。好き。
*/

/*  include  */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <locale.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <setjmp.h>
#include <string.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>

/*  typedef  */
typedef long long ll;
typedef char string[100];
typedef int array[100];
/*  define  */

/*  define funcs  */
#define sort_d(array,end){int size=end-array;qsort(array,size,sizeof(int),intcmp);}
#define sort_c(array,end){int size=end-array;qsort(array,size,sizeof(char),charcmp);}
#define rand_range(min,max) (min)+(rand())%((max)-(min)+(1))
#define rep(i,j) for(int i=0;i<j;i++)
#define loop(i,j,z) for(int i=j;i<z;i++)
#define swap(a,b) ((a!=b)&&(a+=b,b=a-b,a-= b))
#define getarray_d(array,size){array=(int *)malloc(sizeof(int)*size);}
#define getarray_c(array,size){array=(char *)malloc(sizeof(char)*size);}
#define fill(array,end,val){int size=end-array;rep(i,size)array[i]=val;}

/*  otter  (Otter)  ｶﾜｳｿｯ！ */
#define intptr int *
#define random srand((unsigned)time(NULL))
#define ON 1
#define OFF 0
#define TREE_SIZE 1000

/*  prototype Declaration */
int intcmp(const void* a, const void* b);
int charcmp(const void* a, const void* b);
bool is_sorted(const int* start, const int* end);
int count(const int* start, const int* end, int target);
void shuffle(int* start, int* end);
void tree_init(void);
int tree_root(int x);
void unite(int x, int y);
bool same(int x, int y);

/*  scan  */
#define sd(a) scanf("%d",&a)
#define sc(a) scanf("%c",&a), getchar()
#define sf(a) scanf("%f",&a)
#define ss(a) scanf("%s",a)
#define sld(a) scanf("%lld",&a)
/*  print  */
#define odn(a) printf("%lld\n",a)
#define ocn(a) printf("%c\n",a)
#define ofn(a) printf("%f\n",a)
#define osn(a) printf("%s\n",a)
#define od(a) printf("%d ",a)
#define oc(a) printf("%c ",a)
#define of(a) printf("%f ",a)
#define os(a) printf("%s ",a)

/*  struct  */
typedef struct {
	int first;
	int second;
}pair;
/*  local val  */
int tree[TREE_SIZE];
int cnts=0;
/*  funcs （local）*/

/*  main program  */
int main(void)
{
	int X,Y,A,B,C;
	long long p[100005];
	long long q[100005];
	long long r[100005];
        long long ans[100005];
	int cost=0;
	sd(X),sd(Y),sd(A),sd(B),sd(C);
	rep(i,A) sd(p[i]);
	rep(i,B) sd(q[i]);
	rep(i,C) sd(r[i]);
	sort_d(p,p+A);
	sort_d(q,q+B);
	sort_d(r,r+C);
	rep(i,X+Y+C){
		if(i<X) ans[i]=p[i];
		else if(i<X+Y) ans[i]=q[i];
		else ans[i]=r[i];
	}
	sort_d(ans,ans+X+Y+C);
	rep(i,X+Y)cost+=ans[i];
	od(cost);
}

/*  funcs  (global)*/
void sort_first(pair* b, pair* e)
{
	int* dec;
	int s2 = e - b;
	int size = e - b;
	getarray_d(dec, size);
	rep(i, size) dec[i] = b[i].first;
	sort_d(dec, dec + s2);
	rep(i, size) b[i].first = dec[i];
}
void sort_second(pair* b, pair* e)
{
	int* dec;
	int s2 = e - b;
	int size = e - b;
	getarray_d(dec, size);
	rep(i, size) dec[i] = b[i].second;
	sort_d(dec, dec + s2);
	rep(i, size) b[i].second = dec[i];
}


long long intcmp(const void* a, const void* b)
{
	return *(long long*)a - *(long long*)b;
}

int charcmp(const void* a, const void* b)
{
	return *(char*)a - *(char*)b;
}

bool is_sorted(const int* start, const int* end)
{
	while (start != end) {
		if (*start > * (start + 1)) return false;
		start++;
	}
	return true;
}

int count(const int* start, const int* end, int target)
{
	int cnt = 0;
	int* array;
	int* p;

	array = (int*)malloc((end - start) * sizeof(int));

	if (array == NULL) {
		printf("Err0r");
		exit(-1);
	}

	memcpy(array, start, sizeof(int) * (end - start));
	sort_d(array, array + (end - start));
	p = (int*)bsearch(&target, array, end - start, sizeof(int), intcmp);

	if (p == NULL) {
		free(array);
		return 0;
	}
	while (*p == target)
		p++;
	p--;
	while (*p == target) {
		cnt++;
		p--;
	}

	free(array);

	return cnt;
}

void shuffle(int* start, int* end)
{
	random;

	int a, b;
	int size = end - start;

	rep(i, 500) {
		a = rand_range(0, size - 1);
		b = rand_range(0, size - 1);
		swap(start[a], start[b]);
	}
}
/*  tree  */

void tree_init(void)
{
	for (int i = 0; i < TREE_SIZE; i++) tree[i] = i;
}

int tree_root(int x)
{
	if (tree[x] == x) return x;
	return tree[x] = tree_root(tree[x]);
}

void unite(int x, int y)
{
	int rx = tree_root(x);
	int ry = tree_root(y);
	if (rx == ry) return;
	tree[rx] = ry;
}

bool same(int x, int y)
{
	int rx = tree_root(x);
	int ry = tree_root(y);
	return rx == ry;
}

ll pow_mod(ll n, ll k, ll m)
{
	if (k == 0) return 1;
	else if (k % 2) return pow_mod(n, k - 1, m) * n % m;
	else {
		int t = pow_mod(n, k / 2, m);
		return t * t % m;
	}
}


Compiler output:
main.c:204:11: error: conflicting types for 'intcmp'; have 'long long int(const void *, const void *)'
  204 | long long intcmp(const void* a, const void* b)
      |           ^~~~~~
main.c:119:5: note: previous declaration of 'intcmp' with type 'int(const void *, const void *)'
  119 | int intcmp(const void* a, const void* b);
      |     ^~~~~~
main.c: In function 'count':
main.c:101:75: error: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types]
  101 | #define sort_d(array,end){int size=end-array;qsort(array,size,sizeof(int),intcmp);}
      |                                                                           ^~~~~~
      |                                                                           |
      |                                                                           long long int (*)(const void *, const void *)
main.c:237:9: note: in expansion of macro 'sort_d'
  237 |         sort_d(array, array + (end - start));
      |         ^~~~~~
In file included from main.c:86:
/usr/include/stdlib.h:971:34: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'long long int (*)(const void *, const void *)'
  971 |                    __compar_fn_t __compar) __nonnull ((1, 4));
      |                    ~~~~~~~~~~~~~~^~~~~~~~
main.c:238:69: error: passing argument 5 of 'bsearch' from incompatible pointer type [-Wincompatible-pointer-types]
  238 |         p = (int*)bsearch(&target, array, end - start, sizeof(int), intcmp);
      |                                                                     ^~~~~~
      |                                                                     |
      |                                                                     long long int (*)(const void *, const void *)
/usr/include/stdlib.h:961:68: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'long long int (*)(const void *, const void *)'
  961 |                       size_t __nmemb, size_t __size, __compar_fn_t __compar)
      |                                                      ~~~~~~~~~~~~~~^~~~~~~~