#include <iostream>
#include <map>
#include <cstdint>
#include <tuple>
#include <string>
static const char pa = 'p';
static const char gu = 'g';
static const char choki = 'c';
typedef std::tuple<std::string, std::uint64_t> RType;
typedef std::map<char, std::uint64_t> MType;
RType MakeHoge(std::string s){
bool P = false;
bool G = false;
bool C = false;
MType M;
for(auto& o : s){
M[o]++;
if (o == pa) P = true;
if (o == gu) G = true;
if (o == choki)C = true;
}
if (P & !G & !C) return std::make_tuple("PNone", M[pa]);
if (!P & G & !C) return std::make_tuple("GNone", M[gu]);
if (!P & !G & C) return std::make_tuple("CNone", M[choki]);
if (P & G & C) return std::make_tuple("None", 0);
if (P & G) return std::make_tuple("P", M[pa]);
if (G & C) return std::make_tuple("G", M[gu]);
if (C & P) return std::make_tuple("C", M[choki]);
return std::make_tuple("Error", -1);
}
bool Show(std::string str, RType R){
std::string S;
std::uint64_t N;
std::tie(S, N) = R;
std::cout << str << " -> " << S << '@' << N << std::endl;
return true;
}
int main(){
std::string S;
RType R;
S = "gpgpgppppg";
R = MakeHoge(S);
Show(S, R);
S = "gcgcgcgcgcggcgccgcgcg";
R = MakeHoge(S);
Show(S, R);
S = "ccpcpppcccpppcppcpcc";
R = MakeHoge(S);
Show(S, R);
S = "ggcgcgcggggcpgcggcgcggggcgcgcc";
R = MakeHoge(S);
Show(S, R);
S = "ppp";
R = MakeHoge(S);
Show(S, R);
S = "cccc";
R = MakeHoge(S);
Show(S, R);
S = "gggggg";
R = MakeHoge(S);
Show(S, R);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8Y3N0ZGludD4KI2luY2x1ZGUgPHR1cGxlPgojaW5jbHVkZSA8c3RyaW5nPgoKc3RhdGljIGNvbnN0IGNoYXIgcGEgPSAncCc7CnN0YXRpYyBjb25zdCBjaGFyIGd1ID0gJ2cnOwpzdGF0aWMgY29uc3QgY2hhciBjaG9raSA9ICdjJzsKCnR5cGVkZWYgc3RkOjp0dXBsZTxzd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