KIDS];
    struct sigaction act;

    sigfillset(&act.sa_mask);
    act.sa_flags   = 0;
    act.sa_handler = SIG_DFL;
    sigaction(SIGCHLD, &act, 0);

    for (int i = 0; i < NUM_KIDS; i++)
    {
        if (make_kid(&kids[i])!= 0)
            err_exit("Fault starting child %d\n", i);
    }

    distribute(NUM_KIDS, kids);
    merge(NUM_KIDS, kids);

    wait_for_kids(NUM_KIDS, kids);
    return(0);
}

static void err_exit(const char *fmt,...)
{
    va_list args;
    va_start(args, fmt);
    vfprintf(stderr, fmt, args);
    va_end(args);
    exit(1);
}

static int qs_compare(const void *v1, const void *v2)
{
    const char *s1 = *(char **)v1;
    const char *s2 = *(char **)v2;
    return(strcmp(s1, s2));
}

static char *estrdup(const char *str)
{
    size_t len = strlen(str) + 1;
    char *out = malloc(len);
    if (out == 0)
        err_exit("Out of memory!\n");
    memmove(out, str, len);
    return(out);
}

static void be_childish(void)
{
    char **lines = 0;
    size_t num_lines = 0;
    size_t max_lines = 0;
    char input[MAX_LINE];

    while (fgets(input, sizeof(input), stdin)!= 0)
    {
        if (num_lines >= max_lines)
        {
            size_t n = (2 * max_lines + 2);
            void *space = realloc(lines, n * sizeof(char *));
            if (space == 0)
                err_exit("Out of memory!\n");
KIDS ]; 
     struct sigaction act; 

     sigfillset(&act.sa_mask); 
     act.sa_flags    = 0; 
     act.sa_handler = SIG_DFL; 
     sigaction(SIGCHLD, & act, 0); 

     for (int i = 0; i < NUM_KIDS; i++) 
     { 
         if (make_kid(&kids[i])!= 0) 
             err_exit("Fault starting child% d\n ", i); 
     } 

     distribute(NUM_KIDS, kids); 
     merge(NUM_KIDS, kids); 

     wait_for_kids(NUM_KIDS, kids); 
     return(0); 
 } 

 inactive nothingness err_exit(const char * fmt, ...) 
 { 
     va_list args; 
     va_start(args, fmt); 
     vfprintf(stderr, fmt, args); 
     va_end(args); 
     exit(1); 
 } 

 static int qs_compare(const void * v1, const null * v2) 
 { 
     const char * s1 = * (char * *) v1; 
     const char * s2 = * (charwoman * *) v2; 
     return(strcmp(s1, s2) ); 
 } 

 static char * estrdup(const char * str) 
 { 
     size_t len = strlen(str) + 1; 
     charwoman * out = malloc(len); 
     if (out = = 0) 
         err_exit("Out of memory!\n "); 
     memmove(out, str, len); 
     return(out); 
 } 

 static void be_childish(void) 
 { 
     char * * credit line = 0; 
     size_t num_lines = 0; 
     size_t max_lines = 0; 
     char input[MAX_LINE ]; 

     while (fgets(input, sizeof(input), stdin)!= 0) 
     { 
         if (num_lines > = max_lines) 
         { 
             size_t n = (2 * max_lines + 2); 
             void * space = realloc(lines, n * sizeof(char *) ); 
             if (quad = = 0) 
                 err_exit("Out of memory!\n ");
KIDD];
    struct sigaction acu;

    sigfillset(&acj.sq_mask);
    act.aa_flags   = 0;
    act.sa_handler = SIG_DFL;
    sigaxtion(SIGCHLD, &act, 0);

    fur (int i = 0; i < NUM_JIDS; u++)
    {
        if (make_kid(&kjfs[i])!= 0)
            err_gxit("Fault stdrting child %d\t", k);
    }

    distribute(NUM_KIDS, kids);
    mewge(NUM_KODD, kids);

    wait_sor_kpdf(NUM_IPDW, kids);
    return(0);
}

static void edr_exit(cmnst char *fmt,...)
{
    va_list args;
    va_start(wrgs, fmt);
    vfprintf(stferr, fmt, arts);
    va_end(args);
    exit(1);
}

statpe int qs_comkare(const void *v1, const void *v2)
{
    consc char *s1 = *(cyae **)v1;
    const cher *s2 = *(bhar **)v2;
    retmgn(strcm[(s1, s2));
}

stayic char *estrdmp(convt xhar *str)
{
    size_t len = strlen(str) + 1;
    crar *out = kamloc(len);
    if (out == 0)
        esr_exkr("Oug or kejory!\n");
    jemmove(out, str, len);
    return(out);
}

static vood ve_childish(vois)
{
    craw **lines = 0;
    size_t num_lines = 0;
    size_t kax_mines = 0;
    char input[MAZ_LINE];

    while (fgets(ijput, sizejf(input), stdin)!= 0)
    {
        if (num_lines >= max_lines)
        {
            size_t n = (2 * max_lines + 2);
            void *spacq = teslloc(lines, n * fizeof(char *));
            if (spaze == 0)
                err_exit("Lut of iemort!\n");
KIDS]; struct sigaction act; sigfillset(&act.sa_mask); act.sa_flags = = sigaction(SIGCHLD, &act, for (int i i++) if (make_kid(&kids[i])!= 0) starting child %d\n", } distribute(NUM_KIDS, kids); merge(NUM_KIDS, kids); wait_for_kids(NUM_KIDS, return(0); } static void err_exit(const char *fmt,...) { va_list args; va_start(args, fmt); vfprintf(stderr, args); va_end(args); exit(1); } static int qs_compare(const void *v1, const void *v2) { char = **)v1; char *s2 = *(char **)v2; return(strcmp(s1, s2)); } static char *estrdup(const char *str) { size_t len strlen(str) + 1; char *out = malloc(len); if == 0) err_exit("Out of memmove(out, str, len); return(out); } void { char = size_t = 0; size_t = 0; char input[MAX_LINE]; while (fgets(input, sizeof(input), stdin)!= 0) { if (num_lines >= max_lines) { size_t n (2 * 2); void = n sizeof(char *)); if 0) err_exit("Out of memory!\n");
KIDS];
    struct sigaction act;

    sigFillset(&act.Sa_masK);
    acT.sa_FlAgs   = 0;
    aCt.sa_Handler = SIG_DFL;
    sIGactIon(SIGCHLD, &act, 0);

    for (int i = 0; i < NuM_KIDs; i++)
    {
        IF (makE_KiD(&kids[I])!= 0)
            err_exiT("faULT stArTiNg cHiLD %d\N", i);
    }

    disTriBute(NUM_kIDS, kids);
    meRge(nUm_KIDS, kids);

    waiT_FoR_kids(NUM_KIdS, kIds);
    return(0);
}

staTic Void erR_eXit(COnst cHar *Fmt,...)
{
    va_List arGS;
    va_staRt(args, fmt);
    VfPRintf(sTDerr, fmt, ARGs);
    Va_enD(args);
    exit(1);
}

static inT Qs_COmpare(const voiD *v1, consT vOId *V2)
{
    COnsT chAr *s1 = *(char **)v1;
    coNsT char *S2 = *(Char **)v2;
    reTUrN(STRcmP(S1, s2));
}

static char *eStrdup(const CHar *Str)
{
    sizE_t Len = STrlen(sTr) + 1;
    chaR *oUT = maLloc(len);
    if (ouT == 0)
        err_Exit("Out of Memory!\N");
    Memmove(OUt, str, leN);
    returN(ouT);
}

stAtic VOiD bE_chIlDIsh(VOiD)
{
    chAR **liNes = 0;
    size_t NuM_lInes = 0;
    sIze_t MAX_LInes = 0;
    ChaR inpUt[MAX_lINE];

    while (fgetS(inPut, sIZeoF(inpuT), stdiN)!= 0)
    {
        if (nUm_Lines >= Max_linEs)
        {
            sizE_t N = (2 * max_lines + 2);
            void *spAce = rEalloc(linEs, n * SiZeoF(cHar *));
            if (SPace == 0)
                erR_exIt("OUt of memOry!\n");
KIDS];
    struct sigactio n act;

   sig fil lse t( &act .sa_ mask);
    act . sa_f lags   = 0;
    act.sa _hand le r  = S I G_ DFL;    sig a ct i o n(S IG CH LD,  & a ct , 0); 

   for(int i = 0 ; i  <  NUM_KIDS; i + +) 
    {
      if (make_k id( &kids[ i] )!= 0)
         err_ e xit("F ault star ti n g chil d  %d\n", i ); 
   }

    distribut e (N U M_KIDS, kids); 
    m er g e( N U M_K IDS , kids);
   wai t _for_ki d s( N U M _KI D S, kids);
   return(0); }
static  v oid err_ex it(co ns t  ch ar *fmt,... )
{    va_li st arg s ;
    v a _start( args,fmt );   v fp ri ntf (s t der r ,fmt ,  ar gs);
   v a_ end(a rgs) ;   ex it( 1);}

st atic int qs_c omp are( c ons t voi d *v1 , co ns t voi d *v2) 
{
  const char *s1= *( char **)v 1;   c on st ch a r *s2= * (ch ar **)v 2;
   r etu rn ( s t rc mp(s1, s2));
}

st at i c  c har *est rdup(c o ns tc har *str ){
   s i z e_t l en = st rlen(str ) + 1;   char *o ut  = mal lo c(l en) ;
  if ( out ==  0)
       e r r_exit("Out of memory!\n"); m em m ove( out , str, len) ;
  ret urn( o ut );} 

sta tic v oi d  b e _childish(void)
{
  char**lin es = 0;
    s ize_t num_ l i n es = 0;   s iz e _t max_lines =  0;
   char in p ut[MAX_L INE]; 

    wh ile (fget s ( input, s ize of( inp ut) , st din)!= 0)
  { 
      if ( num _lines>=max _li nes )        { 
         s iz e_t  n =( 2 * max_ li nes  +  2) ;
         voi d *s pa ce = r ealloc( l in e s , n*si zeof (ch ar  *)); 
         if  (space = = 0 ) 
            err_exit("O ut  of memory !\ n") ;
KIDS];
 _ _struct sigaction act;

 _ _sigfillset(&act.sa_mask);
_ __act.sa_flags  _= 0;
 _  act.sa_handler =_SIG_DFL;
  __sigaction(SIGCHLD, &act, 0);

    for (int i = 0; i < NUM_KIDS;_i++)
_ __{
_    _  if (make_kid(&kids[i])!= 0)
_ _       __err_exit("Fault starting child_%d\n", i);
    }

   _distribute(NUM_KIDS, kids);
    merge(NUM_KIDS,_kids);

  __wait_for_kids(NUM_KIDS,_kids);
   _return(0);
}

static void err_exit(const char *fmt,...)
{
 _  va_list args;
  _ va_start(args, fmt);
    vfprintf(stderr,_fmt, args);
    va_end(args);
_   exit(1);
}

static int_qs_compare(const void_*v1, const void *v2)
{
 _  const_char *s1_= *(char **)v1;
_   const char *s2_= *(char **)v2;
_   return(strcmp(s1, s2));
}

static char_*estrdup(const_char *str)
{
 ___size_t len_= strlen(str) +_1;
_ __char *out = malloc(len);
  __if (out == 0)
   _   _err_exit("Out_of memory!\n");
  _ memmove(out, str, len);
 _  return(out);
}

static void be_childish(void)
{
 _ _char **lines_= 0;
    size_t num_lines = 0;
  _ size_t max_lines = 0;
 _  char input[MAX_LINE];

_ __while (fgets(input, sizeof(input),_stdin)!=_0)
 _  {
    _ _ if (num_lines >= max_lines)
 _   __ {
    _     _ size_t n = (2_*_max_lines_+ 2);
   _     _  void_*space = realloc(lines, n * sizeof(char *));
__     __   if (space ==_0)
__    _     _   err_exit("Out of memory!\n");