malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   const int infinity = (int)1e9 + 42;   const int64_t llInfinity = (int64_t)1e18 + 256;   const int module = (int)1e9 + 7;   const long double eps = 1e-8;   mt19937_64 randGen(system_clock().now().time_since_epoch().count());   inline void raiseError(string errorCode) {     cerr <<  Error :   << errorCode << endl;     exit(42);   }   inline int readAns(int req) {     cout << req << endl;     int q;     cin >> q;     if (q == 0) {       exit(0);     }     return q;   }   signed main() {     ios_base::sync_with_stdio(false);     int m, n;     cin >> m >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) {       v[i] = readAns(m) * -1;     }     int l = 1, r = m - 1;     int p = 0;     while (l != r) {       int m = (l + r) / 2;       int ans = readAns(m) * v[p];       p++;       p %= n;       if (ans < 0) {         r = m - 1;       } else {         l = m + 1;       }     }     readAns(l);     assert(false);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     string s, t;     cin >> n >> m >> s >> t;     bool can = false;     if (s == t)       can = true;     else {       if (n <= m + 1) {         for (int i = 0; i < int(n); i++) {           if (s[i] ==  * ) {             if (s.substr(0, i) == t.substr(0, i) &&                 s.substr(i + 1, string::npos) ==                     t.substr(m - (n - (i + 1)), string::npos))               can = true;           }         }       }     }     cout << (can ?  YES  :  NO ) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200001], b[200001], c[200001];   int main() {     long long n, ans = 0;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) c[i] = a[i] - b[i];     sort(c, c + n);     for (int i = n - 1;; i--) {       if (c[i] <= 0) break;       int ans1 = &c[i] - upper_bound(c, c + n, 0 - c[i]);       ans += ans1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   unsigned long long preLef[N], preRig[N], sum[N], a[N];   map<unsigned long long, unsigned long long> f, g;   int n, m;   unsigned long long Rand() {     return (unsigned long long)rand() * rand() * rand() +            (unsigned long long)rand() * rand() * rand();   }   int main() {     srand(time(0));     scanf( %d%d , &n, &m);     for (int i = 0, l, r; i < n; ++i) {       scanf( %d%d , &l, &r);       unsigned long long t = Rand();       a[l] ^= t;       a[r + 1] ^= t;       preLef[l] ^= t;       preRig[r] ^= t;     }     for (int i = 1; i <= m + 1; ++i) {       a[i] ^= a[i - 1];       sum[i] = sum[i - 1] ^ a[i];       preLef[i] ^= preLef[i - 1];       preRig[i] ^= preRig[i - 1];     }     g[0] = 0;     f[0] = 1;     unsigned long long ans = 0;     for (int i = 1; i <= m; ++i) {       unsigned long long t = sum[i] ^ preLef[i];       ans += f[t] * i - g[t];       t = sum[i] ^ preRig[i];       g[t] += i;       ++f[t];     }     for (int i = 1, lf = 0; i <= m; ++i)       if (!a[i])         ans -= (unsigned long long)(i - lf + 1) * (i - lf) / 2;       else         lf = i;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 5;   int n, a[N];   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( main.in ,  r )) freopen( main.in ,  r , stdin);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     int cnt = 0;     for (int i = 2; i < n; i++)       if (a[i - 1] == 1 && a[i + 1] == 1 && a[i] == 0) a[i + 1] = 0, cnt++;     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[10];   int main() {     int n, i, len;     long long wi = 1, he = 1;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %s , s);       len = strlen(s);       if (len == 4) {         wi++;         he++;       } else if (!strcmp(s,  UL ) || !strcmp(s,  DR ))         wi++;       else if (!strcmp(s,  UR ) || !strcmp(s,  DL ))         he++;     }     printf( %I64d n , wi * he);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string rotate(string s, int off, int* a) {     string new_s(s);     for (int i = 0; i < 4; i++) new_s[a[(i + off) % 4] - 1] = s[a[i] - 1];     return new_s;   }   string rotate1(string s, int off) {     int a[] = {1, 3, 5, 6};     return rotate(s, off, a);   }   string rotate2(string s, int off) {     int a[] = {2, 6, 4, 3};     return rotate(s, off, a);   }   int main() {     string s;     cin >> s;     sort(s.begin(), s.end());     map<string, int> m;     int ans = 0;     do {       bool flg = true;       map<string, int> mm;       for (int i = 0; i < 4; i++) {         string b = rotate1(s, i);         for (int j = 0; j < 4; j++) {           string bb = rotate2(b, j);           if (mm.find(bb) == mm.end())             if (m.find(bb) != m.end()) flg = false;           mm[bb] = m[bb] = 1;         }       }       if (flg) ans++;     } while (next_permutation(s.begin(), s.end()));     cout << ans;     return 0;   }
// Problem: A. Searching Local Minimum   // Contest: Codeforces - Codeforces Round #700 (Div. 1)   // URL: https://codeforces.com/contest/1479/problem/A   // Memory Limit: 512 MB   // Time Limit: 2000 ms   // Powered by CP Editor (https://github.com/cpeditor/cpeditor)      #include <iostream>   #include <iosfwd>   #include <iomanip>   #include <cstdio>   #include <cstring>   #include <cstdlib>   #include <ctime>   #include <cmath>   #include <cassert>   #include <cctype>   #include <climits>   #include <vector>   #include <bitset>   #include <set>   #include <queue>   #include <math.h>   #include <stack>   #include <map>   #include <deque>   #include <string>   #include <list>   #include <iterator>   #include <sstream>   #include <complex>   #include <fstream>   #include <functional>   #include <numeric>   #include <utility>   #include <algorithm>   #include <assert.h>   #include <unordered_map>   #pragma GCC optimize ( -O3 )      using namespace std;      #define watch(x) cout << (#x) <<   =   << (x) << endl   #define PI double(2 * acos(0.0))   #define LL long long   #define MOD 1000000007   #define all(x) (x).begin(), (x).end()   #define INF 1e15   int query(int a, int n){         if(a == 0 || a == n + 1){               return 1e7;         }         cout <<  ?   << a << endl;         int p;         cin >> p;         return p;   }   int helper(int a, int n){         int left = a - 1;         int right = a + 1;         int mid = a;         int p = query(left, n);         int q = query(mid, n);         int r = query(right, n);         if(p > q && q < r){               return 0;         }         if(p < q){               return 2;         }         else{               return 1;         }   }   int main() {         int n;         cin >> n;         int start = 1;         int end = n;         int ans = -1;         while(start <= end){               int mid = (start + end) / 2;               int p = helper(mid, n);               if(p == 0){                     ans = mid;                     break;               }               if(p == 1){                     start = mid + 1;               }else{                     end = mid - 1;               }         }         cout <<  !   << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const long long INFL = LLONG_MAX;   const long double pi = acos(-1);   class SumSegTree {    private:     vector<long long> sum, lazy;     int N;     void check_index(int i) {       if (i < 0 || N <= i) {         throw  index out of bound ;       }     }       public:     SumSegTree(int N) {       this->N = 1;       while (this->N < N) this->N <<= 1;       this->sum.resize(this->N << 1);       this->lazy.resize(this->N << 1);     }     long long get_sum(int l, int r) {       check_index(l);       check_index(r);       return get_sum(l, r, 0, N - 1, 1);     }     void add(int l, int r, int val) {       check_index(l);       check_index(r);       add(l, r, val, 0, N - 1, 1);     }     void delegate(int a, int b, int n) {       sum[n] += (b - a + 1) * lazy[n];       if (a < b) {         lazy[n * 2] += lazy[n];         lazy[n * 2 + 1] += lazy[n];       }       lazy[n] = 0;     }     long long get_sum(int l, int r, int a, int b, int n) {       if (b < l || r < a) return 0;       if (lazy[n] != 0) delegate(a, b, n);       if (l <= a && b <= r) return sum[n];       int m = (a + b) / 2;       return get_sum(l, r, a, m, n * 2) + get_sum(l, r, m + 1, b, n * 2 + 1);     }     void add(int l, int r, long long val, int a, int b, int n) {       if (b < l || r < a) return;       if (l <= a && b <= r) {         if (a == b)           sum[n] += val;         else           lazy[n] += val;       } else {         int m = (a + b) / 2;         if (lazy[n] != 0) delegate(a, b, n);         sum[n] += (min(b, r) - max(a, l) + 1) * val;         add(l, r, val, a, m, n * 2);         add(l, r, val, m + 1, b, n * 2 + 1);       }     }   };   int N, M;   vector<int> adj[300100];   vector<pair<int, long long> > query[300100];   SumSegTree segt(300005);   long long ans[300100];   void dfs(int u, int prev, int h) {     for (int(i) = 0; (i) < (int((query[u]).size())); (i)++) {       int dist = query[u][i].first;       long long value = query[u][i].second;       segt.add(h, min(N, h + dist), value);     }     ans[u] = segt.get_sum(h, h);     for (int(i) = 0; (i) < (int((adj[u]).size())); (i)++) {       int v = adj[u][i];       if (v == prev) continue;       dfs(v, u, h + 1);     }     for (int(i) = 0; (i) < (int((query[u]).size())); (i)++) {       int dist = query[u][i].first;       long long value = query[u][i].second;       segt.add(h, min(N, h + dist), -value);     }   }   int main() {     ios_base::sync_with_stdio(0);     cout.precision(15);     cout << fixed;     cout.tie(0);     cin.tie(0);     cin >> N;     for (int(i) = 1; (i) <= (N - 1); (i)++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     cin >> M;     for (int(i) = 1; (i) <= (M); (i)++) {       int v, d;       long long x;       cin >> v >> d >> x;       query[v].push_back(make_pair(d, x));     }     dfs(1, 0, 0);     for (int(i) = 1; (i) <= (N); (i)++)       cout << ans[i] << (i + 1 <= N ?     :   n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     pair<int, int> home, uni;     cin >> home.first >> home.second >> uni.first >> uni.second;     int count;     cin >> count;     int solution = 0;     int64_t a, b, c;     for (int i = 0; i < count; i++) {       cin >> a >> b >> c;       bool h_p = a * home.first + b * home.second + c > 0;       bool u_p = a * uni.first + b * uni.second + c > 0;       if ((h_p && !u_p) || (!h_p && u_p)) {         solution++;       }     }     cout << solution << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n;     char str[102][102];     scanf( %d , &n);     bool row, col;     row = col = false;     for (int i = 0; i < n; i++) {       scanf( %s , str[i]);       bool bolong = false;       for (int j = 0; j < n; j++) {         if (str[i][j] ==  . ) {           bolong = true;         }       }       if (!bolong) {         row = true;       }     }     if (!row) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (str[i][j] ==  . ) {             printf( %d %d n , i + 1, j + 1);             break;           }         }       }       return 0;     }     for (int i = 0; i < n; i++) {       bool bolong = false;       for (int j = 0; j < n; j++) {         if (str[j][i] ==  . ) bolong = true;       }       if (!bolong) col = true;     }     if (!col) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (str[j][i] ==  . ) {             printf( %d %d n , j + 1, i + 1);             break;           }         }       }     } else       printf( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937_64 rng(       (unsigned)chrono::system_clock::now().time_since_epoch().count());   const long double error = 1e-7;   const long double PI = acosl(-1);   const int nmax = 2e5 + 10;   int master[nmax];   int sz[nmax];   void init(int u) {     master[u] = u;     sz[u] = 1;     return;   }   int fnd(int u) {     if (master[u] == u) return u;     return master[u] = fnd(master[u]);   }   bool unite(int u, int v) {     u = fnd(u);     v = fnd(v);     if (u == v) return false;     if (sz[u] < sz[v]) swap(u, v);     sz[u] += sz[v];     master[v] = u;     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, m;     cin >> n >> m;     vector<long long int> A(n + 1), B(m + 1);     for (int i = 1; i <= n; i++) {       cin >> A[i];     }     for (int i = 1; i <= m; i++) {       cin >> B[i];     }     vector<pair<long long int, pair<int, int>>> edges;     long long int totcost = 0;     for (int i = 1; i <= n; i++) {       int k;       cin >> k;       for (int j = 0; j < k; j++) {         int x;         cin >> x;         edges.emplace_back(A[i] + B[x], make_pair(i, n + x));         totcost += A[i] + B[x];       }     }     for (int i = 1; i <= n + m; i++) init(i);     sort(edges.begin(), edges.end());     reverse(edges.begin(), edges.end());     long long int ans = 0;     for (auto e : edges) {       if (unite(e.second.first, e.second.second)) ans += e.first;     }     ans = totcost - ans;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int L[100010];   int P[100010][20];   vector<int> pp[100010][20];   int T[100010];   vector<int> tt[100010];   int arr[100010];   vector<int> graph[100010];   vector<int> fnc(vector<int> &a, vector<int> &b) {     vector<int> ans;     int aa = a.size(), bb = b.size(), i, j, shajib = 0;     for (i = 0, j = 0; i + j < aa + bb && shajib < 10;) {       if (i == aa) {         ans.push_back(b[j]);         j++;         shajib++;       } else if (j == bb) {         ans.push_back(a[i]);         i++;         shajib++;       } else {         if (a[i] == b[j]) {           i++;         } else if (a[i] > b[j]) {           ans.push_back(b[j]);           j++;           shajib++;         } else {           ans.push_back(a[i]);           i++;           shajib++;         }       }     }     return ans;   }   void dfs(int src, int par) {     if (src == -1)       L[par] = 1;     else       L[par] = L[src] + 1;     T[par] = src;     int len = graph[par].size();     for (int i = 0; i < (int)graph[par].size(); i++) {       int v = graph[par][i];       if (v != src) {         dfs(par, v);       }     }   }   vector<int> query(int n, int p, int q) {     int log = 1, i, j, temp;     if (L[p] < L[q]) {       temp = q;       q = p;       p = temp;     }     log = log2(n);     vector<int> os;     os = fnc(os, tt[p]);     for (j = log; j >= 0; j--) {       if (L[p] - (1 << j) >= L[q]) {         os = fnc(os, pp[p][j]);         p = P[p][j];       }     }     if (p == q) return os;     os = fnc(os, tt[q]);     for (j = log; j >= 0; j--) {       if (P[p][j] != -1 && P[p][j] != P[q][j]) {         os = fnc(os, pp[p][j]);         os = fnc(os, pp[q][j]);         p = P[p][j], q = P[q][j];       }     }     os = fnc(os, pp[p][0]);     return os;   }   void lca(int n) {     memset(P, -1, sizeof(P));     int i, j;     for (i = 1; i <= n; i++) {       P[i][0] = T[i];       if (T[i] != -1) pp[i][0] = fnc(pp[i][0], tt[T[i]]);     }     for (j = 1; (1 << j) < n; j++) {       for (i = 1; i <= n; i++) {         if (P[i][j - 1] != -1) {           P[i][j] = P[P[i][j - 1]][j - 1];           pp[i][j] = fnc(pp[i][j], pp[P[i][j - 1]][j - 1]);           pp[i][j] = fnc(pp[i][j], pp[i][j - 1]);         }       }     }   }   int main() {     int i, j, n, m, t, a, b, k, c;     scanf( %d%d%d , &n, &m, &k);     for (i = 0; i < n - 1; i++) {       scanf( %d%d , &a, &b);       graph[a].push_back(b);       graph[b].push_back(a);     }     for (i = 1; i <= m; i++) {       scanf( %d , &a);       tt[a].push_back(i);     }     for (i = 1; i <= n; i++) {       sort(tt[i].begin(), tt[i].end());       a = tt[i].size();       while (a > 10) {         tt[i].pop_back();         a--;       }     }     dfs(-1, 1);     lca(n);     vector<int> os;     for (i = 1; i <= k; i++) {       scanf( %d%d%d , &a, &b, &c);       os = query(n, a, b);       c = min(c, (int)os.size());       a = 0;       printf( %d  , c);       for (auto it = os.begin(); a < c && it != os.end(); a++, it++) {         printf( %d  , (*it));       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k, lst, a[22], b[1 << 18], o[1 << 18];   long long f[1 << 18][18], g[1 << 18];   char s[22][22];   void rec(int sum, int x, int mask) {     if (sum == 0) {       for (i = 0; i < (1 << n); i++)         if (b[i] > lst)           for (j = 0; j < n; j++) f[i][j] = 0;       for (i = 0; i < (1 << n) - 1; i++)         if (b[i] >= lst)           for (j = 0; j < n; j++)             if (f[i][j]) {               int prv = (1 << n) - 1 - i;               if ((mask >> (n - b[i] - 1)) & 1) {                 for (int x = (prv & (prv - 1)); prv > 0; x &= (x - 1)) {                   k = o[prv ^ x];                   if (s[j][k] ==  1 ) f[i ^ (1 << k)][k] += f[i][j];                   prv = x;                 }               } else                 for (int x = (prv & (prv - 1)); prv > 0; x &= (x - 1)) {                   k = o[prv ^ x];                   f[i ^ (1 << k)][k] += f[i][j];                   prv = x;                 }             }       for (j = 0; j < n; j++) g[mask] += f[i][j];       return;     }     for (; x > 0; x--) {       rec(sum - x, min(sum - x, x), (mask << x) + (1 << (x - 1)) - 1);       lst = n - (sum - x + 1);     }   }   int main() {     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s , s[i]);       f[1 << i][i] = 1;       o[1 << i] = i;     }     lst = 1;     for (i = 0; i < (1 << n); i++) b[i] = b[i / 2] + (i & 1);     rec(n, n, 0);     for (i = 0; i < (1 << (n - 1)); i++) {       for (m = 0, j = -1; j < n - 1; j = k) {         for (k = j + 1; k < n - 1 && ((i >> k) & 1); k++)           ;         a[m++] = k - j;       }       sort(a, a + m);       reverse(a, a + m);       for (k = j = 0; j < m; j++) k = (k << a[j]) + (1 << (a[j] - 1)) - 1;       g[i] = g[k];     }     for (j = n - 1; j >= 0; j--)       for (i = (1 << (n - 1)) - 1; i > 0; i--)         if ((i >> j) & 1) g[i ^ (1 << j)] -= g[i];     for (i = 0; i < (1 << (n - 1)); i++) printf( %I64d  , g[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[107];   map<string, int> f;   vector<pair<int, string>> b;   bool cmp(pair<int, string> u, pair<int, string> v) { return u.first > v.first; }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) {       string s;       cin >> s;       if (f[s] == 0)         f[s] = 1;       else         f[s]++;     }     sort(a + 1, a + n + 1);     for (map<string, int>::iterator it = f.begin(); it != f.end(); ++it) {       b.push_back(make_pair(it->second, it->first));     }     sort(b.begin(), b.end(), cmp);     long long minP = 0, maxP = 0;     for (int i = 0; i < b.size(); i++) {       minP += b[i].first * a[i + 1];       maxP += b[i].first * a[n - i];     }     cout << minP <<     << maxP << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long cos, rlev;     bool operator<(const node &a) const { return cos < a.cos; }   } f[300005];   int main() {     int n, k;     while (scanf( %d%d , &n, &k) != EOF) {       for (int i = 1; i <= n; i++) {         scanf( %I64d , &f[i].cos);         f[i].rlev = i;       }       priority_queue<node> p;       long long ans = 0;       for (int i = 1; i <= k; i++) p.push(f[i]);       for (int i = k + 1; i <= k + n; i++) {         if (i <= n) p.push(f[i]);         node now = p.top();         p.pop();         if (i >= now.rlev) {           ans += (i - now.rlev) * now.cos;           f[now.rlev].rlev = i;         }       }       printf( %I64d n , ans);       for (int i = 1; i < n; i++) {         printf( %I64d  , f[i].rlev);       }       printf( %I64d n , f[n].rlev);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mul(long long a, long long b, long long p = 1000000007) {     return ((a % p) * (b % p)) % p;   }   long long add(long long a, long long b, long long p = 1000000007) {     return (a % p + b % p) % p;   }   void input(long long a[], long long sz) {     for (long long i = 0; i < sz; i++) cin >> a[i];   }   void print(long long a[], long long sz) {     for (long long i = 0; i < sz; i++) {       if (i == sz - 1)         cout << a[i] <<   n ;       else         cout << a[i] <<    ;     }   }   long long maxr(long long a[], long long sz) {     long long ma;     for (long long i = 0; i < sz; i++) {       if (i == 0)         ma = a[i];       else if (a[i] > ma)         ma = a[i];     }     return ma;   }   long long minr(long long a[], long long sz) {     long long mi;     for (long long i = 0; i < sz; i++) {       if (i == 0)         mi = a[i];       else if (a[i] < mi)         mi = a[i];     }     return mi;   }   long long isprm(long long n) {     if (n <= 1) return 0;     if (n <= 3) return 1;     if (n % 2 == 0 || n % 3 == 0) return 0;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return 0;     return 1;   }   long long power(long long x, long long y, long long p = 1000000007) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long modInverse(long long n, long long p = 1000000007) {     return power(n, p - 2, p);   }   long long ncrMod(long long n, long long r, long long p = 1000000007) {     if (r == 0) return 1;     long long fac[n + 1];     fac[0] = 1;     for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;     return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %            p;   }   bool comp(const pair<int, int> &a, const pair<int, int> &b) {     if (a.first == b.first) {       return (a.second > b.second);     }     return (a.first < b.first);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long q = n / k;       long long r = n % k;       if ((r % 2 == 1 && k % 2 == 0) || (r % 2 == 1 && q == 1) || q == 0)         cout <<  NO n ;       else {         cout <<  YES n ;         if (r % 2 == 0) {           cout << q + r <<    ;           for (long long i = 0; i < k - 1; i++) cout << q <<    ;           cout <<   n ;         } else {           cout << q + r <<    ;           for (long long i = 0; i < k - 1; i++) {             if (i % 2 == 0)               cout << q - 1 <<    ;             else               cout << q + 1 <<    ;           }           cout <<   n ;         }       }     }     return 0;   }