TUT language translator
Ruby, 310 311 characters
h=Hash[(?a..?z).zip %w{e bub kut dud i fuf jug hash ay jag kak lul mum nun o pup kwak rut sus tut yu vuv waks eks yak zuz}]
h[&quot;rd&quot;]=&quot;ruddud&quot;
h.keys.each{|k|h[k[0]+k]=&quot;skwer&quot;+h[k]}
h.keys.each{|k|h[k.upcase]=h[k].upcase}
h=h.invert if b=getc==?1
i=gets
print b ?0:1;(k=i;k=k.chop until h[k]||!k[1];$&gt;&lt;&lt;(h[k]||k);i[k]=&quot;&quot;)until i==&quot;&quot;

Correctly handles:

squared uppercase (unfix by merging iterations gains 18 characters)

if AA should turn into skwerE, swap lines #3 and #4
I also assume aA and Aa should turn into eE and Ee respectively


rrd translates to `skwerruddud (unfix gains 3 characters)
in cubes the first pair is reported as a square. rrrd turns into skwerrutruddud. rrrrd becomes skwerrutskwerruddud
the output is now a valid input. It is, indeed, required by the spec
uses newline as input terminator

Input requires there be no newline between the indicator and the string, output puts it there (fix: 1 character). Console output suppressed at this point to prevent mixing with STDIN. Unfix free, it's just a little bit uglier.
Example input:
0Hello

Output:
1
HASHiskwerlulo