import re SQRT=.5.__rpow__ a=[_[:-1].split('\x09')for _ in re.sys.stdin] def E(s,t={}): \x09v=t.get(s,s) \x09if'<'<v<'>':t[s]=v=eval(re.sub('(\w)(\d+)',r'E(a[\2-1][ord("\1")-65])',s[1:])) \x09try:v=float(v) \x09finally:return v for _ in a:print'\x09'.join(int>type(v)and"%.8g"%round(v,2)or v for v in map(E,_))
Note that non-ascii characters in the above source code will be escaped (such as \x9f).