#include <iostream>
#include <numeric>
#include <vector>
#define fold(a,x,f) std::accumulate(begin(a),end(a),(x),(f))
template<class T>typename T::value_type join(T const& c){typedef typename T::value_type U;return fold(c,U(),std::plus<U>());};
using namespace std;
int main() {
vector<int> a = {10, 20, 30};
vector<string> b = {"hel", "lo wo", "rld"};
cout << join(a) << endl;
cout << join(b) << endl;
cout << fold(a, 0, [](int x, int y){return x+y;}) << endl;
cout << fold(b, string(), [](string x, string y){return x+y;}) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bnVtZXJpYz4KI2luY2x1ZGUgPHZlY3Rvcj4KCiNkZWZpbmUgZm9sZChhLHgsZikgc3RkOjphY2N1bXVsYXRlKGJlZ2luKGEpLGVuZChhKSwoeCksKGYpKQp0ZW1wbGF0ZTxjbGFzcyBUPnR5cGVuYW1lIFQ6OnZhbHVlX3R5cGUgam9pbihUIGNvbnN0JiBjKXt0eXBlZGVmIHR5cGVuYW1lIFQ6OnZhbHVlX3R5cGUgVTtyZXR1cm4gZm9sZChjLFUoKSxzdGQ6OnBsdXM8VT4oKSk7fTsKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICB2ZWN0b3I8aW50PiBhID0gezEwLCAyMCwgMzB9OwogIHZlY3RvcjxzdHJpbmc+IGIgPSB7ImhlbCIsICJsbyB3byIsICJybGQifTsKICBjb3V0IDw8IGpvaW4oYSkgPDwgZW5kbDsKICBjb3V0IDw8IGpvaW4oYikgPDwgZW5kbDsKICBjb3V0IDw8IGZvbGQoYSwgMCwgW10oaW50IHgsIGludCB5KXtyZXR1cm4geCt5O30pIDw8IGVuZGw7CiAgY291dCA8PCBmb2xkKGIsIHN0cmluZygpLCBbXShzdHJpbmcgeCwgc3RyaW5nIHkpe3JldHVybiB4K3k7fSkgPDwgZW5kbDsKICByZXR1cm4gMDsKfQ==