// sum for k=1..n of {k*(k+1) if it does not divide by 4} #include #include #include using namespace std; int main () { int n; cin >> n; auto ans = ranges::iota_view (1) | views::take (n) | views::transform ([] (int x) {return x * (x + 1);}) | views::filter ([] (int x) {return x % 4 != 0;}) | views::common; auto s = accumulate (ans.begin (), ans.end (), 0LL); cout << s << endl; return 0; }