Language: C++

import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);
	auto M = to!ulong(tokens[1]);

	ulong[] P, Y;
	P.length = N;
	Y.length = N;
	ulong[][] county;
	county.length = N;
	foreach (i; 0..M)
	{
		auto tokens2 = split(my_readln());
		P[i] = to!ulong(tokens2[0]) - 1;
		Y[i] = to!ulong(tokens2[1]);
		county[P[$-1]] ~= cast(ulong)i;
	}

	foreach (ref e; county)
	{
		sort!((ulong a, ulong b){ return Y[a] < Y[b]; })(e);
	}

	ulong digit(ulong x)
	{
		ulong d;
		while (x)
		{
			x /= 10;
			++d;
		}
		return d;
	}

	string[] zero = ["000000", "00000", "0000", "000", "00", "0"];

	foreach (i, e; P)
	{
		string result;
		result ~= zero[digit(e+1)];
		result ~= to!string(e+1);

		auto c = county[e];
		auto pos = countUntil(c, i) + 1;
		result ~= zero[digit(pos)];
		result ~= to!string(pos);

		writeln(result);
	}

	stdout.flush();
}

Compiler output:
a.cc:22:21: error: too many decimal points in number
   22 |         foreach (i; 0..M)
      |                     ^~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import std.stdio;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import std.algorithm;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import std.conv;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import std.datetime;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import std.numeric;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import std.math;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import std.string;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'string' does not name a type
    9 | string my_readln() { return chomp(readln()); }
      | ^~~~~~
a.cc:11:1: error: '::main' must return 'int'
   11 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:13:29: error: 'my_readln' was not declared in this scope
   13 |         auto tokens = split(my_readln());
      |                             ^~~~~~~~~
a.cc:13:23: error: 'split' was not declared in this scope
   13 |         auto tokens = split(my_readln());
      |                       ^~~~~
a.cc:14:18: error: 'to' was not declared in this scope
   14 |         auto N = to!ulong(tokens[0]);
      |                  ^~
a.cc:15:20: error: expected ',' or ';' before '!' token
   15 |         auto M = to!ulong(tokens[1]);
      |                    ^
a.cc:17:9: error: 'ulong' was not declared in this scope; did you mean 'long'?
   17 |         ulong[] P, Y;
      |         ^~~~~
      |         long
a.cc:17:15: error: expected primary-expression before ']' token
   17 |         ulong[] P, Y;
      |               ^
a.cc:18:9: error: 'P' was not declared in this scope
   18 |         P.length = N;
      |         ^
a.cc:19:9: error: 'Y' was not declared in this scope
   19 |         Y.length = N;
      |         ^
a.cc:20:15: error: expected primary-expression before ']' token
   20 |         ulong[][] county;
      |               ^
a.cc:20:17: error: expected primary-expression before ']' token
   20 |         ulong[][] county;
      |                 ^
a.cc:21:9: error: 'county' was not declared in this scope
   21 |         county.length = N;
      |         ^~~~~~
a.cc:22:18: error: 'i' was not declared in this scope
   22 |         foreach (i; 0..M)
      |                  ^
a.cc:30:18: error: 'ref' was not declared in this scope
   30 |         foreach (ref e; county)
      |                  ^~~
a.cc:30:31: error: expected ';' before ')' token
   30 |         foreach (ref e; county)
      |                               ^
      |                               ;
a.cc:35:14: error: expected ';' before 'digit'
   35 |         ulong digit(ulong x)
      |              ^~~~~~
      |              ;
a.cc:46:9: error: 'string' was not declared in this scope
   46 |         string[] zero = ["000000", "00000", "0000", "000", "00", "0"];
      |         ^~~~~~
a.cc:46:16: error: expected primary-expression before ']' token
   46 |         string[] zero = ["000000", "00000", "0000", "000", "00", "0"];
      |                ^
a.cc:48:21: error: 'e' was not declared in this scope
   48 |         foreach (i, e; P)
      |                     ^
a.cc:48:25: error: expected ';' before ')' token
   48 |         foreach (i, e; P)
      |                         ^
      |                         ;
a.cc:62:9: error: 'stdout' was not declared in this scope
   62 |         stdout.flush();
      |         ^~~~~~
a.cc:1:1: note: 'stdout' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | import std.stdio;