func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1 << 23;   const int offset = (int)1e6;   int st_sum[2 * N];   int st_ma[2 * N];   int getMax(int a, int b) {     a += N + offset;     b += N + offset;     int ma = -1e9;     int sum_a = 0;     int ma_b = 0;     for (; a < b; a /= 2, b /= 2) {       if (a % 2 == 1) {         ma = max(ma, st_ma[a] + sum_a);         sum_a += st_sum[a];         ++a;       }       if (b % 2 == 0) {         ma_b = max(ma_b + st_sum[b], st_ma[b]);         --b;       }     }     if (a == b) {       ma = max(ma, st_ma[a] + sum_a);       sum_a += st_sum[a];     }     ma = max(ma, sum_a + ma_b);     return ma;   }   void updateSegtreePos(int pos) {     st_sum[pos] = st_sum[pos * 2] + st_sum[pos * 2 + 1];     st_ma[pos] = max(st_ma[pos * 2], st_sum[pos * 2] + st_ma[pos * 2 + 1]);   }   void addValue(int pos, int val) {     pos += N + offset;     st_sum[pos] += val;     st_ma[pos] += val;     for (pos /= 2; pos; pos /= 2) {       updateSegtreePos(pos);     }   }   set<int> pawns[(int)2e5 + 10];   multiset<int> intercept_ys;   int main() {     int n, k, m;     cin >> n >> k >> m;     for (int i = 0; i < N; ++i) {       st_sum[i + N] = -1;       st_ma[i + N] = -1;     }     for (int i = N - 1; i; --i) {       updateSegtreePos(i);     }     for (int i = 0; i < m; ++i) {       int x, y;       cin >> x >> y;       int intercept_y = (n - y) - abs(x - k);       if (pawns[x].count(y)) {         addValue(intercept_y, -1);         pawns[x].erase(y);         intercept_ys.erase(intercept_ys.find(intercept_y));       } else {         addValue(intercept_y, 1);         pawns[x].insert(y);         intercept_ys.insert(intercept_y);       }       if (intercept_ys.size()) {         cout << max(0, getMax(*intercept_ys.begin(), n) - *intercept_ys.begin())              << endl;       } else {         cout << 0 << endl;       }     }   }   