malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200200;   int n;   int a[maxn], b[maxn], c[3][maxn];   int sum[maxn];   int lowbit(int x) { return x & (-x); }   void add(int p, int v = 1) {     for (int i = p; i <= n; i += lowbit(i)) sum[i] += v;   }   int get(int p) {     int ret = 0;     for (int i = p; i; i -= lowbit(i)) ret += sum[i];     return ret;   }   bool on[maxn];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , a + i);       a[i]++;       int before = get(a[i]);       c[0][i] = a[i] - 1 - before;       add(a[i]);     }     memset(sum, 0, sizeof(sum));     for (int i = 0; i < n; i++) {       scanf( %d , b + i);       b[i]++;       int before = get(b[i]);       c[1][i] = b[i] - 1 - before;       c[2][i] = c[0][i] + c[1][i];       add(b[i]);     }     for (int i = n - 1; i > 0; i--) {       int j = n - 1 - i;       if (c[2][i] > j) {         c[2][i] -= j + 1;         c[2][i - 1]++;       }     }     c[2][0] %= n;     memset(sum, 0, sizeof(sum));     memset(on, true, sizeof(on));     for (int i = 1; i <= n; i++) add(i);     vector<int> vi;     for (int i = 0; i < n; i++) {       int goal = c[2][i];       int low = 0, high = n, ans = -1;       while (low <= high) {         int mid = (low + high) / 2;         int s = get(mid);         if (s == goal) {           if (on[mid + 1] == true) {             ans = mid + 1;             break;           } else             low = mid + 1;         } else if (s < goal)           low = mid + 1;         else if (s > goal)           high = mid - 1;       }       on[ans] = false;       add(ans, -1);       vi.push_back(ans - 1);     }     for (int i = 0; i < n; i++) printf( %d  , vi[i]);     putchar(10);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vis[205][205];   int cnt;   vector<int> ans;   void dfs(int x, int y) {     if (x % 2 == 0 && y % 2 == 0) cnt++;     vis[x][y] = 1;     if (!vis[x + 1][y]) dfs(x + 1, y);     if (!vis[x][y + 1]) dfs(x, y + 1);     if (!vis[x - 1][y] && (x - 1 >= 0)) dfs(x - 1, y);     if (!vis[x][y - 1] && (y - 1 >= 0)) dfs(x, y - 1);   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int w, h, n;     cin >> w >> h >> n;     for (int i = 0; i <= w * 2; i++) {       vis[i][h * 2 - 1] = 1;     }     for (int i = 0; i <= h * 2; i++) {       vis[w * 2 - 1][i] = 1;     }     for (int i = 0; i < n; i++) {       int x0, y0, x1, y1;       cin >> x0 >> y0 >> x1 >> y1;       if (x0 == x1) {         x0 *= 2;         x0--;         for (int j = max(y0 * 2 - 1, 0); j <= y1 * 2 - 1; j++) {           vis[x0][j] = 1;         }       } else if (y0 == y1) {         y0 *= 2;         y0--;         for (int j = max(x0 * 2 - 1, 0); j <= x1 * 2 - 1; j++) {           vis[j][y0] = 1;         }       }     }     for (int i = 0; i <= w * 2 - 1; i++) {       for (int j = 0; j <= h * 2 - 1; j++) {         if (!vis[i][j]) {           dfs(i, j);           ans.push_back(cnt);           cnt = 0;         }       }     }     sort(ans.begin(), ans.end());     for (auto i : ans) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     bool remove = true;     int ans = 0;     while (remove) {       remove = false;       int idx;       char c =   0 ;       if (s.size() > 1) {         for (int i = 0; i < s.size(); i++) {           if (i > 0) {             if (i == s.size() - 1) {               if (s[i] - 1 == s[i - 1]) {                 remove = true;                 if (c < s[i]) {                   idx = i;                   c = s[i];                 }               }             } else {               if (s[i] - 1 == s[i - 1] || s[i] - 1 == s[i + 1]) {                 remove = true;                 if (c < s[i]) {                   idx = i;                   c = s[i];                 }               }             }           } else {             if (s[i] - 1 == s[i + 1]) {               remove = true;               if (c < s[i]) {                 idx = i;                 c = s[i];               }             }           }         }       }       if (remove) {         s.erase(s.begin() + idx);         ans++;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 50;   long long g[maxn];   int ans, n;   inline int ctz(long long s) {     return s ? __builtin_ctzll(s) : 8 * sizeof(long long);   }   void BronKerbosch(long long clique, long long allow, long long forbid) {     if (!allow && !forbid) {       ans = max(ans, __builtin_popcountll(clique));       return;     }     if (!allow) return;     int pivot = ctz(allow | forbid);     long long choose = allow & ~g[pivot];     for (int u = ctz(choose); u < n; u += ctz(choose >> (u + 1)) + 1) {       BronKerbosch(clique | (1LL << u), allow & g[u], forbid & g[u]);       allow ^= 1LL << u;       forbid |= 1LL << u;     }   }   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     int k;     long long x;     cin >> n >> k;     memset(g, 0, sizeof(g));     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> x;         g[i] ^= (x << j);       }     }     BronKerbosch(0LL, (1LL << n) - 1, 0LL);     printf( %.9f n , 1.0 * k * k * (ans - 1) / (2 * ans));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10;   int m, k, n, s, tot, del, a[N], b[N], c[N], d[N];   int main() {     scanf( %d%d%d%d , &m, &k, &n, &s);     del = m - k * n;     for (int i = 1; i <= m; i++) scanf( %d , &a[i]);     for (int i = 1, x; i <= s; i++) {       scanf( %d , &x);       b[x]++;       if (b[x] == 1) tot++;     }     for (int l = 1, r = 1; r <= m; r++) {       ++c[a[r]];       tot -= c[a[r]] == b[a[r]];       while (!tot && r - l + 1 > k && l <= m && c[a[l]] > b[a[l]]) --c[a[l]], l++;       if (!tot && r - l + 1 >= k) {         int del2 = (l - 1) % k + r - l + 1 - k;         if (del2 > del) continue;         printf( %d n , del2);         if (!del2) return 0;         for (int i = 1; i <= (l - 1) % k && del2; i++) printf( %d  , i), del2--;         for (int i = l; i <= r && del2; i++)           if (d[a[i]] + 1 > b[a[i]])             printf( %d  , i), del2--;           else             d[a[i]]++;         return 0;       }     }     printf( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)3e5 + 7;   int n, k;   int x[N], y[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> x[i];     }     for (int i = 1; i <= n; i++) {       cin >> y[i];     }     long long f, s;     f = s = 0;     for (int i = 1; i <= n; i++) {       f = max(0LL, x[i] + f - y[i] * 1LL * k);       s = max(0LL, y[i] + s - x[i] * 1LL * k);       if (f > k || s > k) {         puts( NO );         return 0;       }     }     puts( YES );   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > a;   bool g[100][100];   bool used[100];   int n;   void dfs(int v) {     used[v] = true;     for (int i = 0; i < n; i++)       if (g[v][i] && !used[i]) dfs(i);   }   int main() {     int m;     cin >> n >> m;     bool now = false;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) g[i][j] = false;     for (int i = 0; i < n; i++) used[i] = false;     a.resize(n);     for (int i = 0; i < n; i++) {       int num;       cin >> num;       if (num != 0) now = true;       a[i].resize(num);       for (int j = 0; j < num; j++) {         cin >> a[i][j];         a[i][j]--;       }     }     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         for (int i1 = 0; i1 < a[i].size(); i1++)           for (int j1 = 0; j1 < a[j].size(); j1++)             if (a[i][i1] == a[j][j1]) {               g[i][j] = true;               g[j][i] = true;             }     int result = 0;     for (int i = 0; i < n; i++)       if (!used[i]) {         dfs(i);         result++;       }     if (!now) result++;     cout << result - 1;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 512;   const int T = 101;   int n, m;   long long a[M][M];   long long b[M][M];   int t;   int x[T], y[T];   void solve(int xl, int xr, int yl, int yr) {     if (xl == xr && yl == yr) {       b[xl][yl] = a[xl][yl];     } else if (xl != xr) {       int tm = (xr - xl + 1);       int um = (yr - yl + 1);       for (int i = xl; i < xl + tm / 2; i++) {         for (int j = yl; j <= yr; j++) a[i + tm / 2][j] ^= a[i][j];       }       solve(xl + tm / 2, xr, yl, yr);       for (int i = xl; i < xl + tm / 2; i++) {         for (int j = yl; j <= yr; j++) a[i + tm / 2][j] ^= a[i][j];       }       for (int i = xl + tm / 2; i <= xr; i++) {         for (int j = yl; j <= yr; j++) {           for (int k = 1; k <= t; k++) {             if ((i + x[k]) % tm < tm / 2)               a[xl + (i + x[k]) % tm][yl + (j + y[k]) % um] ^= b[i][j];           }         }       }       solve(xl, xl + tm / 2 - 1, yl, yr);       for (int i = xl + tm / 2; i <= xr; i++) {         for (int j = yl; j <= yr; j++) {           for (int k = 1; k <= t; k++) {             if ((i + x[k]) % tm < tm / 2)               a[xl + (i + x[k]) % tm][yl + (j + y[k]) % um] ^= b[i][j];           }           b[i][j] ^= b[i - tm / 2][j];         }       }     } else {       int tm = (xr - xl + 1);       int um = (yr - yl + 1);       for (int i = xl; i <= xr; i++) {         for (int j = yl; j < yl + um / 2; j++) a[i][j + um / 2] ^= a[i][j];       }       solve(xl, xr, yl + um / 2, yr);       for (int i = xl; i <= xr; i++) {         for (int j = yl; j < yl + um / 2; j++) a[i][j + um / 2] ^= a[i][j];       }       for (int i = xl; i <= xr; i++) {         for (int j = yl + um / 2; j <= yr; j++) {           for (int k = 1; k <= t; k++) {             if ((j + y[k]) % um < um / 2)               a[xl + (i + x[k]) % tm][yl + (j + y[k]) % um] ^= b[i][j];           }         }       }       solve(xl, xr, yl, yl + um / 2 - 1);       for (int i = xl; i <= xr; i++) {         for (int j = yl + um / 2; j <= yr; j++) {           for (int k = 1; k <= t; k++) {             if ((j + y[k]) % um < um / 2)               a[xl + (i + x[k]) % tm][yl + (j + y[k]) % um] ^= b[i][j];           }           b[i][j] ^= b[i][j - um / 2];         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     m = 1 << n;     for (int i = 0; i < m; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     cin >> t;     for (int i = 1; i <= t; i++) {       cin >> x[i] >> y[i];     }     solve(0, m - 1, 0, m - 1);     int ans = 0;     for (int i = 0; i < m; i++) {       for (int j = 0; j < m; j++) {         ans += (b[i][j] != 0);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 2;   int pos[MAX], a[MAX];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, c = 0, k;     cin >> n;     for (int i = 1; i < n + 1; i++) cin >> k, a[k] = i, pos[i] = k;     for (int i = 1; i < n + 1; i++) {       if (pos[i] != i) {         c++;         int j = pos[i];         int k = a[i];         pos[k] = j;         a[j] = k;         a[i] = i;         pos[i] = i;       }     }     if ((3 * n + c) & 1)       cout <<  Um_nik ;     else       cout <<  Petr ;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000000], psum[1000000];   map<long long, long long> mp, pp;   vector<long long> v;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       for (int i = 0; i < n; i++) cin >> a[i];       for (int i = 0; i < (2 * k + 2); i++) {         psum[i] = 0;       }       for (int i = 0; i < n / 2; i++) {         int mn = min(a[i], a[n - i - 1]);         int mx = max(a[i], a[n - i - 1]);         psum[1] += 2;         psum[mn + 1] -= 1;         psum[mn + mx] -= 1;         psum[mx + mn + 1] += 1;         psum[mx + k + 1] += 1;       }       int ans = INT_MAX, sum = 0;       for (int i = 1; i <= (2 * k + 1); i++) psum[i] += psum[i - 1];       for (int i = 1; i < (2 * k + 1); i++) ans = min(ans, psum[i]);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using vi = vector<int>;   using vvi = vector<vi>;   using ll = long long;   using vll = vector<ll>;   using vpi = vector<pair<int, int>>;   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     int speedlim = 301;     bool overtake = true;     int speed = -1;     int noovertakes = 0;     vi speedsigns(302, 0);     int ignore = 0;     for (int i = 0; i < n; ++i) {       int t;       cin >> t;       switch (t) {         case 1:           int newspeed;           cin >> newspeed;           assert(newspeed <= 300 && newspeed >= 1);           if (newspeed > speed && newspeed > speedlim) {             ignore += speedsigns[newspeed];             for (int i = newspeed + 1; i < speedsigns.size(); ++i) {               speedsigns[i] -= speedsigns[newspeed];             }             for (int i = 0; i <= newspeed; ++i) {               speedsigns[i] = 0;             }           }           speed = newspeed;           break;         case 2:           if (!overtake) {             ignore += noovertakes;             noovertakes = 0;           }           break;         case 3:           int newspeedlim;           cin >> newspeedlim;           assert(newspeedlim <= 300 && newspeedlim >= 1);           if (newspeedlim < speed)             ++ignore;           else {             for (int i = 0; i <= newspeedlim; ++i) speedsigns[i] = 0;             for (int i = newspeedlim + 1; i < speedsigns.size(); ++i)               ++speedsigns[i];           }           speedlim = newspeedlim;           break;         case 4:           overtake = true;           noovertakes = 0;           break;         case 5:           speedlim = 301;           for (int& si : speedsigns) si = 0;           break;         case 6:           overtake = false;           ++noovertakes;           break;       }     }     cout << ignore <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<string, string>, pair<int, int> > mp;   set<pair<string, string> > st;   int main() {     int n, d;     cin >> n >> d;     for (int i = 0; i < n; ++i) {       string s, q;       int x;       cin >> s >> q;       scanf( %d , &x);       if (mp.count({q, s})) {         pair<int, int> a = mp[{q, s}];         int y = x - a.first;         if (y <= d && y > 0) st.insert({min(s, q), max(s, q)});         y = x - a.second;         if (y <= d && y > 0) st.insert({min(s, q), max(s, q)});       }       if (!mp.count({s, q}))         mp[{s, q}] = {x, x};       else {         pair<int, int> a = mp[{s, q}];         if (x != a.first) a.second = a.first, a.first = x;         mp[{s, q}] = a;       }     }     cout << st.size() << endl;     for (set<pair<string, string> >::iterator it = st.begin(); it != st.end();          it++)       printf( %s %s n , it->first.c_str(), it->second.c_str());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int len[500020];   vector<int> s[500020];   vector<int> g[500020];   int col[500020];   set<int> FK;   int c;   int rt;   void dfs(int u, int p) {     if (p) {       vector<int> t;       int k = c;       for (auto v : s[u]) {         if (!col[v]) continue;         FK.erase(col[v]);         t.push_back(col[v]);       }       k = 0;       set<int>::iterator it = FK.begin();       for (auto v : s[u]) {         if (col[v]) continue;         col[v] = *it;         ++it;       }       for (auto v : t) {         FK.insert(v);       }       t.clear();     }     for (auto v : g[u]) {       if (v == p) continue;       dfs(v, u);     }   }   int main() {     scanf( %d%d , &n, &m);     rt = 0;     int tmp = 0;     for (int i = 1; i <= n; ++i) {       scanf( %d , &len[i]);       for (int j = 1; j <= len[i]; ++j) {         int v;         scanf( %d , &v);         s[i].push_back(v);       }       if (len[i] > tmp) {         tmp = len[i], rt = i;       }     }     for (int i = 1; i < n; ++i) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     int t = 0;     for (auto v : s[rt]) {       col[v] = ++t;     }     c = max(tmp, 1);     for (int i = 1; i <= c; ++i) FK.insert(i);     dfs(rt, 0);     for (int i = 1; i <= m; ++i)       if (!col[i]) col[i] = 1;     printf( %d n , c);     for (int i = 1; i <= m; ++i) printf( %d%c , col[i], i == m ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long rate[2000002];   int n, k;   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> rate[i];     long long p = 0, c;     int del = 0;     vector<int> vec;     for (int i = 1; i <= n; i++) {       if (i - del > 1)         c = (-rate[i - 1] * ((n - del) - (i - del))) * (i - del - 1) + p;       else         c = 0;       if (c < k)         del++, vec.push_back(i);       else         p += rate[i - 1] * (i - del - 1);     }     for (int i = 0; i < vec.size(); i++) cout << vec[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct wektor {     int roz;     int *tab;     int roztab;     wektor() {       tab = new int[1];       roz = 0;       roztab = 1;     }     ~wektor() { delete[] tab; }     int size() { return roz; }     bool empty() { return roz == 0; }     void pop_back() { roz--; }     int &operator[](int ind) { return tab[ind]; }     int operator[](int ind) const { return tab[ind]; }     int back() { return tab[roz - 1]; }     void resize(int cos) {       if (cos > roztab) {         int *tmp;         tmp = new int[2 * cos];         for (int i = 0; i < roz; i++) {           tmp[i] = tab[i];         }         delete[] tab;         tab = tmp;         roztab = 2 * cos;       } else {         if (cos < roz) {           roz = cos;         }       }     }     void push_back(int elem) {       resize(roz + 1);       tab[roz] = elem;       roz = roz + 1;       ;     }   };   wektor slo[100005];   int vis[100005];   int gleb[100005];   double wynik;   void dfs(int v, int g) {     wynik += double(1) / g;     vis[v] = 1;     for (int i = 0; i < slo[v].size(); i++) {       int aktv = slo[v][i];       if (vis[aktv] == 0) {         dfs(aktv, g + 1);       }     }   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n - 1; i++) {       int a, b;       cin >> a >> b;       slo[a].push_back(b);       slo[b].push_back(a);     }     dfs(1, 1);     printf( %.7lf n , wynik);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double kEps(1e-8);   #pragma gcc optimize(2)   int gcd(int x, int y) {     while (y ^= x ^= y ^= x %= y)       ;     return x;   }   void write(int x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   int qpow(int m, int n) {     int res = 1;     while (n) {       if (n & 1) {         res *= m;       }       n >>= 1;       m *= m;     }     return res;   }   int max(int a, int b) {     if (a > b) {       return a;     } else       return b;   }   int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return x * f;   }   signed main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long ans = 1;       map<long long, long long> mp;       for (long long i = 2; i < n; ++i) {         if (i * i > n) {           break;         } else {           if (i * i <= n) {             ans++;           }           if (i * i * i <= n) {             ans++;           }           mp[i * i]++;           mp[i * i * i]++;         }       }       long long temp = 0;       for (auto it : mp) {         if (it.second > 1) {           temp++;         }       }       mp.clear();       cout << ans - temp <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 100005;   const int MSIZE = 10000;   const int INF = 1 << 30;   set<int>::iterator it;   int main() {     int n, a, b;     int p[SIZE];     set<int> fi, se;     map<int, int> mp;     bool flag[SIZE];     while (cin >> n >> a >> b) {       fi.clear(), se.clear(), mp.clear();       memset(flag, 0, sizeof(flag));       for (int i = 0; i < n; i++) {         scanf( %d , &p[i]);         fi.insert(p[i]);         mp[p[i]] = i;       }       vector<int> v;       for (it = fi.begin(); it != fi.end(); it++) {         if (fi.find(a - *it) == fi.end()) {           se.insert(*it);           v.push_back(*it);         }       }       for (int i = 0; i < v.size(); i++) {         fi.erase(v[i]);         se.insert(v[i]);       }       bool mark = 0;       while (!se.empty()) {         it = se.begin();         int x = *it;         if (se.find(b - x) != se.end()) {           flag[mp[x]] = flag[mp[b - x]] = 1;           se.erase(x);           if ((x)*2 != b) se.erase(b - x);         } else if (fi.find(b - x) != fi.end()) {           flag[mp[x]] = flag[mp[b - x]] = 1;           fi.erase(b - x);           se.erase(x);           if ((b - x) * 2 != a) {             fi.erase(a - (b - x));             se.insert(a - (b - x));           }         } else {           puts( NO );           mark = 1;           break;         }       }       if (mark) continue;       puts( YES );       for (int i = 0; i < n; i++) printf( %d  , flag[i]);       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char *argv[]) {     int n, a, d;     cin >> n >> a >> d;     int t, v;     double T, P = 0, D;     while (n--) {       cin >> t >> v;       T = 1.0 * v / a;       if (T * v <= 2 * d) {         D = (1.0 * d - T * v * 0.5) / v;         T = T + D;       } else {         T = sqrt(2.0 * d / a);       }       T += t;       if (T < P) T = P;       printf( %.7f n , T);       P = T;     }     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   long long fac[2000001];   long long PowMod(long long a, long long b, long long mod) {     long long ret = 1LL;     while (b) {       if (b & 1) ret = (ret * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return ret;   }   void cfac() {     fac[0] = 1;     for (long long i = 1; i <= 200000; i++) fac[i] = i * fac[i - 1] % mod;   }   long long Lucas(long long n, long long m, long long p = mod) {     long long ret = 1;     if (n == 0) return 1;     while (n && m) {       long long a = n % p, b = m % p;       if (a < b) return 0;       ret = (ret * fac[a] * PowMod(fac[b] * fac[a - b] % p, p - 2, p)) % p;       n /= p;       m /= p;     }     return ret;   }   long long pre[2002][2002];   long long dp[2002];   struct data {     long long x, y;     bool operator<(const data& b) const { return y == b.y ? x < b.x : y < b.y; }   } Q[2002];   int main() {     ios::sync_with_stdio(0);     cfac();     int h, w, n, l;     cin >> h >> w >> n;     for (int i = 0; i < n; i++) {       cin >> Q[i].x >> Q[i].y;     }     sort(Q, Q + n);     long long ans = 0LL;     for (int i = 0; i < n; i++) {       dp[i] += Lucas(Q[i].x - 1 + Q[i].y - 1, Q[i].x - 1);       dp[i] %= mod;       if (dp[i] < 0) dp[i] += mod;       for (int j = i + 1; j < n; j++) {         if (Q[j].x < Q[i].x) continue;         long long temp =             Lucas(Q[j].x + Q[j].y - Q[i].y - Q[i].x, Q[j].x - Q[i].x);         pre[i][j] = temp;         dp[j] -= temp * dp[i];         dp[j] %= mod;         if (dp[j] < 0) dp[j] += mod;       }     }     long long temp = Lucas(h + w - 2, h - 1);     for (int i = n - 1; i >= 0; i--) {       temp -= dp[i] * Lucas(h + w - Q[i].x - Q[i].y, h - Q[i].x);       temp %= mod;       if (temp < 0) temp += mod;       temp %= mod;       if (temp < 0) temp += mod;     }     cout << temp << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1002][102];   int main() {     int n, m, k, x;     cin >> n >> m >> k;     cout << m * (m - 1) / 2 << endl;     for (int i = 0; i < m; i++) {       for (int j = i + 1; j < m; j++) {         if (!k)           cout << i + 1 <<     << j + 1 << endl;         else           cout << j + 1 <<     << i + 1 << endl;       }     }     return 0;   }