begin
integer sp,dd,eoln,add,sub,mul,div,err,num,c,tk;
real x;
integer procedure getchar;
begin integer i;
inchar(0,⌜0123456789.+-*/ ⌜NL⌝⌝,i);
getchar := if i=0 then err
else if i<11 then i-1
else if i=11 then dd
else if i=12 then add
else if i=13 then sub
else if i=14 then mul
else if i=15 then div
else if i=16 then sp
else eoln
end ;
procedure skiprest; for c := c while c≠eoln do c := getchar;
integer procedure evalrpn(r); real r;
begin integer tk; real x,y;
Boolean procedure isoper(o); value o; integer o;
isoper := o=add ∨ o=sub ∨ o=mul ∨ o=div;
integer procedure gettoken;
begin integer sgn,tk;
procedure skipws; for c := c while c=sp do c := getchar;
Boolean procedure getnumber;
begin integer d; real z;
getnumber := false;
z := d := -1;
loop:
if c<10 then begin
if d≥0 then d := 1+d;
if z=-1 then z := 0;
z := 10×z+c
end else if c=dd then begin
if d=-1 then d := 0 else go to en
end else go to en;
c := getchar;
if ¬(c=sp ∨ c=eoln) then go to loop;
if z≥0 then begin
y := sgn×z; if d>0 then y := y/10↑d;
getnumber := true
end;
en:
end ;
skipws;
sgn := 1;
tk := c;
if isoper(c) then begin
c := getchar;
if (tk=add ∨ tk=sub) ∧ (c<10 ∨ c=dd) then begin
if tk=sub then sgn := -1;
tk := if getnumber then num else err
end else tk := if c=sp ∨ c=eoln then tk else err
end else if ¬(c=eoln ∨ c=err) then
tk := if getnumber then num else err;
if ¬(c=sp ∨ c=eoln) then tk := err;
gettoken := tk
end ;
tk := gettoken;
if ¬(tk=eoln ∨ isoper(tk)) then begin
if tk=num then begin
x := y;
for tk := evalrpn(y) while isoper(tk-num) do begin
tk := tk-num;
if tk=add then x := x+y
else if tk=sub then x := x-y
else if tk=mul then x := x×y
else x := x/y
end;
if tk=eoln ∨ isoper(tk) then begin
r := x;
tk := if tk=eoln then num else tk+num
end else if tk=num then tk := err
end
end;
evalrpn := tk
end ;
num := 50; add := 51; sub := 52; mul := 53; div := 54;
sp := 20; dd := 30; eoln := 10; err := 1001;
for c := sp while true do begin
tk := evalrpn(x);
if tk=num then begin outreal(1,x); outstring(1,⌜⌜NL⌝⌝) end
else if tk≠eoln then begin outstring(1,⌜error⌜NL⌝⌝); skiprest end
end
end