Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
using ll = long long;
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    //vector<vector<int>> d(N, vector<int>(1000000000, -1));
    vector<vector<map<char, int>>> d(M, vector<map<char, int>>);
    vector<string> ans(M);
    int p, y;
    for (int i = 0; i < M; i++)
    {
        cin >> p >> y;
        d[p - 1].push_back(map<char, int>(y, i));
    }
    for (int i = 0; i < M; i++)
    {
        int k = 1;
        for (auto itr = d[i].begin(); itr != d[i].end(); ++itr)
        {
            stringstream sout, sout2;
            sout << setfill('0') << setw(6) << i + 1;
            sout2 << setfill('0') << setw(6) << k;
            ans[itr->second] = sout.str() + sout2.str();
            k++;
        }
    }
    for (auto v : ans)
        cout << v << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:63: error: expected primary-expression before ')' token
   18 |     vector<vector<map<char, int>>> d(M, vector<map<char, int>>);
      |                                                               ^
a.cc:34:22: error: 'class std::map<char, int>' has no member named 'second'
   34 |             ans[itr->second] = sout.str() + sout2.str();
      |                      ^~~~~~
In file included from /usr/include/c++/14/map:63,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = char; _Tp = int; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, int> >]':
a.cc:24:47:   required from here
   24 |         d[p - 1].push_back(map<char, int>(y, i));
      |                                               ^
/usr/include/c++/14/bits/stl_map.h:287:38: error: no matching function for call to 'std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int> >, std::less<char>, std::allocator<std::pair<const char, int> > >::_M_insert_range_unique(int&, int&)'
  287 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1096:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = char; _Val = std::pair<const char, int>; _KeyOfValue = std::_Select1st<std::pair<const char, int> >; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, int> >]'
 1096 |         _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1096:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<std::pair<const char, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int> >, std::less<char>, std::allocator<std::pair<const char, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]':
/usr/include/c++/14/bits/stl_map.h:287:31:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = char; _Tp = int; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, int> >]'
  287 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:24:47:   required from here
   24 |         d[p - 1].push_back(map<char, int>(y, i));
      |                                               ^
/usr/include/c++/14/bits/stl_tree.h:1095:58: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
 1095 |         __enable_if_t<__same_value_type<_InputIterator>::value>
      |                                                          ^~~~~
/usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = char; _Tp = int; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, int> >]':
a.cc:24:47:   required from here
   24 |         d[p - 1].push_back(map<char, int>(y, i));
      |                                               ^
/usr/include/c++/14/bits/stl_tree.h:1105:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = char; _Val = std::pair<const char, int>; _KeyOfValue = std::_Select1st<std::pair<const char, int> >; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, int> >]'
 1105 |         _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1105:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<std::pair<const char, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value)), void> std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int> >, std::less<char>, std::allocator<std::pair<const char, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]':
/usr/include/c++/14/bits/stl_map.h:287:31:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = char; _Tp = int; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, int> >]'
  287 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:24:47:   required from here
   24 |         d[p - 1].push_back(map<char, int>(y, i));
      |                                               ^
/usr/include/c++/14/bits/stl_tree.h:1104:59: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
 1104 |         __enable_if_t<!__same_value_type<_InputIterator>::value>
      |                                                           ^~~~~