#include <iostream>
#include <vector>
#include <future>

long psum(long *v, size_t offset, size_t n) {
  long result = 0;
  for (size_t i = 0; i < n; ++i) result += v[offset + i];
  return result;
}

int main() {
  std::vector<long> v(10000, 1);
  auto p0 = std::async(psum, &v[0], 0, v.size() / 2);
  auto p1 = std::async(psum, &v[0], v.size() / 2, v.size() - v.size() / 2);
  std::cout << "result: " << p0.get() + p1.get() << std::endl;
}