func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   int tree[4 * N];   int n, m;   void update(int root, int lo, int hi, int u, int v) {     if (v < lo || u > hi) return;     if (u <= lo && hi <= v) {       tree[root]++;       return;     }     int mid = (lo + hi) / 2, left = root * 2, right = left + 1;     update(left, lo, mid, u, v);     update(right, mid + 1, hi, u, v);     tree[root] = tree[left] + tree[right];   }   int query(int root, int lo, int hi, int u, int v) {     if (v < lo || u > hi) return 0;     if (u <= lo && hi <= v) return tree[root];     int mid = (lo + hi) / 2, left = root * 2, right = left + 1;     return query(left, lo, mid, u, v) + query(right, mid + 1, hi, u, v);   }   int main() {     scanf( %d%d , &n, &m);     int i, cur = 0, next, start, end, p1, p2;     long long ans = 1;     for (i = 1; i <= n; ++i) {       next = (cur + m) % n;       start = min(cur, next) + 1;       end = max(cur, next) + 1;       p1 = query(1, 1, n, start + 1, end - 1);       p2 = 2 * (i - 1) - query(1, 1, n, start, start) - query(1, 1, n, end, end) -            p1;       ans += min(p1, p2) + 1;       update(1, 1, n, start, start);       update(1, 1, n, end, end);       cur = next;       printf( %lld  , ans);     }     printf(  n );     return 0;   }   