def RunEncode(n)
listToNum(RunEncode1([3],n,1));
def RunEncode1(ls,n,c)
if(c=n)
ls
else
RunEncode1(flatten(RunEncode2(ls,car(ls),0,[])),n,c+1);
def RunEncode2(ls,num,cnt,res)
if(null?(ls))
reverse(cons(list(cnt,num),res))
else if(car(ls)=num)
RunEncode2(cdr(ls),num,cnt+1,res)
else
RunEncode2(cdr(ls),car(ls),1,cons(list(cnt,num),res));
def flatten(ls)
if(null?(ls))
[]
else if(atom?(car(ls)))
cons(car(ls),flatten(cdr(ls)))
else
append(flatten(car(ls)),flatten(cdr(ls)));
def listToNum(ls)
listToNum1(ls,0);
def listToNum1(ls,num)
if(null?(ls))
num
else
listToNum1(cdr(ls),num*10+car(ls));
ZGVmIFJ1bkVuY29kZShuKQogICBsaXN0VG9OdW0oUnVuRW5jb2RlMShbM10sbiwxKSk7CgpkZWYgUnVuRW5jb2RlMShscyxuLGMpCiAgaWYoYz1uKQogICAgbHMKICBlbHNlCiAgICBSdW5FbmNvZGUxKGZsYXR0ZW4oUnVuRW5jb2RlMihscyxjYXIobHMpLDAsW10pKSxuLGMrMSk7CgpkZWYgUnVuRW5jb2RlMihscyxudW0sY250LHJlcykKICBpZihudWxsPyhscykpCiAgICByZXZlcnNlKGNvbnMobGlzdChjbnQsbnVtKSxyZXMpKQogIGVsc2UgaWYoY2FyKGxzKT1udW0pCiAgICBSdW5FbmNvZGUyKGNkcihscyksbnVtLGNudCsxLHJlcykKICBlbHNlCiAgICBSdW5FbmNvZGUyKGNkcihscyksY2FyKGxzKSwxLGNvbnMobGlzdChjbnQsbnVtKSxyZXMpKTsKCmRlZiBmbGF0dGVuKGxzKQogIGlmKG51bGw/KGxzKSkKICAgIFtdCiAgZWxzZSBpZihhdG9tPyhjYXIobHMpKSkKICAgIGNvbnMoY2FyKGxzKSxmbGF0dGVuKGNkcihscykpKQogIGVsc2UKICAgIGFwcGVuZChmbGF0dGVuKGNhcihscykpLGZsYXR0ZW4oY2RyKGxzKSkpOwoKZGVmIGxpc3RUb051bShscykKICBsaXN0VG9OdW0xKGxzLDApOwoKZGVmIGxpc3RUb051bTEobHMsbnVtKQogIGlmKG51bGw/KGxzKSkKICAgIG51bQogIGVsc2UKICAgbGlzdFRvTnVtMShjZHIobHMpLG51bSoxMCtjYXIobHMpKTsK
Main.java:1: error: class, interface, or enum expected
def RunEncode(n)
^
Main.java:4: error: class, interface, or enum expected
def RunEncode1(ls,n,c)
^
Main.java:10: error: class, interface, or enum expected
def RunEncode2(ls,num,cnt,res)
^
Main.java:18: error: class, interface, or enum expected
def flatten(ls)
^
Main.java:26: error: class, interface, or enum expected
def listToNum(ls)
^
Main.java:29: error: class, interface, or enum expected
def listToNum1(ls,num)
^
6 errors