Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <utility>
#include <sstream>
#include <iomanip>
#include <string>

typedef std::tuple<long long ,long long , int, string> llis;

int main(){
  int N , M;
  std::cin >> N >> M;
  std::vector<llis> v(M);
  for(int i = 0 ; i < M ; i++){
    std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
    std::get<2>(v[i]) = i;
    std::get<3>(v[i]) = "";
  }

  std::sort(v.begin(), v.end(),
	    [](llis &x , llis &y){
	      return (std::get<0>(x) == std::get<0>(y))?(std::get<1>(x) < std::get<1>(y)):(std::get<0>(x)<std::get<0>(y));});
  
  for(int i = 0 ; i < (int)v.size() ; i++){
    std::cout << std::get<0>(v[i]) <<" "<<  std::get<1>(v[i]) <<" "<< std::get<2>(v[i]);
    std::cout << std::endl;
  }
  long long city  = 1;
  long long count = 1;
  for(int i = 0 ; i < (int)v.size() ; i++){
    long long first = std::get<0>(v[i]);
    if(first != city){
      city = first;
      count = 1;
    }
    if(first == city){
      std::ostringstream oss;
      oss << std::setw(6) << std::setfill('0') << first << std::setw(6) << std::setfill('0') << count;
      std::get<3>(v[i]) = oss.str();
      count++;
    }
  }
  std::sort(v.begin(), v.end(), [](llis &x, llis &y){return std::get<2>(x) < std::get<2>(y);});
  for(int i = 0 ; i < (int)v.size() ; i++){
    std::cout<<std::get<3>(v[i])<<std::endl;
  }
  return 0;
}


Compiler output:
a.cc:11:48: error: 'string' was not declared in this scope
   11 | typedef std::tuple<long long ,long long , int, string> llis;
      |                                                ^~~~~~
a.cc:11:48: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:11:54: error: template argument 4 is invalid
   11 | typedef std::tuple<long long ,long long , int, string> llis;
      |                                                      ^
a.cc: In function 'int main()':
a.cc:18:28: error: no matching function for call to 'get<0>(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
 1250 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
 1255 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
 1260 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
 1265 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
 2445 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2445:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'std::tuple<_Elements ...>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
 2451 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2451:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'const std::tuple<_Elements ...>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
 2457 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2457:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'std::tuple<_Elements ...>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
 2466 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2466:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'const std::tuple<_Elements ...>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
  138 |     get(array<_Tp, _Nm>&) noexcept;
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'std::array<_Tp, _Nm>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
  142 |     get(array<_Tp, _Nm>&&) noexcept;
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'std::array<_Tp, _Nm>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:146:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
  146 |     get(const array<_Tp, _Nm>&) noexcept;
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:146:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'const std::array<_Tp, _Nm>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:150:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
  150 |     get(const array<_Tp, _Nm>&&) noexcept;
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:150:5: note:   template argument deduction/substitution failed:
a.cc:18:28: note:   mismatched types 'const std::array<_Tp, _Nm>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
 1272 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note:   template argument deduction/substitution failed:
a.cc:18:28: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
   18 |     std::cin >> std::get<0>(v[i]) >> std::get<1>(v[i]);
      |                 ~~~~~~~~~~~^~~~~~
a.cc:18:28: note:   expected a type, got '0'
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
 1277 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note:   template argument deduction/substitution failed:
a.cc:18:28: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
   18 |     std::cin >> std