/* strip extra whitespace from input and print the result on standard
 * output */

#include <stdlib.h>
#include <stdio.h>

#define UNUSED(x) ((void) (x))

/* this should really be isspace(), but you said you didn't know that
 * yet, so we'll use this instead :D */
#define IS_SPACE(c) ((c) == '\t' || \
                     (c) == '\r' || \
                     (c) == '\n' || \
                     (c) == ' ')

int main(int argc, char *argv[]) {
  int c, lc, i, l, len[20];
  UNUSED(argc);
  UNUSED(argv);

  /* slightly faster way of clearing the array */
  memset(len, 0, sizeof(len));
  
  l = 0;
  lc = ' ';
  while ((c = getchar()) != EOF) {
    if (IS_SPACE(c) && !IS_SPACE(lc)) {
      len[l]++;
      l = 0;
    } else if (!IS_SPACE(c)) {
      l++;
    }
    
    lc = c;
  }

  for (i = 0; i < (int) (sizeof(len) / sizeof(int)); i++)
    if (len[i])
      printf("% 2d: % 2d\n", i, len[i]);

  return EXIT_SUCCESS;
}

