func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int vs, ve;     int t, d;     cin >> vs >> ve >> t >> d;     int cur = vs;     int sm = vs;     int pre = vs;     for (int i = 2; i <= t; i++) {       while (cur < ve && abs(pre - cur) < d) cur++;       if (cur >= ve) {         while ((t - i) * d > cur - ve && abs(pre - cur) < d) cur++;         while ((t - i) * d < cur - ve && abs(pre - cur) < d) cur--;       }       pre = cur;       sm += cur;     }     assert(cur == ve);     cout << sm;     return 0;   }   