func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Order {     char d;     int p;     int q;   };   int main() {     int n, s;     Order a[1001];     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> a[i].d >> a[i].p >> a[i].q;     }     map<int, int> bmp, smp;     for (int i = 0; i < n; i++) {       if (a[i].d ==  B ) {         bmp[a[i].p] += a[i].q;       } else {         smp[a[i].p] += a[i].q;       }     }     vector<pair<int, int> > bv;     for (map<int, int>::iterator it = bmp.begin(); it != bmp.end(); it++) {       bv.push_back(make_pair(it->first, it->second));     }     vector<pair<int, int> > sv;     for (map<int, int>::iterator it = smp.begin(); it != smp.end(); it++) {       sv.push_back(make_pair(it->first, it->second));     }     sort(bv.begin(), bv.end());     sort(sv.begin(), sv.end());     reverse(bv.begin(), bv.end());     int n1 = min(s, (int)bv.size());     int n2 = min(s, (int)sv.size());     vector<pair<int, int> > resv;     for (int i = 0; i < n2; i++) {       resv.push_back(sv[i]);     }     reverse(resv.begin(), resv.end());     for (int i = 0; i < n2; i++) {       cout <<  S   << resv[i].first <<     << resv[i].second <<   n ;     }     for (int i = 0; i < n1; i++) {       cout <<  B   << bv[i].first <<     << bv[i].second <<   n ;     }     return 0;   }   