malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.precision(10);     int n;     cin >> n;     int m;     cin >> m;     std::vector<std::vector<long long> > re(n, std::vector<long long>(m, 0));     long long ta = 0;     for (int i = 0; i < n; ++i) {       cin >> re[i][0];       ta ^= re[i][0];     }     long long tb = 0;     long long a;     for (int i = 0; i < m; ++i) {       cin >> a;       re[0][i] ^= a;       tb ^= a;     }     if (tb != ta) {       cout <<  NO ;       exit(0);     }     re[0][0] ^= ta;     cout <<  YES n ;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cout << re[i][j] <<   n  [j != m - 1];   }
#include <bits/stdc++.h>   using namespace std;   template <class htpe, class cmp>   using heap = priority_queue<htpe, vector<htpe>, cmp>;   template <class htpe>   using min_heap = heap<htpe, greater<htpe> >;   template <class htpe>   using max_heap = heap<htpe, less<htpe> >;   const int INF = 1791791791;   const long long INFLL = 1791791791791791791ll;   bool query(int x, int y) {     cout << 1 <<     << x <<     << y << endl;     cout.flush();     string s;     cin >> s;     return s ==  TAK ;   }   bool is_two_answers(int a, int b) { return query(a, b) && query(b, a); }   int find_on_segment(int l, int r, int tr) {     l--;     while (l < r - 1) {       int mid = (l + r + tr) >> 1;       if (!query(mid, mid + 1))         l = mid;       else         r = mid;     }     return r;   }   int main() {     int n, k;     cin >> n >> k;     int a = find_on_segment(1, n, 0);     int b = find_on_segment(a + 1, n, 1);     if (a + 1 > n || !is_two_answers(a, b)) b = find_on_segment(1, a - 1, 0);     cout << 2 <<     << a <<     << b << endl;     cout.flush();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 13e9;   const long long dd = 1e6 + 7;   int main() {     int n, s, r = -1;     cin >> n >> s;     s *= 100;     for (int i = 0; i < (long long)n; i++) {       int x, y;       cin >> x >> y;       x = x * 100 + y;       if (x <= s) r = max((100 - y) % 100, r);     }     cout << r;   }
#include <bits/stdc++.h>   using namespace std;   long double PI = acosl(-1);   bool compare_int(int a, int b) { return (a > b); }   bool compare_string(string a, string b) { return a.size() < b.size(); }   bool compare_pair(const pair<int, int> &a, const pair<int, int> &b) {     if (a.second == b.second)       return a.first < b.first;     else       return (a.second > b.second);   }   bool cmp(pair<string, int> x, pair<string, int> y) {     return (x.second < y.second);   }   void NA() {     printf( NO n );     exit(0);   }   void YA() {     printf( YES n );     exit(0);   }   const int N = 300005;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, x, y, q;     cin >> n;     int sz = sqrt(n);     long long int a[n + 1], tmp[n + 1];     for (int i = 0; i < n; i++) cin >> a[i];     cin >> q;     vector<long long int> res(q);     vector<pair<int, pair<int, int> > > v;     for (int i = 0; i < q; i++) {       cin >> x >> y;       v.push_back({y, {x, i}});     }     sort(v.begin(), v.end());     int pre = -1;     for (int i = 0; i < q; i++) {       x = v[i].second.first - 1;       y = v[i].first;       int id = v[i].second.second;       if (y >= sz) {         for (int i = x; i < n; i += y) res[id] += a[i];       } else {         if (pre != y) {           memset(tmp, 0, sizeof tmp);           for (int i = n - 1; i >= 0; i--) {             tmp[i] += a[i];             if (i + y < n) tmp[i] += tmp[i + y];           }           pre = y;         }         res[id] = tmp[x];       }     }     for (int i = 0; i < q; i++) {       cout << res[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   set<int> st[2];   map<int, int> mp;   int ar[110];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> ar[i];       mp[ar[i]]++;     }     int idx = 0;     map<int, int>::iterator it1;     for (it1 = mp.begin(); it1 != mp.end(); it1++) {       if (it1->second == 1) {         st[idx].insert(it1->first);         idx = !idx;       }     }     if (st[0].size() == st[1].size()) {       string ans(n,  A );       for (int i = 0; i < n; i++) {         if (st[1].count(ar[i])) ans[i] =  B ;       }       cout <<  YES n ;       for (int i = 0; i < n; i++) cout << ans[i];       return 0;     } else {       string res(n,  A );       for (int i = 0; i < n; i++) {         if (st[1].count(ar[i])) {           res[i] =  B ;         }       }       int id = -1;       map<int, int>::iterator it;       for (it = mp.begin(); it != mp.end(); it++) {         if (it->second >= 3) {           id = it->first;           break;         }       }       if (id == -1) {         cout <<  NO ;         return 0;       }       bool flag = false;       for (int i = 0; i < n; i++) {         if (ar[i] == id) {           if (!flag) {             flag = true;             res[i] =  B ;           }         }       }       cout <<  YES n ;       for (int i = 0; i < n; i++) {         cout << res[i];       }       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int len;   set<string> v;   bool check[111111][5];   void fuck(string father, int now) {     if (now - 2 > 4) {       string now1 = s.substr(now - 2, 2);       if (now1 != father) {         v.insert(now1);         if (check[now - 2][2] == true)           check[now - 2][2] = false, fuck(now1, now - 2);       }     }     if (now - 3 > 4) {       string now2 = s.substr(now - 3, 3);       if (now2 != father) {         v.insert(now2);         if (check[now - 3][3] == true)           check[now - 3][3] = false, fuck(now2, now - 3);       }     }   }   int main() {     cin >> s;     memset(check, true, sizeof(check));     len = s.length();     fuck(  , len);     cout << v.size() << endl;     for (set<string>::iterator it = v.begin(); it != v.end(); it++)       cout << *it << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline char nc() {     return getchar();     static char buf[100000], *l = buf, *r = buf;     return l == r && (r = (l = buf) + fread(buf, 1, 100000, stdin), l == r)                ? EOF                : *l++;   }   template <class T>   void read(T &x) {     x = 0;     int f = 1, ch = nc();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = nc();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 -  0  + ch;       ch = nc();     }     x *= f;   }   int N, M, D, A[100050][50];   int cnt, id[100050][50];   pair<int, int> bel[5000050];   int head[5000050];   int head1[5000050];   struct edge {     int to, nex;     edge(int to = 0, int nex = 0) : to(to), nex(nex) {}   };   vector<edge> G;   vector<edge> G1;   inline void addedge(int u, int v) {     G.push_back(edge(v, head[u])), head[u] = G.size() - 1;   }   inline void addedge1(int u, int v) {     G1.push_back(edge(v, head1[u])), head1[u] = G1.size() - 1;   }   int dfn[5000050], low[5000050], dfc;   int sccno[5000050], val[5000050], scnt;   int vis[100050];   int stk[5000050], top;   void tarjan(int u) {     low[u] = dfn[u] = ++dfc;     stk[++top] = u;     for (int i = head[u]; ~i; i = G[i].nex) {       int v = G[i].to;       if (!dfn[v]) {         tarjan(v);         low[u] = min(low[u], low[v]);       } else if (!sccno[v]) {         low[u] = min(low[u], dfn[v]);       }     }     if (low[u] == dfn[u]) {       ++scnt;       while (true) {         int x = stk[top--];         sccno[x] = scnt;         int a = bel[x].first, b = bel[x].second;         if (A[a][b] && vis[a] != scnt) {           vis[a] = scnt;           ++val[scnt];         }         if (x == u) break;       }     }   }   void find_scc() {     for (int i = 1; i <= cnt; ++i)       if (!dfn[i]) {         tarjan(i);       }     memset(head1, -1, sizeof(head1));     for (int u = 1; u <= cnt; ++u) {       for (int i = head[u]; ~i; i = G[i].nex) {         int v = G[i].to;         if (sccno[u] != sccno[v]) {           addedge1(sccno[u], sccno[v]);         }       }     }   }   int f[5000050];   void dp(int u) {     if (f[u]) return;     for (int i = head1[u]; ~i; i = G1[i].nex) {       int v = G1[i].to;       dp(v);       f[u] = max(f[u], f[v]);     }     f[u] += val[u];   }   int solve() {     find_scc();     int u = sccno[id[1][0]];     dp(u);     return f[u];   }   char str[60];   int main() {     read(N), read(M), read(D);     for (int i = 1; i <= N; ++i) {       for (int j = 0; j < D; ++j) {         id[i][j] = ++cnt;         bel[cnt] = pair<int, int>(i, j);       }     }     memset(head, -1, sizeof(head));     for (int i = 1; i <= M; ++i) {       int u, v;       read(u), read(v);       for (int j = 1; j < D; ++j) {         addedge(id[u][j - 1], id[v][j]);       }       addedge(id[u][D - 1], id[v][0]);     }     for (int i = 1; i <= N; ++i) {       scanf( %s , str);       for (int j = 0; j < D; ++j) {         A[i][j] = str[j] ==  1 ;       }     }     printf( %d n , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mn = 1e6 + 10;   int a[mn * 3];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) a[i] = i;     for (int i = 2; i <= n; i++) {       int v = a[i - 1];       for (int j = i - 1; j < n + i - 1; j += i) {         swap(v, a[min(j + i, n + i - 1)]);       }     }     for (int i = n; i <= n + n - 1; i++) printf( %d  , a[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 106, INF = 0x3f3f3f3f;   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, a[N << 1];   int couple[N][2];   int main() {     n = read();     for (int i = 1; i <= n << 1; i++) {       a[i] = read();       if (!couple[a[i]][0])         couple[a[i]][0] = i;       else         couple[a[i]][1] = i;     }     int ans = 0;     for (int i = 1; i <= (n << 1); i += 2) {       if (a[i] == a[i + 1])         continue;       else {         ans += couple[a[i]][1] - couple[a[i]][0] - 1;         for (int j = couple[a[i]][1] - 1; j >= i; j--)           if (couple[a[j]][0] == j)             a[++couple[a[j]][0]] = a[j];           else             a[++couple[a[j]][1]] = a[j];         a[couple[a[i]][1] = i + 1] = a[i];       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long fact[1000001];   long long pow(long long a, long long b, long long m) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % m;       b /= 2;       a = (a * a) % m;     }     return ans;   }   long long modinv(long long k) { return pow(k, 998244353 - 2, 998244353); }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     fact[0] = 1;     for (long long i = 1; i < 1000001; i++)       fact[i] = (fact[i - 1] * i) % 998244353;     long long ans = 0;     ans += fact[n];     if (n - 2 > 0) ans = (ans + (n - 2) * fact[n]) % 998244353;     for (long long i = 1; i < n - 1; i++) {       ans = (ans - fact[n] * modinv(fact[n - i])) % 998244353;     }     cout << (ans + 998244353) % 998244353 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100010], cewa, now;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     now = 0;     for (int i = 0; i < n; i++) {       if (now > a[i]) {         cewa++;         now -= a[i];       }       now += a[i];     }     cout << n - cewa <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int destroy(list<int> row) {     int totalDestroyed = 0, lastDestroyed = -1;     int combo = 1;     while (lastDestroyed != 0) {       lastDestroyed = 0;       combo = 1;       list<int>::iterator it = row.begin();       list<int>::iterator prev = it++;       for (; it != row.end(); ++it) {         if (*prev == *it) {           combo++;         } else {           if (combo >= 3) {             it = row.erase(prev, it);             lastDestroyed += combo;           }           prev = it;           combo = 1;         }       }       totalDestroyed += lastDestroyed;     }     totalDestroyed += (combo >= 3 ? combo : 0);     return totalDestroyed > 0 ? totalDestroyed - 1 : 0;   }   int main() {     int N, K, X;     cin >> N >> K >> X;     list<int> row;     int ball;     for (int i = 0; i < N; ++i) {       cin >> ball;       row.push_back(ball);     }     int maxDestroyed = 0;     for (list<int>::iterator it = row.begin(); it != row.end(); ++it) {       it = row.insert(it, X);       int destroyed = destroy(row);       maxDestroyed = max(maxDestroyed, destroyed);       it = row.erase(it);     }     cout << maxDestroyed;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 112;   const long long mod = 1e9 + 7;   int R;   long long p1, p2, p3, p4, s;   int lim[N];   long long F[N][N];   long long ksm(long long a, long long b = mod - 2) {     long long ret = 1;     for (; b; b >>= 1, a = a * a % mod)       if (b & 1) ret = ret * a % mod;     return ret;   }   struct node {     long long a[N];     node() { memset(a, 0, sizeof a); }   } a[N][N];   node operator*(long long x, node a) {     node c;     for (int i = 0; i <= 2 * R + 1; i++) c.a[i] = a.a[i] * x % mod;     return c;   }   node operator+(node a, node b) {     node c;     for (int i = 0; i <= 2 * R + 1; i++) c.a[i] = (a.a[i] + b.a[i]) % mod;     return c;   }   node operator-(node a, node b) {     node c;     for (int i = 0; i <= 2 * R + 1; i++) c.a[i] = (a.a[i] - b.a[i] + mod) % mod;     return c;   }   void solve() {     int n = 2 * R;     for (int i = 0; i <= n; i++) {       int maxx = i;       for (int j = i + 1; j <= n; j++)         if (abs(F[j][i]) > abs(F[maxx][i])) maxx = j;       swap(F[maxx], F[i]);       for (int j = 0; j <= n; j++) {         if (j != i) {           long long x = F[j][i] * ksm(F[i][i]) % mod;           for (int k = i; k <= n + 1; k++)             F[j][k] = (F[j][k] - F[i][k] * x) % mod;         }       }     }     for (int i = 0; i <= n; i++) F[i][n + 1] = F[i][n + 1] * ksm(F[i][i]) % mod;   }   int main() {     scanf( %d%lld%lld%lld%lld , &R, &p1, &p2, &p3, &p4);     s = p1 + p2 + p3 + p4;     s = ksm(s);     p1 = p1 * s % mod;     p2 = p2 * s % mod;     p3 = p3 * s % mod;     p4 = p4 * s % mod;     int T = R + 3;     p4 = ksm(p4);     for (int i = 0; i <= R; i++)       for (int j = 0; j * j + i * i <= R * R; j++) lim[i] = j;     for (int j = -R; j <= R + 1; j++)       for (int i = -R; i <= R; i++) {         int lt = lim[abs(i)];         if (j == -lt)           a[i + T][-lt + T].a[i + R] = 1;         else if (j > -lt && j <= lt + 1) {           a[i + T][j + T] =               (a[i + T][j - 1 + T] - p1 * a[i - 1 + T][j - 1 + T] -                p2 * a[i + T][j - 2 + T] - p3 * a[i + 1 + T][j - 1 + T]);           (a[i + T][j + T].a[2 * R + 1])--;           (a[i + T][j + T].a[2 * R + 1]) = (a[i + T][j + T].a[2 * R + 1]) % mod;           a[i + T][j + T] = p4 * a[i + T][j + T];         }       }     for (int i = -R; i <= R; i++) {       for (int j = 0; j <= 2 * R + 1; j++)         F[i + R][j] = a[i + T][lim[abs(i)] + 1 + T].a[j];       F[i + R][2 * R + 1] = -F[i + R][2 * R + 1];     }     solve();     long long ans = 0;     for (int i = 0; i <= 2 * R; i++)       ans = (ans + a[T][T].a[i] * F[i][2 * R + 1]) % mod;     ans = (ans + a[T][T].a[2 * R + 1]) % mod;     ans = (ans + mod) % mod;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000001];   int main() {     int n, k;     cin >> n >> k;     if (k == 1) return puts( 3 ), 0;     for (int i = 1; i <= n; i++) a[i] = i;     for (int i = 2; i <= n; i++)       if (a[i] == i) {         for (int j = i; j <= n; j += i) a[j] = (a[j] / i) * (i - 1);       }     sort(a + 3, a + n + 1);     cout << accumulate(a + 3, a + k + 3, 0ll) + 2 << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:134217728 )   using namespace std;   const long long MOD = 1000000000 + 7;   const long long MAGIC = 123123123;   const double PI = 4 * atan(1.);   const double EPS = 1E-7;   void time_elapsed() {     cout <<   nTIME ELAPSED:   << (double)clock() / CLOCKS_PER_SEC <<   sec n ;   }   struct frac;   template <typename T>   T gcd(T a, T b) {     return ((b == 0) ? a : gcd(b, a % b));   }   template <class T>   T gcd(T a, T b, T& x, T& y) {     if (!a) {       x = 0, y = 1;       return b;     }     T x1, y1;     T d = gcd(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return d;   }   template <typename T>   T lcm(T a, T b) {     return (a / gcd(a, b)) * b;   }   template <typename T, typename M>   T neg_mod(T a, M mod) {     return ((a % mod) + mod) % mod;   }   long long binpow(long long x, long long p) {     long long res = 1;     while (p) {       if (p & 1) res *= x;       x *= x;       p >>= 1;     }     return res;   }   long long binpow_mod(long long x, long long p, long long m) {     long long res = 1;     while (p) {       if (p & 1) res = (res * x) % m;       x = (x * x) % m;       p >>= 1;     }     return res;   }   struct cmp_for_set {     bool operator()(const pair<long long, long long>& a,                     const pair<long long, long long>& b) const {       return a > b;     }   };   string a, b;   map<char, int> amap;   bool check(int len, map<char, int>& need, string& res) {     map<char, int> aa = amap;     for (auto it : need) {       if (aa[it.first] < it.second) {         return false;       }       aa[it.first] -= it.second;       if (aa[it.first] == 0) {         aa.erase(it.first);       }     }     res.resize(a.size());     for (int i = 0; i < len; ++i) {       res[i] = b[i];     }     if (len == b.size()) {       return true;     }     char nxt =  0  - 1;     for (auto it : aa) {       if (it.first < b[len] && it.second > 0) {         nxt = it.first;       }     }     if (nxt ==  0  - 1) {       return false;     }     res[len] = nxt;     aa[nxt]--;     vector<char> toadd;     for (auto it : aa) {       for (int j = 0; j < it.second; ++j) {         toadd.push_back(it.first);       }     }     for (int i = 0; i < toadd.size(); ++i) {       res[len + 1 + i] = toadd[(int)toadd.size() - 1 - i];     }     return true;   }   int main() {     cin >> a >> b;     for (int i = 0; i < a.size(); ++i) {       amap[a[i]]++;     }     string res = a;     sort(res.begin(), res.end());     if (a.size() < b.size()) {       sort(res.rbegin(), res.rend());       cout << res;       return 0;     }     map<char, int> need;     for (int i = 0; i <= b.size(); ++i) {       string cur;       if (check(i, need, cur)) {         res = cur;       }       need[b[i]]++;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   const int MOD = (int)1e9 + 7;   using namespace std;   stack<long long> st;   int main() {     long long n, num;     cin >> n;     long long sum = 0;     int over = 0;     st.push(1);     for (int i = 1; i <= n; i++) {       string s;       cin >> s;       if (over == 1) continue;       if (s[0] ==  a ) {         sum += st.top();         if (sum > 4294967295) {           over = 1;         }       } else if (s[0] ==  f ) {         cin >> num;         long long f = st.top();         if (st.top() > 4294967295)           st.push(st.top());         else           st.push(f * num);       } else {         st.pop();       }     }     if (over == 1)       cout <<  OVERFLOW!!!  << endl;     else       cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int k, n;     cin >> k >> n;     int ans = 0;     unordered_set<int> pref_sums;     int curr_sum = 0;     while (k--) {       int x;       cin >> x;       curr_sum += x;       pref_sums.insert(curr_sum);     }     unordered_set<int> r;     while (n--) {       int x;       cin >> x;       r.insert(x);     }     for (int p : pref_sums) {       int i = *begin(r) - p;       bool check = true;       for (int e : r) {         if (!count(pref_sums.begin(), pref_sums.end(), e - i)) {           check = false;           break;         }       }       if (check) ans++;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long n, fact[200001], a[200005];   long long power(long long a, long long b) {     if (b == 0) return 1;     long long p = power(a, b / 2);     p = ((p % 1000000007) * (p % 1000000007)) % 1000000007;     if (b & 1) {       return (a * p) % 1000000007;     }     return p;   }   long long mod_inv(long long n, long long m) {     long long div = power((fact[n - m] * fact[m]) % 1000000007, 1000000007 - 2);     return (fact[n] * div) % 1000000007;   }   int main() {     fact[0] = 1;     for (int i = 1; i <= 200000; i++) {       fact[i] = (fact[i - 1] * i) % 1000000007;     }     scanf( %lld , &n);     for (int i = 0; i < n; i++) {       scanf( %lld , &a[i]);     }     long long ans = 0;     if (n % 4 == 0) {       n = n - 2;       n /= 2;       for (int i = 0; i < n * 2 + 2; i++) {         if (i & 1) {           ans -= ((mod_inv(n, i / 2)) * a[i]) % 1000000007;           ans = (ans + 1000000007) % 1000000007;         } else {           ans += ((mod_inv(n, i / 2)) * a[i]) % 1000000007;           ;           ans = (ans + 1000000007) % 1000000007;         }       }     } else if (n % 4 == 1) {       long long sz = n;       n = n - 1;       n /= 2;       for (int i = 0; i < sz; i += 2) {         ans += ((mod_inv(n, i / 2)) * a[i]) % 1000000007;         ans = (ans + 1000000007) % 1000000007;       }     } else if (n % 4 == 2) {       long long sz = n;       n = n - 2;       n /= 2;       for (int i = 0; i < sz; i++) {         ans += ((mod_inv(n, i / 2)) * a[i]) % 1000000007;         ;         ans = (ans + 1000000007) % 1000000007;       }     } else {       long long sz = n;       n = n - 3;       n /= 2;       ans = (a[0] * mod_inv(n, 0)) % 1000000007;       for (int i = 1; i < sz; i++) {         if (i & 1) {           ans += (2 * (mod_inv(n, i / 2)) * a[i]) % 1000000007;           ;           ans = ans = (ans + 1000000007) % 1000000007;         } else {           ans +=               ((mod_inv(n, i / 2) - mod_inv(n, (i / 2) - 1)) * a[i]) % 1000000007;           ans = (ans + 1000000007) % 1000000007;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long T;   void Read(long long &x) {     char c;     while (c = getchar(), c != EOF)       if (c >=  0  && c <=  9 ) {         x = c -  0 ;         while (c = getchar(), c >=  0  && c <=  9 ) x = x * 10 + c -  0 ;         ungetc(c, stdin);         return;       }   }   struct wall {     int x1, y1, x2, y2;     inline wall() {}     inline wall(int x1, int y1, int x2, int y2)         : x1(x1), y1(y1), x2(x2), y2(y2) {}   } ans[300 + 10];   int cnt;   int main() {     Read(T);     long long a = 1;     int t, now = 2, i, tot = 2;     while (a <= T) a *= 6, tot += 2;     printf( %d %d n , tot, tot);     ans[++cnt] = wall(1, 2, 2, 2);     ans[++cnt] = wall(2, 1, 2, 2);     while (a != 1) {       a /= 6;       t = T / a;       T -= t * a;       now += 2;       ans[++cnt] = wall(now - 3, now - 1, now - 2, now - 1);       if (now != tot) {         if (now != 4) {           ans[++cnt] = wall(now - 4, now + 1, now - 3, now + 1);           ans[++cnt] = wall(now + 1, now - 4, now + 1, now - 3);         }         ans[++cnt] = wall(now - 2, now, now - 2, now + 1);         ans[++cnt] = wall(now - 1, now, now - 1, now + 1);         ans[++cnt] = wall(now - 2, now + 2, now - 1, now + 2);         ans[++cnt] = wall(now, now - 1, now + 1, now - 1);         ans[++cnt] = wall(now, now - 2, now + 1, now - 2);         ans[++cnt] = wall(now + 2, now - 2, now + 2, now - 1);       }       if (t % 3 == 0) ans[++cnt] = wall(now - 3, now, now - 2, now);       if (t % 3 <= 1) ans[++cnt] = wall(now, now - 3, now, now - 2);       if (t < 3) ans[++cnt] = wall(now - 1, now - 3, now - 1, now - 2);     }     printf( %d n , cnt);     for (i = 1; i <= cnt; i++)       printf( %d %d %d %d n , ans[i].x1, ans[i].y1, ans[i].x2, ans[i].y2);     return 0;   }