#include <iostream>
#include <numeric>
#include <vector>

int main()
{
    std::vector<int> v { 1, 2, 3, 4, 5 };
    int sum = std::accumulate(v.begin(), v.end(), 0);

    // What is the type of std::multiplies<int>()
    int product = std::accumulate(v.begin(), v.end(), 1, std::multiplies<int>());
    (void)product; // dummy line

    auto midpoint = v.begin() + static_cast<int>(v.size() / 2);
    // This looks a lot harder to read. Why might it be better?

    auto midpoint11 = std::next(v.begin(), std::distance(v.begin(), v.end()) / 2);
    (void)midpoint11;

    int sum2 = std::accumulate(v.begin(), midpoint, 0);

    std::cout << sum << " " << sum2 << "\n";
}
