#include <iostream>
#include <tuple>
#include <vector>
#include <string>
#include <cstdint>
typedef std::vector<std::string> SType;
typedef std::tuple<char, std::uint64_t> DType;
typedef std::vector<DType> SDType;
typedef std::vector<SDType> RType;
SDType Comp(std::string& S){
char C = S[0];
std::uint64_t N=0;
SDType R;
for (auto& o : S){
if (C != o){
R.push_back(std::make_tuple(C, N));
C = o;
N = 0;
}
N++;
}
R.push_back(std::make_tuple(C, N));
return R;
}
RType MakeHoge(SType& S){
RType R;
for (auto&o : S){
R.push_back(Comp(o));
}
return R;
}
bool Show(SType& S,RType& R){
char C='\0';
std::uint64_t N=0;
for (auto& o : S){
std::cout <<o<<std::endl;
}
for (auto& oo : R){
for (auto& o : oo){
std::tie(C, N) = o;
std::cout << C << N;
}
std::cout << std::endl;
}
std::cout << std::endl;
return true;
}
int main(){
SType S;
RType R;
SType S1{ "aabbcc" };
S = S1;
R = MakeHoge(S);
Show(S,R);
SType S2{ "abcde","aabbb" };
S = S2;
R = MakeHoge(S);
Show(S,R);
SType S3{ "aaa","bbb","ccc" };
S = S3;
R = MakeHoge(S);
Show(S,R);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxjc3RkaW50PgoKdHlwZWRlZiBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gU1R5cGU7CnR5cGVkZWYgc3RkOjp0dXBsZTxjaGFyLCBzdGQ6OnVpbnQ2NF90PiBEVHlwZTsKdHlwZWRlZiBzdGQ6OnZlY3RvcjxEVHlwZT4gU0RUeXBlOwp0eXBlZGVmIHN0ZDo6dmVjdG9yPFNEVHlwZT4gUlR5cGU7CgpTRFR5cGUgQ29tcChzdGQ6OnN0cmluZyYgUyl7CgljaGFyIEMgPSBTWzBdOwoJc3RkOjp1aW50NjRfdCBOPTA7CglTRFR5cGUgUjsKCglmb3IgKGF1dG8mI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