#include <iostream>
#include <vector>

typedef std::vector<int> DType;

int Count(DType& vec, std::size_t N, std::size_t idx){
	size_t i;
	for (i = idx; i < vec.size(); i++)
	{
		if (vec[i] != N)return i - idx;
	}

	return i - idx;
}
bool Copy(DType& Dest,DType& Src, std::size_t N,std::size_t idx){
	for (size_t i = idx; i < Src.size(); i++)
	{
		if (Src[i] != N)return true;
		Dest.push_back(Src[i]);
	}

	return true;;
}
bool Erase(DType& vec, std::size_t N, std::size_t idx){

	int C = Count(vec, vec[idx], idx);

	for (size_t i =0; i < vec.size()-idx-C; i++)
	{
		vec[idx + i] = vec[idx + C + i];
	}

	vec.resize(vec.size() - C);

	return true;
}

std::vector<DType> MakeHoge(DType vec){
	std::size_t C = 0;
	std::size_t Idx = 0;
	DType Res = Res;
	std::vector<DType> R;
	size_t i = 0;
	bool F = false;

	do{
		R.push_back(vec);
		F = false;
		for (size_t i = 0; i < vec.size(); i++)
		{
			C = Count(vec, vec[i], i);
			if (C >= 4){
				Erase(vec, vec[i], i);
				F = true;
				break;
			}
			i += C-1;
		}
		
	} while (F);
	//R.pop_back();
	return R;
}

bool ShowOut(std::vector<DType>& vec){
	std::cout << "out:" << std::endl;
	for (auto& oo : vec){
		for (auto& o : oo) std::cout << o;
		if (oo.size() == 0) std::cout << "[None]";
		std::cout << std::endl;
	}
	std::cout << std::endl;
	return true;
}
bool ShowIn(const DType& vec){
	std::cout << "in:";
	for (auto& o : vec) std::cout << o;
	std::cout << std::endl;
	return true;
}

int main(){

	std::vector<DType> R;

	auto A{ 1, 1, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 1, 1, 1, 1, 1, 4, 3, 3, 2, 2, 2, 1, 1, };
	R = MakeHoge(A);
	ShowIn(A);
	ShowOut(R);

	auto B{ 1, 1, 2, 2, 2, 2, 4, 4, 1, 1, 1, 1, 2, 2, 2, 2, };
	R = MakeHoge(B);
	ShowIn(B);
	ShowOut(R);

	auto C{ 2,1,1,2,2,2,2,1,1,3,3,3,3,1,2, };
	R = MakeHoge(C);
	ShowIn(C);
	ShowOut(R);

	return 0;
}