func_code_string: #include <bits/stdc++.h>   const double PI = acos(-1.0);   using namespace std;   int t[100010];   void update(int x, int v) {     for (; x < 100010; x += (x & -x)) t[x] += v;   }   int sum(int r) {     int ans = 0;     for (; r > 0; r -= (r & -r)) ans += t[r];     return ans;   }   int sum(int l, int r) {     if (l > r) swap(l, r);     return sum(r) - sum(l - 1);   }   int main() {     int n, q;     scanf( %d %d , &n, &q);     for (int i = 1; i <= n; ++i) update(i, 1);     int ll = 0, rr = n, dir = 1;     while (q--) {       int type;       scanf( %d , &type);       if (type == 1) {         int p;         scanf( %d , &p);         if (2 * p <= abs(ll - rr)) {           for (int j = 1; j <= p; ++j) {             int w = sum(ll + j * dir, ll + j * dir);             update(ll + j * dir, -w);             update(ll + (2 * p - j + 1) * dir, w);           }           ll += p * dir;         } else {           for (int j = abs(ll - rr); j > p; --j) {             int w = sum(ll + j * dir, ll + j * dir);             update(ll + j * dir, -w);             update(ll + (2 * p - j + 1) * dir, w);           }           ll += (p + 1) * dir;           rr = ll - p * dir;           dir *= -1;         }       } else {         int l, r;         scanf( %d %d , &l, &r);         printf( %d n , sum(ll + (l + 1) * dir, ll + r * dir));       }     }     return 0;   }   