# -*- coding: utf-8 -*-

import util
from slang import *
from constants import REDUCED, SUFFIX_FLAG, PREFIX_FLAG


def reduce_suffix(words_dict, words):
    """
    Reduce suffix from words
    :param words_dict: (dict) key-value pair of words from text
    :param words (list) word list
    :returns: reduced words dictionary
    """
    for word in words:
        if not words_dict[word][SUFFIX_FLAG]:
            word_length = len(word)
            if word_length > 3:
                suffix_3 = word[-3:]
                suffix_4 = word[-4:]
                if suffix_3 in suffix_slang_3:
                    words_dict[word][REDUCED] = word[:-3] + \
                            suffix_slang_3[suffix_3]
                elif suffix_4 in suffix_slang_4:
                    words_dict[word][REDUCED] = word[:-4] + \
                            suffix_slang_4[suffix_4]
                else:
                    if not words_dict[word][PREFIX_FLAG]:
                        words_dict[word][REDUCED] = word
            else:
                words_dict[word][REDUCED] = word

        words_dict[word][SUFFIX_FLAG] = True
    return words_dict


def reduce_prefix(words_dict, words):
    """
    Redue prefix from words
    :param words_dict: (dict) key-value pair of words from text
    :param words: (list) word list
    :returns: reduced words dictionary
    """
    for word in words:
        if not words_dict[word][PREFIX_FLAG]:
            word_length = len(word)
            if word_length > 3:
                prefix_3 = word[:3]
                prefix_4 = word[:4]
                if prefix_3 in prefix_slang_3:
                    words_dict[word][REDUCED] = prefix_slang_3[prefix_3] + \
                            word[3:]
                elif prefix_4 in prefix_slang_4:
                    words_dict[word][REDUCED] = prefix_slang_4[prefix_4] + \
                            word[4:]
                else:
                    if not words_dict[word][SUFFIX_FLAG]:
                        words_dict[word][REDUCED] = word
            else:
                words_dict[word][REDUCED] = word

        words_dict[word][PREFIX_FLAG] = True
    return words_dict


def get_text():
    """
    Driver function; Execution starts here
    """
    text = raw_input('')
    words_dict, words = util.getWords(text)
    words_dict = reduce_suffix(words_dict, words)
    words_dict = reduce_prefix(words_dict, words)
    for word in words:
        print words_dict[word][REDUCED],

get_text()

@@ -105,16 +105,24 @@
 FIX_FLAG
+, LENGTH
 %0A%0A%0Adef r
@@ -143,32 +143,39 @@
 ords_dict, words
+, limit
 ):%0A    %22%22%22%0A    R
@@ -347,34 +347,134 @@
 %22%22%22%0A    
-for word in words:
+text_length = words_dict%5BLENGTH%5D%0A    for word in words:%0A        if text_length %3C= limit:%0A            return words_dict
 %0A       
@@ -832,18 +832,81 @@
         
-el
+    text_length -= len(suffix_slang_3%5Bsuffix_3%5D)%0A                
 if suffi
@@ -1063,195 +1063,56 @@
     
-else:%0A                    if not words_dict%5Bword%5D%5BPREFIX_FLAG%5D:%0A                        words_dict%5Bword%5D%5BREDUCED%5D = word%0A            else:%0A                words_dict%5Bword%5D%5BREDUCED%5D = word
+    text_length -= len(suffix_slang_4%5Bsuffix_4%5D)
 %0A%0A  
@@ -1213,16 +1213,23 @@
 t, words
+, limit
 ):%0A    %22
@@ -1409,34 +1409,134 @@
 %22%22%22%0A    
-for word in words:
+text_length = words_dict%5BLENGTH%5D%0A    for word in words:%0A        if text_length %3C= limit:%0A            return words_dict
 %0A       
@@ -1891,18 +1891,81 @@
         
-el
+    text_length -= len(prefix_slang_3%5Bprefix_3%5D)%0A                
 if prefi
@@ -2121,195 +2121,56 @@
     
-else:%0A                    if not words_dict%5Bword%5D%5BSUFFIX_FLAG%5D:%0A                        words_dict%5Bword%5D%5BREDUCED%5D = word%0A            else:%0A                words_dict%5Bword%5D%5BREDUCED%5D = word
+    text_length -= len(prefix_slang_4%5Bprefix_4%5D)
 %0A%0A  
@@ -2336,16 +2336,36 @@
 put('')%0A
+    limit = input()%0A
     word
@@ -2400,16 +2400,49 @@
 s(text)%0A
+    words_sorted = sorted(words)%0A
     word
@@ -2477,24 +2477,38 @@
 _dict, words
+_sorted, limit
 )%0A    words_
@@ -2541,24 +2541,38 @@
 _dict, words
+_sorted, limit
 )%0A    for wo

compress as per character limit