malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     register char c =    ;     register int v = 0, x = 1;     while ((c <  0 ) || (c >  9 )) {       if (c ==  - ) x = -1;       c = getchar();     }     while ((c >=  0 ) && (c <=  9 )) {       v = (v << 1) + (v << 3) + (c ^ 48);       c = getchar();     }     return v * x;   }   inline void write(register int x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) write(x / 10);     putchar(x % 10 ^ 48);   }   const int N = 2e5 + 10;   int ans, fa[N], dep[N], dp[N][3];   int n, cnt, head[N], v[N], nxt[N], ind[N];   inline void add(register int x, register int y) {     ind[x]++, ind[y]++;     v[++cnt] = y, nxt[cnt] = head[x], head[x] = cnt;     v[++cnt] = x, nxt[cnt] = head[y], head[y] = cnt;   }   inline void dfs(register int u) {     dep[u] = dep[fa[u]] + 1;     dp[u][0] = 0, dp[u][1] = 1;     for (register int i = head[u]; i; i = nxt[i])       if (v[i] != fa[u]) {         fa[v[i]] = u;         dfs(v[i]);         ans = max(ans, dp[u][0] + dp[v[i]][0]);         ans = max(ans, dp[u][1] + dp[v[i]][0]);         ans = max(ans, dp[u][0] + dp[v[i]][1]);         dp[u][0] = max(dp[u][0], dp[v[i]][0] + ind[u] - 2);         dp[u][0] = max(dp[u][0], dp[v[i]][1] + ind[u] - 2);         dp[u][1] = max(dp[u][1], dp[v[i]][0] + 1);       }     ans = max(ans, dp[u][1]);   }   int main() {     n = read();     for (register int i = 1; i < n; i++) add(read(), read());     dfs(1);     write(ans);     return ~~(0 - 0);   }
#include <bits/stdc++.h>   using namespace std;   int n, m = 3, l, c[20000];   char s[500];   int main() {     cin >> n;     while (c[m] <= n) m++, c[m] = (long long)m * (m - 1) * (m - 2) * (m - 3) / 24;     for (int i = m - 1; i >= 1; i--) {       while (c[i] >= 1 && n >= c[i]) {         s[++l] =  a ;         n -= c[i];       }       s[++l] =  b ;     }     printf( %s abbbb n , s + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int px[4000010];   int py[4000010];   char c[2010][2010];   int n, m;   bool pd(int x, int y, int d) {     if (x < 0 || y < 0 || x + d >= n || y + d >= m) return false;     for (int t = 1; t <= px[0]; t++)       if ((px[t] != x) && (px[t] != x + d) && (py[t] != y) && (py[t] != y + d))         return false;     for (int i = 0; i <= d; i++) {       if (c[x + i][y] ==  . ) c[x + i][y] =  + ;       if (c[x][y + i] ==  . ) c[x][y + i] =  + ;       if (c[x + i][y + d] ==  . ) c[x + i][y + d] =  + ;       if (c[x + d][y + i] ==  . ) c[x + d][y + i] =  + ;     }     for (int i = 0; i < n; i++) printf( %s n , c[i]);     return true;   }   int main() {     int i, j;     scanf( %d%d , &n, &m);     int x0 = n, x1 = -1, y0 = m, y1 = -1;     px[0] = 0;     py[0] = 0;     for (i = 0; i < n; i++) {       scanf( %s , c[i]);       for (j = 0; j < m; j++) {         if (c[i][j] ==  w ) {           px[++px[0]] = i;           py[++py[0]] = j;           x0 = min(x0, i);           x1 = max(x1, i);           y0 = min(y0, j);           y1 = max(y1, j);         }       }     }     if (px[0] > n * 4) {       printf( -1 n );       return 0;     }     int d = max(x1 - x0, y1 - y0);     if (pd(x0, y0, d)) return 0;     if (pd(x0, max(y1 - d, 0), d)) return 0;     if (pd(max(x1 - d, 0), y0, d)) return 0;     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char Ma[4105];   int Mp[4105];   void Manacher(char s[], int len) {     int l = 0;     Ma[l++] =  $ ;     Ma[l++] =  # ;     for (int i = 0; i < len; i++) {       Ma[l++] = s[i];       Ma[l++] =  # ;     }     Ma[l] = 0;     int mx = 0, id = 0;     for (int i = 0; i < l; i++) {       Mp[i] = mx > i ? min(Mp[id * 2 - i], mx - i) : 1;       while (Ma[i + Mp[i]] == Ma[i - Mp[i]]) Mp[i]++;       if (i + Mp[i] > mx) {         mx = i + Mp[i];         id = i;       }     }   }   char s[4105];   long long f[4105];   int ans, cnt;   int tmp[2005 * 2005];   int main() {     scanf( %s , s);     int len = strlen(s);     Manacher(s, len);     long long ans = 0;     for (int i = 1; i < 2 * len + 2; i++) {       for (int j = 1; j < Mp[i]; j++)         if (Ma[i - j + 1] !=  # ) {           tmp[++cnt] = i + j - 1;           f[i - j + 1]++;         }     }     for (int i = 2 * len + 2; ~i; i--) f[i] += f[i + 1];     for (int i = 1; i <= cnt; i++) ans += f[tmp[i] + 1];     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void _R(T &x) {     cin >> x;   }   void _R(int &x) { scanf( %d , &x); }   void _R(int64_t &x) { scanf( %lld , &x); }   void _R(double &x) { scanf( %lf , &x); }   void _R(char &x) { scanf(  %c , &x); }   void _R(char *x) { scanf( %s , x); }   void R() {}   template <class T, class... U>   void R(T &head, U &...tail) {     _R(head);     R(tail...);   }   template <class T>   void _W(const T &x) {     cout << x;   }   void _W(const int &x) { printf( %d , x); }   void _W(const int64_t &x) { printf( %lld , x); }   void _W(const double &x) { printf( %.16f , x); }   void _W(const char &x) { putchar(x); }   void _W(const char *x) { printf( %s , x); }   template <class T, class U>   void _W(const pair<T, U> &x) {     _W(x.first);     putchar(   );     _W(x.second);   }   template <class T>   void _W(const vector<T> &x) {     for (auto i = x.begin(); i != x.end(); _W(*i++))       if (i != x.cbegin()) putchar(   );   }   void W() {}   template <class T, class... U>   void W(const T &head, const U &...tail) {     _W(head);     putchar(sizeof...(tail) ?     :   n );     W(tail...);   }   int MOD = 1e9 + 7;   void ADD(long long &x, long long v) {     x = (x + v) % MOD;     if (x < 0) x += MOD;   }   const int SIZE = 1 << 20;   string s[201];   int len[201];   int n, m;   int a[202], b[202];   bitset<4096> d[201][13];   void solve() {     for (int i = (1); i <= (n); ++i) {       len[i] = ((int)(s[i]).size());       for (int l = (1); l <= (12); ++l) {         for (int k = 0; k + l <= len[i]; k++) {           int me = 0;           for (int r = 0; r < (l); ++r) {             me = me * 2 + (s[i][k + r] -  0 );           }           d[i][l][me] = 1;         }       }     }     for (int i = (n + 1); i <= (n + m); ++i) {       for (int l = (1); l <= (12); ++l) {         d[i][l] = d[a[i]][l] | d[b[i]][l];       }       string tmp = s[a[i]].substr(max(0, ((int)(s[a[i]]).size()) - 12)) +                    s[b[i]].substr(0, min(12, ((int)(s[b[i]]).size())));       for (int l = (1); l <= (12); ++l) {         for (int k = 0; k + l <= ((int)(tmp).size()); k++) {           int me = 0;           for (int r = 0; r < (l); ++r) {             me = me * 2 + (tmp[k + r] -  0 );           }           d[i][l][me] = 1;         }       }       s[i] = s[a[i]] + s[b[i]];       if (((int)(s[i]).size()) > 24) {         s[i] = s[i].substr(0, 12) + s[i].substr(((int)(s[i]).size()) - 12);       }       int ans = 0;       while (ans < 12 && d[i][ans + 1].count() == (1 << (ans + 1))) ans++;       W(ans);     }   }   void input() {     R(n);     for (int i = (1); i <= (n); ++i) {       R(s[i]);     }     R(m);     for (int i = (1); i <= (m); ++i) {       R(a[i + n], b[i + n]);     }   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   int c[1000001];   char str[1000001];   int len;   int ct;   long long ans;   int main() {     int k;     int i;     scanf( %d , &k);     scanf( %s , str);     len = strlen(str);     if (k == 0) {       for (i = 0; i < len; i++) {         if (str[i] ==  0 )           ct++;         else {           ans += (long long)ct * (long long)(ct + 1) / 2;           ct = 0;         }       }       ans += (long long)ct * (long long)(ct + 1) / 2;     } else if (k > 0) {       for (i = 0; i < len; i++) {         if (str[i] ==  1 ) ct++;         c[ct]++;       }       ans = c[k];       for (i = k; i <= len; i++) ans += (long long)c[i] * (long long)c[i - k];     }     printf( %I64d n , ans);     scanf(   );   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 100000000;   const long long MAXN = 20100;   int n, a[MAXN], ans;   int main() {     ans = -INF;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int k = 1; k <= n; k++) {       if (n % k == 0) {         for (int j = 1; j <= k; j++) {           long long sum = 0, cnt = 0;           for (int i = j; i <= n; i += k) {             cnt++;             sum += a[i];           }           if (sum > ans && cnt >= 3) {             ans = sum;           }         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50;   struct matrix {     double m[N + 5][N + 5];     friend matrix operator*(const matrix &A, const matrix &B) {       matrix C;       for (int i = 0; i < N; i++)         for (int j = 0; j < N; j++) C.m[i][j] = 0;       for (int i = 0; i < N; i++)         for (int k = 0; k < N; k++)           for (int j = 0; j < N; j++) C.m[i][j] += A.m[i][k] * B.m[k][j];       return C;     }   } M;   matrix mpow(matrix A, int p) {     matrix R;     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++) R.m[i][j] = (i == j);     for (; p; p >>= 1, A = A * A)       if (p & 1) R = R * A;     return R;   }   int n;   double p;   double t[N + 5][N + 5], t2[N + 5][N + 5];   double s[N + 5][N + 5], s2[N + 5][N + 5];   double f[N + 5][N + 5];   void init() {     t[1][1] = p, t[1][2] = 1 - p;     for (int i = 2; i < N; i++) {       t[i][1] = p, t[i][2] = (1 - p) + p * p, t2[i][2] = 1;       for (int j = 3; j < N; j++)         t[i][j] = t[i][j - 1] * t[i - 1][j - 1],         t2[i][j] = t2[i][j - 1] * t[i - 1][j - 1];     }     for (int i = 1; i < N; i++)       for (int j = 1; j < N; j++)         s[i][j] = t[i][j] * (1 - t[i - 1][j]),         s2[i][j] = t2[i][j] * (1 - t[i - 1][j]);     s2[1][2] = 1;     double sum = 0;     for (int i = 1; i < N; i++) sum += s2[N - 1][i];     for (int i = 1; i < N; i++) M.m[1][i] = s2[N - 1][i] / sum;     sum = 0;     for (int i = 2; i < N; i++) {       sum += s[N - 1][i - 1];       for (int j = 1; j < i; j++) M.m[i][j] = s[N - 1][j] / sum;     }     for (int i = 1; i < N; i++) M.m[i][0] = i;     M.m[0][0] = 1;     f[1][1] = 1, f[1][2] = 2;     for (int i = 2; i < N; i++) {       sum = 0;       f[i][1] = 1;       for (int j = 1; j < N; j++) sum += s2[i - 1][j];       for (int j = 1; j < N; j++) f[i][1] += f[i - 1][j] * s2[i - 1][j] / sum;       sum = 0;       for (int j = 2; j < N; j++) {         f[i][j] = j, sum += s[i - 1][j - 1];         for (int k = 1; k < j; k++) f[i][j] += f[i - 1][k] * s[i - 1][k] / sum;       }     }     f[N - 1][0] = 1;   }   int main() {     scanf( %d%lf , &n, &p), p /= 1E9, init();     double ans = 0;     if (n >= N) {       M = mpow(M, n - N + 1);       for (int i = 0; i < N; i++)         for (int j = 0; j < N; j++) ans += M.m[i][j] * f[N - 1][j] * s[N - 1][i];     } else       for (int i = 1; i < N; i++) ans += s[n][i] * f[n][i];     printf( %.9f n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a[51], n;       cin >> n;       for (int i = 0; i < n; i++) cin >> a[i];       sort(a, a + n);       int res = INT_MAX;       for (int i = 1; i < n; i++) {         res = min(res, a[i] - a[i - 1]);       }       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int q;   long long a, b, n;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> q;     while (q--) {       cin >> a >> b >> n;       if (a > b) swap(a, b);       long long ans = 0;       while (b <= n) {         a += b;         swap(a, b);         ans++;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n;     long long int a[45001] = {0};     if (n == 1 || n == 2)       cout <<  No  << endl;     else {       cout <<  Yes  << endl;       cout <<  1             <<     << n << endl;       cout << n - 1;       for (int i = 1; i <= n - 1; i++) {         cout <<     << i;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   const int N = 2020;   struct trie {     trie *c[26];     int cnt;   } * root, *nil;   string s1, s2, s3;   int n, l, r, f[N][N], ans;   trie *new_node() {     trie *node = new (trie);     for (int i = 0; i < 26; i++) node->c[i] = nil;     node->cnt = 0;     return node;   }   void deleteTree(trie *root) {     for (int i = 0; i < 26; i++)       if (root->c[i] != nil) {         deleteTree(root->c[i]);         delete (root->c[i]);       }   }   int main() {     getline(cin, s1);     scanf( %d n , &n);     nil = new (trie);     root = new_node();     for (int i = 1; i <= n; i++) {       deleteTree(root);       for (int t = 0; t < 26; t++) root->c[t] = nil;       cin >> s2 >> l >> r;       for (int u = 0; u < s2.size(); u++) {         trie *path = root;         for (int v = u; v < s2.size(); v++) {           int q = s2[v] -  a ;           if (path->c[q] == nil) {             trie *nw = new_node();             path->c[q] = nw;           }           path = path->c[q];           path->cnt++;         }       }       for (int u = 0; u < s1.size(); u++) {         trie *path = root;         for (int v = u; v < s1.size(); v++) {           int q = s1[v] -  a ;           if (path->c[q] == nil) {             if (l == 0)               for (int t = v; t < s1.size(); t++) f[u][t]++;             break;           }           path = path->c[q];           if (path->cnt >= l && path->cnt <= r) f[u][v]++;         }       }     }     deleteTree(root);     for (int t = 0; t < 26; t++) root->c[t] = nil;     for (int i = 0; i < s1.size(); i++) {       trie *path = root;       for (int j = i; j < s1.size(); j++) {         int q = s1[j] -  a ;         if (path->c[q] == nil) {           trie *nw = new_node();           path->c[q] = nw;         }         path = path->c[q];         if (f[i][j] == n && path->cnt == 0) ans++;         path->cnt++;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   void solve(int tc) {     int n;     cin >> n;     vector<vector<int>> adj(n, vector<int>(n));     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> adj[i][j];       }     }     int k;     cin >> k;     while (k--) {       int a, b, c;       cin >> a >> b >> c;       a--, b--;       ll sumDist = 0;       for (int i = 0; i < n; i++) {         for (int j = i + 1; j < n; j++) {           int newDist = min(adj[i][a] + c + adj[b][j], adj[i][b] + c + adj[a][j]);           if (newDist < adj[i][j]) {             adj[i][j] = adj[j][i] = newDist;           }           sumDist += adj[i][j];         }       }       cout << sumDist <<    ;     }   }   signed main() {     ios::sync_with_stdio(0), cin.tie(0);     int tcs = 1;     for (int tc = 1; tc <= tcs; tc++) solve(tc);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     sort(a.begin(), a.end());     int ans = a.back() - a[0];     int eachCanRemove = (n - 2) / 2;     for (int i = 0; i + eachCanRemove + 1 < n; ++i) {       ans = min(ans, a[i + eachCanRemove + 1] - a[i]);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int caseno = 1;   typedef long long LL;   typedef unsigned long long ULL;   template <class T>   inline void SWAP(T &a, T &b) {     T t = a;     a = b;     b = t;   }   inline LL POW(LL base, LL power) {     LL res = base;     if (power == 0) return 1;     for (int I = 0; I < power - 1; I++) res *= base;     return res;   }   int ToInt(string s) {     int r = 0;     istringstream sin(s);     sin >> r;     return r;   }   double ToDouble(string s) {     double r = 0;     istringstream sin(s);     sin >> r;     return r;   }   string ToString(int n) {     string s;     stringstream convert;     convert << n;     s = convert.str();     return s;   }   const int SIZE = 500 + 10;   string S[SIZE];   int main() {     std::ios_base::sync_with_stdio(0);     int T, I, J, K, N, n, m, k, cnt = 0, len, R, C;     cin >> R >> C;     for (I = 0; I < R; I++) cin >> S[I];     for (I = 0; I < R; I++) {       for (J = 0; J < C; J++) {         if (S[I][J] ==  . ) S[I][J] =  D ;       }     }     for (I = 0; I < R; I++) {       for (J = 0; J < C; J++) {         if (S[I][J] ==  S  && ((J + 1 < C && S[I][J + 1] ==  W ) ||                                (J - 1 >= 0 && S[I][J - 1] ==  W ) ||                                (I + 1 < R && S[I + 1][J] ==  W ) ||                                (I - 1 >= 0 && S[I - 1][J] ==  W ))) {           cout <<  No n ;           return 0;         }       }     }     cout <<  Yes n ;     for (I = 0; I < R; I++) {       for (J = 0; J < C; J++) cout << S[I][J];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   int n, m;   int A[100005], B[100005], pass[100005];   int l;   int main() {     while (scanf( %d %d , &n, &m) != EOF) {       int i, j;       for (i = 1; i <= n; ++i) scanf( %d , &A[i]);       int sum = 0;       for (i = n; i >= 1; --i) {         if (B[A[i]] == 0) {           ++sum;           B[A[i]] = 1;         }         pass[i] = sum;       }       for (j = 1; j <= m; ++j) {         scanf( %d , &l);         printf( %d n , pass[l]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int lower_case[26] = {0}, upper_case[26] = {0};   char buf[100010];   int main() {     scanf( %s , buf);     int len = strlen(buf);     for (int i = 0; i < len; i++) {       if (buf[i] <=  Z )         upper_case[buf[i] -  A ]++;       else         lower_case[buf[i] -  a ]++;     }     int best = 100010;     best = min(best, lower_case[ a  -  a ] / 2);     best = min(best, upper_case[ b  -  a ]);     best = min(best, lower_case[ b  -  a ]);     best = min(best, lower_case[ u  -  a ] / 2);     best = min(best, lower_case[ l  -  a ]);     best = min(best, lower_case[ s  -  a ]);     best = min(best, lower_case[ r  -  a ]);     printf( %d n , best);   }
#include <bits/stdc++.h>   using namespace std;   long long pwr(long long base, long long p, long long mod = (1000000007LL)) {     long long ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % mod;       base = (base * base) % mod;       p /= 2;     }     return ans;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   const int N = 3002;   int n, q, K[400002], ans[400002];   vector<int> adj[N], qarr[N][N], stack_;   bool visited[N], instack[N];   set<int> cycles;   void dfs(int v, int src) {     visited[v] = true;     instack[v] = true;     stack_.push_back(v);     for (auto idx : qarr[src][v]) {       if (ans[idx] != 0) continue;       if ((int)stack_.size() >= K[idx] && cycles.empty())         ans[idx] = stack_[K[idx] - 1];       else         ans[idx] = -1;     }     for (auto vv : adj[v]) {       if (!visited[vv]) {         dfs(vv, src);       } else if (instack[vv]) {         cycles.insert(vv);       }     }     instack[v] = false;     cycles.erase(v);     stack_.pop_back();   }   int main() {     int m;     scanf( %d%d%d , &n, &m, &q);     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       adj[a].push_back(b);     }     for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());     for (int i = 1; i <= q; i++) {       int s, t, k;       scanf( %d%d%d , &s, &t, &k);       K[i] = k;       qarr[s][t].push_back(i);     }     for (int i = 1; i <= n; i++) {       memset(visited, 0, sizeof(visited));       memset(instack, 0, sizeof(instack));       cycles.clear();       stack_.clear();       dfs(i, i);     }     for (int i = 1; i <= q; i++) {       if (ans[i] == 0) ans[i] = -1;       printf( %d n , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   int n, K, F[3005][3005];   char s[3005][15],       T[10][10] = { 1110111 ,  0010010 ,  1011101 ,  1011011 ,  0111010 ,                     1101011 ,  1101111 ,  1010010 ,  1111111 ,  1111011 };   int read() {     char c = getchar();     int ans = 0;     while (c <  0  || c >  9 ) c = getchar();     while (c >=  0  && c <=  9 ) ans = ans * 10 + c -  0 , c = getchar();     return ans;   }   void Write(int x) {     if (x < 10)       putchar(x ^ 48);     else       Write(x / 10), putchar((x % 10) ^ 48);     return;   }   int Count(int id, int x) {     int k = 0;     for (register int i = 0; i < 7; i++) {       if (s[id][i] ==  1  && T[x][i] ==  0 ) return -1;       if (s[id][i] ==  0  && T[x][i] ==  1 ) ++k;     }     return k;   }   int main() {     n = read(), K = read();     F[n + 1][0] = 1;     for (register int i = 1; i <= n; i++) scanf( %s , s[i]);     for (register int i = n; i; i--)       for (register int j = 0, now; j < 10; j++) {         if ((now = Count(i, j)) == -1) continue;         for (register int k = K; k >= now; k--) F[i][k] |= F[i + 1][k - now];       }     if (!F[1][K]) {       putchar( - ), putchar( 1 );       return 0;     }     for (register int i = 1; i <= n; i++)       for (register int j = 9, now; j >= 0; j--) {         if ((now = Count(i, j)) == -1) continue;         if (K >= now && F[i + 1][K - now]) {           putchar( 0  + j), K -= now;           break;         }       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ii = pair<int, int>;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int q;     cin >> q;     for (int cas = 0; cas < q; ++cas) {       ll a, b, m;       cin >> a >> b >> m;       if (a == b) {         cout << 1 <<     << a <<   n ;         continue;       }       if (b - a <= m) {         cout << 2 <<     << a <<     << b <<   n ;         continue;       }       bool poss = false;       for (ll ans = 3; ans <= 50; ++ans) {         vector<ll> sum(ans + 1, 0);         sum[1] = a;         sum[2] = a + 1;         bool loc = true;         for (int i = 3; i <= ans; ++i) {           for (int j = 1; j < i; ++j) {             sum[i] += sum[j];             if (sum[i] > b) {               loc = false;               break;             }           }           sum[i]++;           if (sum[i] > b) loc = false;           if (!loc) break;         }         if (!loc) continue;         vector<ll> v(ans + 1, 1);         for (int i = 2; i <= ans; ++i) {           ll l = 0, r = m;           for (int j = 0; j < 50; ++j) {             ll mm = (l + r) / 2;             if (i == ans) {               if (sum[ans] + mm > b)                 r = mm;               else                 l = mm;             } else {               if (sum[ans] + mm * (1LL << (ans - (i + 1LL))) > b)                 r = mm;               else                 l = mm;             }           }           v[i] += l;           if (i == ans)             sum[ans] += l;           else             sum[ans] += (l * (1LL << (ans - (i + 1LL))));         }         if (sum[ans] > b) break;         if (sum[ans] == b) {           cout << ans <<    ;           ll curr = a;           vector<ll> res(ans + 1, 0);           res[1] = a;           for (int i = 2; i <= ans; ++i) {             for (int j = 1; j < i; ++j) res[i] += res[j];             res[i] += v[i];           }           for (int i = 1; i <= ans; ++i) cout << res[i] <<    ;           cout <<   n ;           poss = true;           break;         }       }       if (!poss) cout << -1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   int ma[101][101], yes[101];   int main() {     int n;     cin >> n;     int r = n / 2;     if (n % 2 == 1) {       r++;     }     cout << (n / 2) * r << endl;     for (long long i = 1; i <= n / 2; i++) {       for (long long j = n / 2 + 1; j <= n; j++) {         cout << i <<     << j << endl;       }     }     return 0;   }