#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
#include <map>
typedef std::vector<std::int64_t> DType;
typedef std::map<std::uint64_t, std::uint64_t> MType;
std::int64_t MakeHoge2(const DType& D) {
MType M;
for (auto& o : D) {
M[o]++;
}
for (auto& o : M) {
if (o.second == 1) {
return o.first;
}
}
return -1;
}
/** /
DType::value_type MakeHoge(DType D) {
std::sort(D.begin(), D.end());
std::size_t i = 0;
for (i = 1; i < D.size() - 1; i++) {
if (D[i - 1] != D[i]) {
if (D[i] == D[i + 1])continue;
return D[i];
}
}
if (D[i] != D[i - 1])return D[i];
return -1;
}
/**/
int main() {
DType D = { 1,1,1,1,2,2,2,3,3,4 };
std::cout << MakeHoge2(D) << std::endl;
D = DType{ 1,2,3,4,5,5,4,3,2,1 };
std::cout << MakeHoge2(D) << std::endl;
D = DType{ 3,1,4,1,5,9,2,6,5,3,5 };
std::cout << MakeHoge2(D) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y3N0ZGludD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPG1hcD4KCnR5cGVkZWYgc3RkOjp2ZWN0b3I8c3RkOjppbnQ2NF90PiBEVHlwZTsKCnR5cGVkZWYgc3RkOjptYXA8c3RkOjp1aW50NjRfdCwgc3RkOjp1aW50NjRfdD4gTVR5cGU7CgpzdGQ6OmludDY0X3QgTWFrZUhvZ2UyKGNvbnN0IERUeXBlJiBEKSB7CglNVHlwZSBNOwoKCWZvciAoYXV0byYgbyA6IEQpIHsKCQlNW29dKys7Cgl9Cglmb3IgKGF1dG8mIG8gOiBNKSB7CgkJaWYgKG8uc2Vjb25kID09IDEpIHsKCQkJcmV0dXJuIG8uZmlyc3Q7CgkJfQoJfQoJcmV0dXJuIC0xOwoKfQoKCi8qKiAvCkRUeXBlOjp2YWx1ZV90eXBlIE1ha2VIb2dlKERUeXBlIEQpIHsKCglzdGQ6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