#include #define REP(i,n,N) for(int i=(n);i<(int)N;i++) #define p(s) cout<<(s)<>s; s+='?'; int tmp=0,ans=0; int minus= (s[0]=='-'); char c='-'; REP(i,(int)!isdigit(s[0]),s.size()){ if(isdigit(s[i])){ tmp*=10; tmp+=s[i]-'0'; }else{ if(minus) tmp=-tmp; if(c=='-') ans+=tmp; else ans-=tmp; c=s[i]; tmp=0; minus= (s[i+1]=='-'); i += (!isdigit(s[i+1])); } } p(ans); return 0; }