while 1:\x0d i=raw_input();v=0\x0d for z in i.split('='):\x0d t=0\x0d for c in map(int,z.split()):\x0d if t-c:t-=cmp(t-c,0)*c\x0d else:t*=c\x0d v+=t\x0d if v-2*t:print i
Note that non-ascii characters in the above source code will be escaped (such as \x9f).