#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; ll mod_pow(ll x,ll y,ll mod){ ll res=1; x%=mod; while(y>0){ if(y&1){ res*=x; res%=mod; } x*=x; x%=mod; y/=2; } return res; } int main(){ int N; cin>>N; vector> SA; vector S(N); vector A(N); ll cntP=0; ll cntAll=0; for(int i=0;i>S[i]>>A[i]; SA.emplace_back(S[i],A[i]); if(S[i]=='P') cntP++; cntAll+=A[i]; } vector cnt2(3,0); for(int i=0;i