func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > vec;   void update() {     int x;     scanf( %d , &x);     vector<pair<int, int> > a, b;     a.push_back({1000010, 0});     b.push_back({1000010, 0});     a.push_back({0, 0});     b.push_back({0, 0});     int sz = vec.size();     for (int i = 0; i + 1 < sz; i++) {       int p = x - vec[i].first;       if (p > 0) a.push_back({p, vec[i + 1].second});       if (p < 0) b.push_back({-p, vec[i].second});     }     sort(a.begin(), a.end());     sort(b.begin(), b.end());     vec.clear();     int i = 0, j = 0;     int as = a.size(), bs = b.size();     while (i < as || j < bs) {       if (a[i].first == b[j].first) {         vec.push_back({a[i].first, a[i].second + b[j].second});         i++, j++;       } else if (a[i].first < b[j].first) {         vec.push_back({a[i].first, a[i].second + b[j].second});         i++;       } else {         vec.push_back({b[j].first, a[i].second + b[j].second});         j++;       }     }     vec[0].second = 0;     return;   }   void qry() {     int s, e, ans = 0;     scanf( %d %d , &s, &e);     int sz = vec.size();     for (auto cur : vec) {       if (e > cur.first) {         if (cur.first > s) {           ans += cur.second * (cur.first - s);           s = cur.first;         }       } else {         ans += cur.second * (e - s);         break;       }     }     printf( %d n , ans);     return;   }   int main() {     int n, q;     scanf( %d %d , &n, &q);     vec.push_back({0, 0});     vec.push_back({n, 1});     vec.push_back({1000010, 0});     while (q--) {       int type;       scanf( %d , &type);       if (type == 1)         update();       else         qry();     }     return 0;   }   