func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   const int mod = 1e9 + 7;   int a[N];   long long fac[30];   long long sum[N];   long long Contor(int* a, int n) {     long long res = 0;     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = i + 1; j <= n; j++)         if (a[i] > a[j]) cnt++;       res += cnt * fac[n - i];     }     return res;   }   void ReContor(int* a, int n, long long k, int ed) {     int vis[30] = {0};     for (int i = 1; i <= n; i++) {       int cnt = k / fac[n - i], j;       for (j = 1; j <= n; j++)         if (!vis[j]) {           if (!cnt) break;           cnt--;         }       vis[j] = 1;       a[i] = ed + j;       k %= fac[n - i];     }   }   void init() {     fac[0] = 1;     for (int i = 1; i <= 20; i++) fac[i] = fac[i - 1] * i;   }   int main() {     init();     int n, q;     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + i;     int m = 15, ed = n - 15;     if (n < 15) m = n, ed = 0;     for (int i = 1; i <= m; i++) a[i] = ed + i;     long long cnt = 0;     while (q--) {       int op;       scanf( %d , &op);       if (op == 1) {         int l, r;         scanf( %d%d , &l, &r);         printf( %lld n , sum[r] - sum[l - 1]);       } else {         int x;         scanf( %d , &x);         cnt += x;         ReContor(a, m, cnt, ed);         for (int i = 1; i <= m; i++) sum[ed + i] = sum[ed + i - 1] + a[i];         for (int i = 1; i <= m; i++) a[i] = ed + i;       }     }     return 0;   }   