template <typename T> void remove(std::vector<T>& v, std::size_t i) { std::swap(v[i], v.back()); v.resize(v.size() - 1); }