#include <iostream>
using namespace std;

template < class Count >
struct Counter {
	using count_type = Count;
	count_type instances = 0;
	
	template <Counter& c>
	struct Counted {
		using id_type = count_type;
		id_type id;
		Counted() : id(c.instances) { ++c.instances; }
		~Counted() { --c.instances; }
		
		friend std::ostream& operator<<(std::ostream& os, const Counted& lol) {
			os << "printing inner " << lol.id;
			return os;
		}
	};
};

using SCounter = Counter<std::size_t>;
SCounter sc;
using SCounted = SCounter::Counted<sc>;

int main() {
	// your code goes here
	SCounted i, j, k; // --> ok, works fine
	std::cout << j << std::endl;
	return 0;
}