#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include #define rep(i,j,k) for(int i=(int)j;i<(int)k;i++) #define ll long long #define Sort(v) sort(all(v)) #define INF 1000000000 #define END return 0 #define pb push_back #define se second #define fi first #define pb push_back #define all(v) (v).begin() , (v).end() #define MP make_pair #define MOD 1000000007LL #define int long long using namespace std; int day[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int cluc(string s){ vector num; vector cmd; rep(i,0,s.size()){ if('0'<=s[i]&&s[i]<='9'){ int t=s[i]-'0'; while(i+1>s; s+=s; int ans=0; rep(i,0,s.size()/2){ string sub=s.substr(i,s.size()/2); if(sub[0]=='+' || sub[0]=='-')continue; if(sub[sub.size()-1]=='+' || sub[sub.size()-1]=='-')continue; if(ans>cluc(sub)){ ans=cluc(sub); //cout<