std::accumulatehas a small trap, which is the initial value that you pass. It can be easily overlooked that this value is used to display a parameter Tthat is also a return type (and the return type is not , namely the value_typecontainer). Correct it by passing long longas the initial value:
    sum = accumulate(v.begin(),v.end(),(long long)0);
or for paranoids (sorry, just jokes with raw castes are really not good):
    sum = accumulate(v.begin(),v.end(),0LL);
 source
share