#include <vector>
#include <tuple>
#include <algorithm>
#include <type_traits>
template<class T>
using Invoke = typename T::type;
template<class T>
using Unqualified = Invoke<std::remove_cv<Invoke<std::remove_reference<T>>>>;
template<class T>
using ValueType = typename Unqualified<T>::value_type;
template<class T>
T const& forward_index(std::vector<T> const& v, unsigned i){
return v[i];
}
template<class T>
T&& forward_index(std::vector<T>&& v, unsigned i){
return std::move(v[i]);
}
template<class... Vs>
std::vector<std::tuple<ValueType<Vs>...>> zip(Vs&&... vs){
auto lo = std::min({vs.size()...});
std::vector<std::tuple<ValueType<Vs>...>> v;
v.reserve(lo);
for(unsigned i = 0; i < lo; ++i)
v.emplace_back(forward_index(std::forward<Vs>(vs), i)...);
return v;
}
#include <iostream>
int main(){
std::vector<int> a{1,3,5}, b{2,4,6}, c{3,5,7};
for(auto&& t : zip(a, b, c)){
std::cout << std::get<0>(t) << ":" << std::get<1>(t) << ":" << std::get<2>(t) << "\n";
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHR1cGxlPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dHlwZV90cmFpdHM+Cgp0ZW1wbGF0ZTxjbGFzcyBUPgp1c2luZyBJbnZva2UgPSB0eXBlbmFtZSBUOjp0eXBlOwoKdGVtcGxhdGU8Y2xhc3MgVD4KdXNpbmcgVW5xdWFsaWZpZWQgPSBJbnZva2U8c3RkOjpyZW1vdmVfY3Y8SW52b2tlPHN0ZDo6cmVtb3ZlX3JlZmVyZW5jZTxUPj4+PjsKCnRlbXBsYXRlPGNsYXNzIFQ+CnVzaW5nIFZhbHVlVHlwZSA9IHR5cGVuYW1lIFVucXVhbGlmaWVkPFQ+Ojp2YWx1ZV90eXBlOwoKdGVtcGxhdGU8Y2xhc3MgVD4KVCBjb25zdCYgZm9yd2FyZF9pbmRleChzdGQ6OnZlY3RvcjxUPiBjb25zdCYgdiwgdW5zaWduZWQgaSl7CiAgICByZXR1cm4gdltpXTsKfQoKdGVtcG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