Language: C++

#include <bits/stdc++.h>
#include <queue>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    vector<vector<int>> v(M, vector<int>(3));
    REP(i, M) {
        cin >> v[i][0] >> v[i][1];
        v[i][2] = i;
    }
    sort(ALL(v));
    int tmp = v[0][0], counter = 1;
    REP(i, M) {
        if (tmp != v[i][0]) {
            tmp = v[i][0];
            counter = 1;
        }
        v[i][1] = counter;
        swap(v[i][0], v[i][2]);
        counter++;
    }
    sort(ALL(v));
    REP(i, M) {
        cout << setfill('0') << right << setw(6) << v[i][2] << setfill('0') << right
            << setw(6) << v[i][1] << "\n";
    }
#include <bits/stdc++.h>
#include <queue>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    vector<vector<int>> v(M, vector<int>(3));
    REP(i, M) {
        cin >> v[i][0] >> v[i][1];
        v[i][2] = i;
    }
    sort(ALL(v));
    int tmp = v[0][0], counter = 1;
    REP(i, M) {
        if (tmp != v[i][0]) {
            tmp = v[i][0];
            counter = 1;
        }
        v[i][1] = counter;
        swap(v[i][0], v[i][2]);
        counter++;
    }
    sort(ALL(v));
    REP(i, M) {
        cout << setfill('0') << right << setw(6) << v[i][2]
            << setfill('0') << right << setw(6) << v[i][1] << "\n";
    }

    return 0;
}


    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:60:1: error: a template declaration cannot appear at block scope
   60 | template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
      | ^~~~~~~~
a.cc:63:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   63 | int main() {
      |         ^~
a.cc:63:9: note: remove parentheses to default-initialize a variable
   63 | int main() {
      |         ^~
      |         --
a.cc:63:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:63:12: error: a function-definition is not allowed here before '{' token
   63 | int main() {
      |            ^