Problem p03030 (C++)

Buggy submission (status: Runtime Error):
//  ROAD TO GREEN
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack()                                                            \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define do(x)                                                                  \
  for (int i = 1; i <= x; i++) {                                               \
    solve();                                                                   \
  }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9 + 2;
const ll SIZE = 1e5 + 2;
const ll mod = 1e9 + 7;

bool cmp(pair<string, int> a, pair<string, int> b) {
  if (a.first < b.first)
    return true;
  else if (a.first == b.first) {
    return a.second > b.second;
  }
}

void solve() {
  int n;
  cin >> n;
  vector<pair<string, int>> v;
  map<pair<string, int>, int> mapp;
  ;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    int a;
    cin >> a;
    v.push_back(mp(s, a));
    mapp[v[i - 1]] = i;
  }
  sort(all(v), cmp);
  for (int i = 0; i < s(v); i++) {
    cout << mapp[v[i]] << endl;
  }
}

int main() {
  speedhack()
      // int it; cin >> it;
      int it = 1;
  do
    (it);
  return 0;
}


Fixed submission:
//  ROAD TO GREEN
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack()                                                            \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define do(x)                                                                  \
  for (int i = 1; i <= x; i++) {                                               \
    solve();                                                                   \
  }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9 + 2;
const ll SIZE = 1e5 + 2;
const ll mod = 1e9 + 7;

bool cmp(pair<string, int> a, pair<string, int> b) {
  if (a.first < b.first)
    return true;
  else if (a.first == b.first) {
    return a.second > b.second;
  } else {
    return false;
  }
}

void solve() {
  int n;
  cin >> n;
  vector<pair<string, int>> v;
  map<pair<string, int>, int> mapp;
  ;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    int a;
    cin >> a;
    v.push_back(mp(s, a));
    mapp[v[i - 1]] = i;
  }
  sort(all(v), cmp);
  for (int i = 0; i < s(v); i++) {
    cout << mapp[v[i]] << endl;
  }
}

int main() {
  speedhack()
      // int it; cin >> it;
      int it = 1;
  do
    (it);
  return 0;
}