malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> tamCopo;   priority_queue<pair<int, int> > ordemTam;   vector<int> volumeCha;   int main() {     int i, j, k, aux;     int n, w, volume;     cin >> n >> w;     volumeCha.assign(n, 0);     volume = 0;     for (i = 0; i < n; i++) {       cin >> aux;       if (aux % 2 == 0) {         volume += aux / 2;         volumeCha[i] = aux / 2;       } else {         volume += (aux + 1) / 2;         volumeCha[i] = (aux + 1) / 2;       }       tamCopo.push_back(aux);       ordemTam.push(make_pair(aux, i));     }     if (w < volume) {       cout << -1 << endl;     } else {       w -= volume;       while (w > 0) {         pair<int, int> copo = ordemTam.top();         ordemTam.pop();         if (w <= tamCopo[copo.second] / 2) {           volumeCha[copo.second] += w;           w = 0;         } else {           volumeCha[copo.second] = tamCopo[copo.second];           w -= tamCopo[copo.second] / 2;         }       }       for (i = 0; i < volumeCha.size(); i++) cout << volumeCha[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int max(long long int x, long long int y) {     if (x > y) return x;     return y;   }   long long int min(long long int x, long long int y) {     if (x < y) return x;     return y;   }   long long int getSum(long long int n) {     int sum;     for (sum = 0; n > 0; sum += n % 10, n /= 10)       ;     return sum;   }   bool isPrime(long long int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   long long int gcd(long long int a, long long int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long int lcm(long long int a, long long int b) {     return (a * b) / gcd(a, b);   }   long long int two(long long int a, long long int b, long long int c) {     long long int temp = 0;     if (a % 2 == 1) temp++;     if (b % 2 == 1) temp++;     if (c % 2 == 1) temp++;     if (temp == 2)       return true;     else       return false;   }   int CF(const vector<int> &p) {     int ans = 0;     for (int i = 0; i < p.size(); i++)       if (p[i] > 1) ans += p[i];     return ans;   }   long long int res = 1;   long long int power(long long int y) {     if (y == 0) return 1;     res *= 2;     res %= 1000000007;     return res;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int test = 1;     while (test--) {       long long int n, l, r;       cin >> n >> l >> r;       long long int s1 = 0, s2 = 0;       for (int i = l - 1; i >= 0; i--) s1 += pow(2, i);       if (n - l > 0) s1 += (n - l);       cout << s1 <<    ;       for (int i = r - 1; i >= 0; i--) s2 += pow(2, i);       if (n - r > 0) s2 += (n - r) * pow(2, r - 1);       cout << s2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double distance(double v, double a, double t) { return v * t + a * t * t / 2; }   double time(double v, double a, double d) {     return (-v + sqrt(v * v + 2 * a * d)) / a;   }   int main(int argc, char* argv[]) {     cout.precision(16);     double a, v, l, d, w;     cin >> a >> v >> l >> d >> w;     double t = 0;     double p = (w * w + 2 * a * d) / (4 * a);     if (p <= d) {       if (sqrt(2 * p * a) <= v)         t += sqrt(2 * p * a) / a + (sqrt(2 * p * a) - w) / a;       else         t +=             v / a +             (d - distance(0, a, v / a) - distance(v, -a, max(0.0, (v - w) / a))) /                 v +             max(0.0, (v - w) / a);       if (d + distance(w, a, max(0.0, (v - w) / a)) < l)         t += max(0.0, (v - w) / a) +              (l - d - distance(w, a, max(0.0, (v - w) / a))) / v;       else         t += time(w, a, l - d);     } else {       if (distance(0, a, v / a) < l)         t += v / a + (l - distance(0, a, v / a)) / v;       else         t += time(0, a, l);     }     cout << t << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200007, inf = 0x3f3f3f3f;   struct qu {     int op, l, r;   };   qu Q[N];   int v[N];   int main() {     ios::sync_with_stdio(false);     int n, q, m;     cin >> n >> q >> m;     for (int i = 1; i <= n; ++i) {       cin >> v[i];     }     for (int i = 0; i < q; ++i) {       int a, b, c;       cin >> a >> b >> c;       Q[i] = {a, b, c};     }     for (int i = 0; i < m; ++i) {       int x;       cin >> x;       for (int j = q - 1; j >= 0; --j) {         qu que = Q[j];         int l = que.l, r = que.r;         if (que.op == 1 and x >= que.l and x <= que.r) {           x = l + (x - l - 1 + (r - l + 1)) % (r - l + 1);         } else if (que.op == 2 and x >= que.l and x <= que.r) {           x = l + r - x;         }       }       cout << v[x] <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 + 7;   int n;   char s[N];   struct edge {     int to, nex, wei;   } e[N << 1];   int fir[N], eid;   int deg[N], dis[N];   int fa[N];   queue<int> q;   int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }   void addedge(int u, int v, int w) {     e[++eid] = (edge){v, fir[u], w};     fir[u] = eid;     ++deg[v];   }   int main() {     scanf( %d%s , &n, s + 1);     for (int i = 1; i <= n; ++i) fa[i] = i;     for (int i = 1; i < n; ++i)       if (s[i] ==  = ) fa[getfa(i)] = getfa(i + 1);     for (int i = 1; i < n; ++i) {       if (s[i] ==  R ) addedge(getfa(i), getfa(i + 1), 1);       if (s[i] ==  L ) addedge(getfa(i + 1), getfa(i), 1);     }     for (int i = 1; i <= n; ++i) {       dis[i] = 1;       if (deg[i] == 0) q.push(i);     }     while (!q.empty()) {       int s = q.front();       q.pop();       for (int i = fir[s]; i; i = e[i].nex) {         dis[e[i].to] = max(dis[e[i].to], dis[s] + e[i].wei);         if (--deg[e[i].to] == 0) q.push(e[i].to);       }     }     for (int i = 1; i <= n; ++i) printf( %d  , dis[getfa(i)]);     return 0;   }
#include<bits/stdc++.h>   using namespace std;   const int MAX_N = 2e5+5;   vector<long long> us[MAX_N];   long long pres[MAX_N];   long long res[MAX_N];   int u[MAX_N];   int s[MAX_N];   bool cmp(long long &x, long long &y)   {       return x > y;   }   int main()   {       int t;       cin>>t;       // iostream::sync_with_stdio(false);       while(t--)       {           int n, max_v = -1, pre_len;           cin>>n;           for(int i = 1; i <= n; i++)           {               cin>>u[i];               us[i].clear();               max_v = max(max_v, u[i]);           }           for(int i = 1; i <= n; i++)            {               cin>>s[i];               res[i] = 0;               us[u[i]].push_back(s[i]);           }           for(int i = 1; i <= max_v; i++)           {               pre_len = us[i].size();               sort(us[i].begin(), us[i].end(), cmp);               for(int j = 0; j < pre_len; j++)                   pres[j+1] = pres[j] + us[i][j];               for(int k = 1; k <= pre_len; k++)                   res[k] += pres[pre_len/k * k];           }           for(int k = 1; k <= n; k++)               cout<<res[k]<<   ;           cout<<endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int _ = 1, tc = 1;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   int getmod(int x, int y, int mod) { return (((x - y) % mod) + mod) % mod; }   int MAXN = 46341 + 1;   int spf[46341 + 1];   int d, x, y;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void sieve() {     for (int i = 1; i < MAXN; i++) spf[i] = i;     for (int i = 4; i < MAXN; i += 2) spf[i] = 2;     for (int i = 3; i * i < MAXN; i += 2) {       if (spf[i] == i) {         for (int j = i * i; j < MAXN; j += i) {           if (spf[j] == j) spf[j] = i;         }       }     }   }   void extended_gcd(int a, int b) {     if (b == 0) {       d = a;       x = 1;       y = 0;     } else {       extended_gcd(b, a % b);       int temp = y;       y = x - y * (a / b);       x = temp;     }   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   void solve() {     long long n, m, s1, s2;     cin >> n >> m >> s1 >> s2;     cout << s1 <<     << s2 << endl;     for (int i = 1; i <= m; i++) {       if (i == s2) continue;       cout << s1 <<     << i << endl;     }     int curr = m, new_curr = m;     for (int i = s1 - 1; i >= 1; i--) {       if (curr == m) {         for (int j = m; j > 0; j--) {           cout << i <<     << j << endl;         }         curr = 1;       } else {         for (int j = 1; j <= m; j++) {           cout << i <<     << j << endl;         }         curr = m;       }     }     for (int i = s1 + 1; i <= n; i++) {       if (curr == m) {         for (int j = m; j > 0; j--) {           cout << i <<     << j << endl;         }         curr = 1;       } else {         for (int j = 1; j <= m; j++) {           cout << i <<     << j << endl;         }         curr = m;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     while (_--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const double E = exp(1);   int x[] = {0, 0, -1, 1};   int y[] = {-1, 1, 0, 0};   template <class T1>   void deb(T1 e) {     cout << e << endl;   }   template <class T1, class T2>   void deb(T1 e1, T2 e2) {     cout << e1 <<     << e2 << endl;   }   template <class T1, class T2, class T3>   void deb(T1 e1, T2 e2, T3 e3) {     cout << e1 <<     << e2 <<     << e3 << endl;   }   template <class T1, class T2, class T3, class T4>   void deb(T1 e1, T2 e2, T3 e3, T4 e4) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 << endl;   }   template <class T1, class T2, class T3, class T4, class T5>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 << endl;   }   template <class T1, class T2, class T3, class T4, class T5, class T6>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 <<     << e6          << endl;   }   template <typename T>   inline T sqr(T n) {     return n * n;   }   inline double hypot(double x, double y) { return sqrt(sqr(x) + sqr(y)); }   template <typename T>   inline T pmod(T n, T m) {     return ((n % m) + m) % m;   }   template <typename T>   T power(T n, int p) {     return (p == 0) ? (T)(1) : (sqr(power(n, p >> 1)) * ((p & 1) * (n - 1) + 1));   }   template <typename T>   T bigmod(T n, int p, T m) {     return (p == 0)                ? (T)(1)                : ((sqr(bigmod(n, p >> 1, m)) % m) * ((p & 1) * (n - 1) % m + 1)) %                      m;   }   double dp[5005][5005];   double p[5005];   int t[5005];   double pw[5005];   int main() {     int n, T;     cin >> n >> T;     for (int i = 1; i <= n; i++) {       cin >> p[i] >> t[i];       p[i] /= 100.00;       pw[i] = pow(1.00 - p[i], t[i]);     }     for (int i = n; i >= 1; i--) {       for (int j = T; j >= 1; j--) {         dp[i][j] = p[i] * (dp[i + 1][j + 1] + 1);         double tmp = dp[i][j + 1] * (1.00 - p[i]);         if (j + t[i] <= T + 1) tmp += pw[i] * (dp[i + 1][j + t[i]] + 1);         if (j + t[i] + 1 <= T + 1) tmp -= pw[i] * (dp[i + 1][j + t[i] + 1] + 1);         dp[i][j] += tmp;       }     }     cout << setprecision(9) << dp[1][1] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   bool arr[3001];   int main() {     int n, i, input;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> input;       arr[input] = true;     }     for (i = 1; i <= 3000; i++) {       if (!arr[i]) {         cout << i << endl;         return 0;       }     }     cout << 3001 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long c[100001];   void init() {     long long n, x;     long long ans = 0;     cin >> n >> x;     for (int i = 0; i < n; i++) cin >> c[i];     sort(c, c + n);     for (int i = 0; i < n; i++) {       ans += c[i] * x;       if (x > 1) x--;     }     cout << ans << endl;   }   int main() {     init();     return 0;   }
#include <bits/stdc++.h>   int main() {     int i, gt = 0, arr[4];     char var =  C ;     char A[102];     for (i = 0; i < 4; i++) {       scanf( %s , A);       arr[i] = strlen(A) - 2;     }     for (i = 0; i < 4; i++) {       if (i == 0) {         if (arr[0] >= (2 * arr[1]) && arr[0] >= (2 * arr[2]) &&             arr[0] >= (2 * arr[3])) {           gt++;           var =  A ;         } else if ((2 * arr[0]) <= (arr[1]) && (2 * arr[0]) <= (arr[2]) &&                    (2 * arr[0]) <= (arr[3])) {           gt++;           var =  A ;         }       } else if (i == 1) {         if (arr[1] >= (2 * arr[0]) && arr[1] >= (2 * arr[2]) &&             arr[1] >= (2 * arr[3])) {           gt++;           var =  B ;         } else if ((2 * arr[1]) <= (arr[0]) && (2 * arr[1]) <= (arr[2]) &&                    (2 * arr[1]) <= (arr[3])) {           gt++;           var =  B ;         }       } else if (i == 2) {         if (arr[2] >= (2 * arr[1]) && arr[2] >= (2 * arr[0]) &&             arr[2] >= (2 * arr[3])) {           gt++;           var =  C ;         } else if ((2 * arr[2]) <= (arr[1]) && (2 * arr[2]) <= (arr[0]) &&                    (2 * arr[2]) <= (arr[3])) {           gt++;           var =  C ;         }       } else if (i == 3) {         if (arr[3] >= (2 * arr[1]) && arr[3] >= (2 * arr[2]) &&             arr[3] >= (2 * arr[0])) {           gt++;           var =  D ;         } else if ((2 * arr[3]) <= (arr[1]) && (2 * arr[3]) <= (arr[2]) &&                    (2 * arr[3]) <= (arr[0])) {           gt++;           var =  D ;         }       }     }     if (gt == 1) {       printf( %c , var);     } else {       printf( C );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int cnt[200005];   int n, m, k;   vector<unsigned long long> polys[200005];   struct cmp {     bool operator()(int a, int b) const {       return polys[a].size() > polys[b].size();     }   };   priority_queue<int, vector<int>, cmp> q;   const int NMAX = 1 << 19;   const double PI = 2 * acos(0.0);   struct FFT {     vector<int> rev;     vector<complex<double> > omega, oinv;     int K, N;     FFT(int k) {       K = k;       N = 1 << k;       rev.resize(N);       omega.resize(N);       oinv.resize(N);       for (int i = 0; i < (N); i++) {         rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (K - 1));         omega[i] = polar(1.0, 2.0 * PI / N * i);         oinv[i] = conj(omega[i]);       }     }     void dft(complex<double>* a, vector<complex<double> >& w) {       for (int i = 0; i < (N); i++)         if (i < rev[i]) swap(a[i], a[rev[i]]);       for (int l = 2; l <= N; l *= 2) {         int m = l / 2;         for (complex<double>* p = a; p != a + N; p += l)           for (int k = 0; k < (m); k++) {             complex<double> t = w[N / l * k] * p[k + m];             p[k + m] = p[k] - t;             p[k] += t;           }       }     }     void fft(complex<double>* a) { dft(a, omega); }     void ifft(complex<double>* a) {       dft(a, oinv);       for (int i = 0; i < (N); i++) a[i] /= N;     }     void conv(complex<double>* a, complex<double>* b) {       fft(a);       fft(b);       for (int i = 0; i < (N); i++) a[i] *= b[i];       ifft(a);     }   };   vector<FFT> fft;   int roundup(int x) {     while (x & (x - 1)) x += x & (-x);     return x;   }   void mul(vector<unsigned long long>& a, vector<unsigned long long>& b) {     int maxsz = a.size() + b.size();     int sz = roundup(maxsz);     a.resize(sz);     b.resize(sz);     static complex<double> aa[1 << 20], bb[1 << 20];     for (int i = 0; i < sz; i++) {       aa[i] = a[i];       bb[i] = b[i];     }     fft[__builtin_ctz(sz) - 1].conv(aa, bb);     a.resize(maxsz);     for (int i = 0; i < maxsz; i++) {       a[i] = real(aa[i]) + 0.5;       a[i] %= 1009;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     for (int i = 1; i <= 19; i++) fft.push_back(FFT(i));     cin >> n >> m >> k;     for (int i = 0; i < (n); i++) {       int v;       cin >> v;       cnt[v]++;     }     for (int i = 1; i <= (m); i++) {       if (cnt[i]) {         polys[i].resize(cnt[i] + 1);         fill((polys[i]).begin(), (polys[i]).end(), 1);         q.push(i);       }     }     while (q.size() > 1) {       int a = q.top();       q.pop();       int b = q.top();       q.pop();       mul(polys[a], polys[b]);       q.push(a);     }     vector<unsigned long long>& res = polys[q.top()];     cout << res[k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   int n, k, maxn = 2000000001;   int b[100001];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (int i = 0; i < k; i++) {       int r = (n - (k - i) * (k - i - 1) / 2) / (k - i);       if (r <= 0) {         cout <<  NO ;         return 0;       }       if (r > maxn) {         b[i] = maxn;         n -= maxn;         maxn = maxn * 2;       } else {         b[i] = r;         n -= r;         maxn = r * 2;       }       if (i == k - 1 && n != 0) {         cout <<  NO ;         return 0;       }     }     cout <<  YES  << endl;     for (int i = 0; i < k; i++) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, y;   } fei1[60], fei2[60];   int _hash[5100];   int main() {     int p, q, l, r, i, t, j, x, k;     scanf( %d%d%d%d , &p, &q, &l, &r);     for (i = 0; i < p; i++) {       scanf( %d%d , &fei1[i].x, &fei1[i].y);     }     for (i = 0; i < q; i++) {       scanf( %d%d , &fei2[i].x, &fei2[i].y);     }     x = 0;     for (i = l; i <= r; i++) {       memset(_hash, 0, sizeof(_hash));       for (j = 0; j < p; j++) {         for (k = fei1[j].x; k <= fei1[j].y; k++) {           _hash[k] = 1;         }       }       int flag = 0;       for (j = 0; j < q; j++) {         for (k = fei2[j].x + i; k <= fei2[j].y + i; k++) {           if (_hash[k]) {             flag = 1;             break;           }         }         if (flag) break;       }       if (flag) {         x++;       }     }     printf( %d n , x);     return 0;   }
#include <bits/stdc++.h>   int n;   char dir[1010];   int len[1010];   int realx[2030], cntx = 0;   int realy[2030], cnty = 0;   void unique(int *real, int &cnt) {     std::sort(real, real + cnt);     int t2 = 1;     for (int t1 = 1; t1 < cnt; t1++)       if (real[t1] ^ real[t1 - 1]) real[t2++] = real[t1];     cnt = t2;   }   int map[2030][2030];   inline bool legal(int x, int y) {     return x >= 0 && x <= cntx && y >= 0 && y <= cnty;   }   void dfs(int x, int y) {     map[x][y] = -1;     if (legal(x + 1, y) && !map[x + 1][y]) dfs(x + 1, y);     if (legal(x - 1, y) && !map[x - 1][y]) dfs(x - 1, y);     if (legal(x, y + 1) && !map[x][y + 1]) dfs(x, y + 1);     if (legal(x, y - 1) && !map[x][y - 1]) dfs(x, y - 1);   }   int main() {     scanf( %d , &n);     int curx = 0, cury = 0;     for (int i = 0; i < n; i++) {       scanf( %s%d , dir + i, len + i);       switch (dir[i]) {         case  L :           realx[cntx++] = curx + 1;           realx[cntx++] = curx -= len[i];           realy[cnty++] = cury;           realy[cnty++] = cury + 1;           break;         case  R :           realx[cntx++] = curx;           realx[cntx++] = (curx += len[i]) + 1;           realy[cnty++] = cury;           realy[cnty++] = cury + 1;           break;         case  U :           realy[cnty++] = cury;           realy[cnty++] = (cury += len[i]) + 1;           realx[cntx++] = curx;           realx[cntx++] = curx + 1;           break;         case  D :           realy[cnty++] = cury + 1;           realy[cnty++] = cury -= len[i];           realx[cntx++] = curx;           realx[cntx++] = curx + 1;           break;       }     }     unique(realx, cntx);     unique(realy, cnty);     int curxid = std::upper_bound(realx, realx + cntx, curx = 0) - realx,         curyid = std::upper_bound(realy, realy + cnty, cury = 0) - realy, nextid;     for (int i = 0; i < n; i++) switch (dir[i]) {         case  L :           nextid = std::upper_bound(realx, realx + cntx, curx -= len[i]) - realx;           for (; curxid > nextid; curxid--) map[curxid][curyid] = 1;           break;         case  R :           nextid = std::upper_bound(realx, realx + cntx, curx += len[i]) - realx;           for (; curxid < nextid; curxid++) map[curxid][curyid] = 1;           break;         case  U :           nextid = std::upper_bound(realy, realy + cnty, cury += len[i]) - realy;           for (; curyid < nextid; curyid++) map[curxid][curyid] = 1;           break;         case  D :           nextid = std::upper_bound(realy, realy + cnty, cury -= len[i]) - realy;           for (; curyid > nextid; curyid--) map[curxid][curyid] = 1;           break;       }     map[curxid][curyid] = 1;     for (int x = 0; x <= cntx; x++) {       if (!map[x][0]) dfs(x, 0);       if (!map[x][cnty]) dfs(x, cnty);     }     for (int y = 1; y < cnty; y++) {       if (!map[0][y]) dfs(0, y);       if (!map[cntx][y]) dfs(cntx, y);     }     long long ans = 0;     for (int x = 1; x <= cntx; x++)       for (int y = 1; y <= cnty; y++)         if (~map[x][y])           ans += (long long)(realx[x] - realx[x - 1]) * (realy[y] - realy[y - 1]);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e7;   long long int a[N], ans;   int main() {     long long int n;     cin >> n;     long long int l = 0, r = n - 1;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     for (int i = 0; i < n / 2; i++) {       ans += (a[l] + a[r]) * (a[l] + a[r]);       r--, l++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, aa, bb;     cin >> a >> b >> aa >> bb;     if (aa <= bb) aa = bb + 1;     vector<pair<int, int> > ans;     if (aa > a) {       cout << 0;       return 0;     } else {       for (int i = bb; i <= b; i++)         for (int j = (aa > i + 1 ? aa : i + 1); j <= a; j++) {           ans.push_back(make_pair(j, i));         }     }     sort(ans.begin(), ans.end());     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10005;   short dp[MAXN][MAXN];   int32_t main() {     ios::sync_with_stdio(false);     string s, t;     cin >> s >> t;     dp[0][0] = 0;     int n = s.size(), m = t.size();     for (int i = 0; i <= n + 3; i++)       for (int j = 0; j <= m + 3; j++) dp[i][j] = MAXN;     dp[0][0] = 0;     vector<int> prv(n + 1, -1);     vector<int> wh(2 * n + 1, -1);     wh[n] = 0;     for (int i = 1, v = 0; i <= n; i++) {       v += (s[i - 1] ==  .  ? -1 : 1);       if (s[i - 1] ==  .  && wh[v + n] != -1) prv[i] = wh[v + n];       wh[v + n] = i;     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= m; j++) {         if (j > 0 && s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1];         if (s[i - 1] ==  . ) dp[i][j] = dp[i - 1][j + 1];         dp[i][j] = min(dp[i][j], (short)(dp[i - 1][j] + 1));         if (prv[i] != -1) dp[i][j] = min(dp[i][j], dp[prv[i]][j]);       }     }     cout << dp[n][m] <<   n ;   }