malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 2;   const int INF = 1e9 + 1;   const double EPS = 1e-9;   int n, m;   int a[MAXN];   int r[MAXN], t[MAXN];   int b[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     int it = 0;     for (int i = 0; i < m; ++i) {       int ct, crt;       cin >> ct >> crt;       while (it > 0 && crt >= r[it - 1]) --it;       t[it] = ct;       r[it++] = crt;     }     r[it] = 0;     int bl = 0, br = r[0];     for (int i = 0; i < br; ++i) {       b[i] = a[i];     }     sort(b, b + br);     for (int i = 1; i < it + 1; ++i) {       for (int j = r[i - 1]; j > r[i]; --j) {         if (t[i - 1] == 1) {           a[j - 1] = b[--br];         } else           a[j - 1] = b[bl++];       }     }     for (int i = 0; i < n; ++i) {       cout << a[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   int a[1005];   int main() {     int x, i, j;     while (scanf( %d%*c , &x) != EOF) a[x] = 1;     bool flag = false;     for (i = j = 1; i < 1001; i = ++j)       if (a[i]) {         for (j = i; a[j]; ++j)           ;         --j;         if (!flag)           flag = true;         else           printf( , );         if (i == j)           printf( %d , i);         else           printf( %d-%d , i, j);       }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   const long long logN = 20;   const long long M = 1000000007;   const long long INF = 1e12;   const long long N = 505;   const long long K = 250505;   long long dp[K];   void solve() {     long long n, k;     cin >> n >> k;     long long A[n], B[n];     for (long long i = 0; i < n; i++) cin >> A[i] >> B[i];     long long r = 0, g = 0;     for (long long i = 0; i < n; i++) r += A[i], g += B[i];     dp[0] = 1;     for (long long i = 0; i < n; i++) {       long long r0 = A[i];       long long g0 = B[i];       if ((r0 + g0) < k) continue;       long long downr = max(k - g0, 0LL);       long long upr = min(r0, k);       long long mx = K;       for (long long i = K - 1; i >= 0; i--) {         if (dp[i] != 0) {           for (long long j = i + downr + 1; j < i + upr + 1; j++) {             if (j >= mx) break;             dp[j] = dp[i] + 1;           }           dp[i + downr] = dp[i] + 1;           mx = i + downr;         }       }     }     long long ans = 0;     for (long long i = 0; i < K; i++) {       if (dp[i] != 0) {         long long cnt = dp[i] - 1;         long long r0 = i;         long long g0 = cnt * k - r0;         cnt += (r - r0) / k + (g - g0) / k;         ans = max(ans, cnt);       }     }     cout << ans <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long no;     no = 1;     while (no--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, vector<long long> > mp;   long long a[200005];   long long t[200005];   set<long long> s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i], s.insert(a[i]);     for (long long i = 0; i < n; i++) {       cin >> t[i];       mp[a[i]].push_back(t[i]);     }     for (auto i : s) sort(mp[i].begin(), mp[i].end());     long long ans = 0;     multiset<long long> temp;     long long sum = 0;     while (s.size()) {       long long v = *s.begin();       s.erase(s.begin());       for (auto i : mp[v]) temp.insert(i), sum += i;       auto p = s.lower_bound(v);       long long nex = 1e18;       if (p != s.end()) nex = *p;       long long d = nex - v;       long long siz = min(d, (long long)temp.size());       long long c = 0;       while (siz--) {         auto po = prev(temp.end());         ans += (*po) * c;         c++;         sum -= (*po);         temp.erase(po);       }       ans += sum * c;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1e6 + 7;   int N, a[maxN], f[(1LL << 22) + 7];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N;     memset(f, -1, sizeof f);     for (int i = 1; i <= N; i++) {       cin >> a[i];       f[a[i]] = a[i];     }     for (int i = 0; i <= 22; i++)       for (int mask = 0; mask < (1LL << 22); mask++)         if (mask & (1LL << i)) f[mask] = max(f[mask], f[mask ^ (1LL << i)]);     for (int i = 1; i <= N; i++) {       cout << f[(1LL << 22) - 1 - a[i]] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long rd() {     char c;     while (c = getchar(), c <  0  || c >  9 )       ;     long long X = c - 48;     while (c = getchar(), c >=  0  && c <=  9 ) X = X * 10 + c - 48;     return X;   }   template <class T>   inline void print(T x) {     if (x < 0) {       putchar( - );       return print(-x);     }     if (x < 10) {       putchar( 0  + x);       return;     }     print(x / 10);     putchar(x % 10 +  0 );   }   string s;   void solve(int n, vector<int> &a) {     if (n == 1) {       s =  B ;       return;     }     vector<int> idx(n + 1);     s = string(n,  B );     for (__typeof(0) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));          i += 1 - (((0) > (n)) << 1))       idx[a[i]] = i;     for (__typeof(n + 1) i = (n + 1) - ((n + 1) > (1));          i != (1) - ((n + 1) > (1)); i += 1 - (((n + 1) > (1)) << 1)) {       for (int j = idx[i] - i; j >= 0; j -= i) {         if (a[j] > i and s[j] ==  B ) {           s[idx[i]] =  A ;           break;         }       }       for (int j = idx[i] + i; j < n; j += i) {         if (a[j] > i and s[j] ==  B ) {           s[idx[i]] =  A ;           break;         }       }     }   }   int32_t main() {     int n;     cin >> n;     vector<int> a(n);     for (int &i : a) cin >> i;     solve(n, a);     cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const long long INF = (long long)1e14 + 5;   long long N, cur = 1, last = 0, ans[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> N;     for (int i = 1; i <= N; i += 2) {       long long x;       cin >> x;       while (cur * cur <= INF) {         long long l = last + 1, r = cur - 1, found = -1;         while (l <= r) {           long long m = (l + r) >> 1;           if (cur * cur - m * m == x) {             found = m;             break;           } else if (cur * cur - m * m > x)             l = m + 1;           else             r = m - 1;         }         if (found != -1) {           ans[i] = found * found - last * last;           ans[i + 1] = x;           last = cur;           cur++;           break;         }         cur++;       }       if (cur * cur > INF) {         cout <<  No n ;         return 0;       }     }     cout <<  Yes n ;     for (int i = 1; i <= N; i++) {       cout << ans[i] << (i + 1 <= N ?     :   n );     }   }
#include <bits/stdc++.h>   using namespace std;   typedef int nod[100010];   typedef int edg[200010];   int n, m;   int e = 1;   nod h;   edg link, v, u;   nod vis;   nod fz;   int ju;   void creat(int x, int y) {     link[++e] = h[x];     h[x] = e;     v[e] = y;     link[++e] = h[y];     h[y] = e;     v[e] = x;   }   int dfs(int x) {     if (vis[x])       return 0;     else       vis[x] = 1;     for (int i = h[x]; i; i = link[i])       if (!u[i]) {         u[i] = u[i ^ 1] = 1;         if ((ju = dfs(v[i])))           printf( %d %d %d n , x, v[i], ju);         else if (!fz[x])           fz[x] = v[i];         else           printf( %d %d %d n , fz[x], x, v[i]), fz[x] = 0;       }     return fz[x];   }   int main() {     scanf( %d%d , &n, &m);     if (m & 1) {       printf( No solution n );       return 0;     }     for (int i = 1, x, y; i <= m; ++i) scanf( %d%d , &x, &y), creat(x, y);     dfs(1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int K = 5;   void NO() {     puts( unfair );     exit(0);   }   int main() {     int n, b, q;     scanf( %d%d%d , &n, &b, &q);     vector<pair<int, int>> w;     w.push_back(make_pair(b, n));     while (q--) {       int a, b;       scanf( %d%d , &a, &b);       w.push_back(make_pair(a, b));     }     sort(w.begin(), w.end());     for (int mask = 0; mask < (1 << K); ++mask) {       int at_least = 0, at_most = 0;       int prev_upto = 0, prev_quan = 0;       for (pair<int, int> query : w) {         int now_upto = query.first, now_quan = query.second;         int places_matching = 0;         int places_other = 0;         for (int i = prev_upto + 1; i <= now_upto; ++i) {           if (mask & (1 << (i % K)))             ++places_matching;           else             ++places_other;         }         if (now_quan < prev_quan) NO();         int quan = now_quan - prev_quan;         int places_total = now_upto - prev_upto;         assert(places_total == places_matching + places_other);         if (quan > places_total) NO();         at_least += max(0, quan - places_other);         at_most += min(quan, places_matching);         prev_upto = now_upto;         prev_quan = now_quan;       }       int must_be = n / K * __builtin_popcount(mask);       if (!(at_least <= must_be && must_be <= at_most)) NO();     }     puts( fair );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char W[1000 + 10];   int N[1000 + 10];   int main() {     int n, m;     scanf( %d%d%s , &n, &m, W);     for (int i = 0; i < n; ++i) (N[i] = W[i] -  a );     bool fixed = false;     for (int i = n - 1; i >= 0; --i) {       while (true) {         N[i]++;         if (N[i] == m) break;         if (i - 1 >= 0 && N[i] == N[i - 1]) continue;         if (i - 2 >= 0 && N[i] == N[i - 2]) continue;         fixed = true;         for (int j = i + 1; j < n; ++j) {           N[j] = -1;           while (true) {             N[j]++;             if (j - 1 >= 0 && N[j] == N[j - 1]) continue;             if (j - 2 >= 0 && N[j] == N[j - 2]) continue;             break;           }         }         break;       }       if (fixed) break;     }     if (!fixed)       printf( NO n );     else {       for (int i = 0; i < n; ++i) printf( %c ,  a  + N[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int matriz[1010][1010];   void verifica(int i, int j);   int main(void) {     int n, m, d;     d = 0;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         char a;         cin >> a;         if (a ==  # ) {           matriz[i][j] = 0;           d++;         } else           matriz[i][j] = -1;       }     }     for (int i = 1; i <= n - 2; i++) {       for (int j = 1; j <= m - 2; j++) {         verifica(i, j);       }     }     int h = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (matriz[i][j] > 0) {           h++;         }       }     }     if (d == 0) {       cout <<  YES  << endl;     } else {       if ((h == d) && (h != 0)) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     }   }   void verifica(int a, int b) {     int k = 1;     if ((matriz[a - 1][b - 1] == -1) || (matriz[a - 1][b] == -1) ||         (matriz[a - 1][b + 1] == -1) || (matriz[a][b - 1] == -1) ||         (matriz[a][b + 1] == -1) || (matriz[a + 1][b - 1] == -1) ||         (matriz[a + 1][b] == -1) || (matriz[a + 1][b + 1] == -1)) {       k = 0;     }     if (k) {       matriz[a - 1][b - 1] += 1;       matriz[a - 1][b] += 1;       matriz[a - 1][b + 1] += 1;       matriz[a][b - 1] += 1;       matriz[a][b + 1] += 1;       matriz[a + 1][b - 1] += 1;       matriz[a + 1][b] += 1;       matriz[a + 1][b + 1] += 1;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimization( unroll-loops )   using namespace std;   const long long large = 1e11, remi2 = 998244353;   const long long remi = 1e9 + 7, inf = LLONG_MAX;   const long double Pi = acos(-1);   long long PowI(long long a, long long b, long long m) {     long long ans = 1 % m;     while (b > 0) {       if (b % 2) ans = (((ans % m) * (a % m)) % m);       a = (((a % m) * (a % m)) % m);       b = (long long)(b / ((long long)2));     }     return ans;   }   void Foxtrot() {     long long n, k;     cin >> n >> k;     vector<long long> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     sort(v.begin(), v.end());     long long sum = 0;     for (int i = 0; i < (n - (2 * k)); i++) {       sum += v[i];     }     for (long long i = n - 2 * k; i < (n - k); i++) {       sum += (v[i] / v[i + k]);     }     cout << sum <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long T = 1;     cin >> T;     for (int i = 1; i < T + 1; i++) {       Foxtrot();     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   using namespace std;   bool Finish_read;   template <class T>   inline void read(T &x) {     Finish_read = 0;     x = 0;     int f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       if (ch == EOF) return;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     x *= f;     Finish_read = 1;   }   template <class T>   inline void print(T x) {     if (x / 10 != 0) print(x / 10);     putchar(x % 10 +  0 );   }   template <class T>   inline void writeln(T x) {     if (x < 0) putchar( - );     x = abs(x);     print(x);     putchar(  n );   }   template <class T>   inline void write(T x) {     if (x < 0) putchar( - );     x = abs(x);     print(x);   }   const int maxn = 100005, maxlog = 20;   int mx[maxlog][maxn], n, c, v[100005];   long long f[maxn], sum[maxn];   inline int get(int l, int r) {     int k = log2(r - l + 1);     return min(mx[k][l], mx[k][r - (1 << k) + 1]);   }   int main() {     read(n);     read(c);     for (int i = 1; i <= n; i++) {       read(v[i]);       mx[0][i] = v[i];       sum[i] = sum[i - 1] + v[i];     }     for (int j = 1; (1 << j) <= n; j++)       for (int i = 1; i + (1 << j) - 1 <= n; i++)         mx[j][i] = min(mx[j - 1][i], mx[j - 1][i + (1 << (j - 1))]);     for (int i = 1; i < c; i++) f[i] = f[i - 1] + v[i];     for (int i = c; i <= n; i++)       f[i] = min(f[i - 1] + v[i],                  f[i - c] + sum[i] - sum[i - c] - get(i - c + 1, i));     printf( %lld n , f[n]);   }
#include <bits/stdc++.h>   using namespace std;   int i, j, n, t, k1[10000], k2[10000], cz1 = 0, cz11 = 0;   char s1[10000], s2[10000];   int main() {     scanf( %d , &n);     while (n--) {       scanf( %d , &t);       scanf( %s , s1);       scanf( %s , s2);       for (i = 0; i < strlen(s1); i++) {         k1[i] = s1[i] -  0 ;         if (k1[i] == 0) {           cz1++;         }       }       for (i = 0; i < strlen(s2); i++) {         k2[i] = s2[i] -  0 ;         if (k2[i] == 0) {           cz1++;         }       }       if (cz1 == 0) {         printf( YES n );       } else {         for (j = 0; j < t; j++) {           if (k1[j] != 0 && k2[j] != 0) {             cz11++;           }         }         if (cz11 >= 1) {           printf( NO n );         } else {           printf( YES n );         }       }       cz1 = 0, cz11 = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, p;   int get(int x) {     int sum = 0;     while (x) {       if (x & 1) sum++;       x >>= 1;     }     return sum;   }   int main() {     scanf( %lld%lld , &n, &p);     int sum = 0;     while (n - sum * p > 0) {       int s = get(n - sum * p);       if (sum >= s && sum <= n - sum * p) {         printf( %d n , sum);         return 0;       }       sum++;     }     puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     vector<long long> a(n), b(n), idxs(n + 1), ans(n, n);     multiset<long long> s1, s2;     for (long long i = 0; i < n; i++) {       cin >> a[i];       idxs[a[i]] = i;     }     for (long long i = 0; i < n; i++) {       cin >> b[i];       if (idxs[b[i]] < i) {         s1.insert(i - idxs[b[i]]);       } else {         s2.insert(idxs[b[i]] - i);       }     }     for (long long i = 0; i < n; i++) {       while (s1.size() && *s1.begin() == i) {         s2.insert(-i);         s1.erase(s1.find(i));       }       if (s1.size()) {         ans[i] = min(ans[i], *s1.begin() - i);       }       if (s2.size()) {         ans[i] = min(ans[i], i + *s2.begin());       }       assert(s2.count(idxs[b[i]] - i));       s2.erase(s2.find(idxs[b[i]] - i));       s1.insert(n - idxs[b[i]] + i);     }     for (long long i = 0; i < n; i++) cout << ans[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[300005];   int main() {     long long n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++)       for (int j = i + i; j <= n; j += i) dp[j]++;     long long sum = 0, m = 0;     for (int i = 1; i <= n; i++) {       sum += dp[i];       if (sum >= k) {         m = i;         break;       }     }     vector<pair<long long, long long> > vec;     for (int i = m / 2 + 1; i <= m; i++) vec.emplace_back(dp[i], i);     sort(vec.rbegin(), vec.rend());     set<int> st;     for (int i = 1; i <= m; i++) st.insert(i);     k = sum - k;     for (int i = 0; i < vec.size() and k > 0; i++) {       if (vec[i].first <= k) {         k -= vec[i].first;         st.erase(vec[i].second);       }     }     if (k != 0)       cout <<  No  << endl;     else {       cout <<  Yes  << endl;       cout << st.size() << endl;       for (int val : st) cout << val <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k, s, p, x[100001], t[100001], w[100001];   void sort1(int l, int r) {     int i, j, y, z;     i = l;     j = r;     y = x[(l + r) / 2];     do {       while (x[i] < y) {         i++;       }       while (x[j] > y) {         j--;       }       if (!(i > j)) {         z = x[i];         x[i] = x[j];         x[j] = z;         z = t[i];         t[i] = t[j];         t[j] = z;         i++;         j--;       }     } while (!(i > j));     if (l < j) {       sort1(l, j);     }     if (i < r) {       sort1(i, r);     }   }   void sort2(int l, int r) {     int i, j, y, z;     i = l;     j = r;     y = t[(l + r) / 2];     do {       while (t[i] < y) {         i++;       }       while (t[j] > y) {         j--;       }       if (!(i > j)) {         z = x[i];         x[i] = x[j];         x[j] = z;         z = t[i];         t[i] = t[j];         t[j] = z;         z = w[i];         w[i] = w[j];         w[j] = z;         i++;         j--;       }     } while (!(i > j));     if (l < j) {       sort2(l, j);     }     if (i < r) {       sort2(i, r);     }   }   int main() {     scanf( %d %d n , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d %d n , &t[i], &x[i]);     }     i = m;     s = 0;     while (i <= n) {       s = max(s, t[i]);       sort1(i - m + 1, i);       p = x[i];       k = 1;       w[i - m + 1] = s + x[i - m + 1];       for (j = i - m + 2; j <= i; j++) {         if (x[j] == x[j - 1]) {           k++;         } else {           s += 1 + (k / 2);           k = 1;         }         w[j] = s + x[j];       }       s += p + 1 + p + (k / 2);       i += m;     }     if (i - m < n) {       s = max(s, t[n]);       sort1(i - m + 1, n);       p = x[n];       k = 1;       w[i - m + 1] = s + x[i - m + 1];       for (j = i - m + 2; j <= n; j++) {         if (x[j] == x[j - 1]) {           k++;         } else {           s += 1 + k / 2;           k = 1;         }         w[j] = s + x[j];       }       s += p + 1 + p + k / 2;     }     sort2(1, n);     for (i = 1; i <= n; i++) {       printf( %d  , w[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   priority_queue<pair<long long, pair<long long, long long>>> pq;   long long divide(long long x, long long y) {     if (x < y) return 1e16;     long long t = x / y, rm = x % y;     t += rm / y;     rm %= y;     return rm * (t + 1) * (t + 1) + (y - rm) * t * t;   }   void solve() {     cin >> n >> k;     long long ans = 0;     k -= n;     while (n--) {       long long x;       cin >> x;       ans += x * x;       pq.push({x * x - divide(x, 2), {x, 2}});     }     while (k--) {       auto x = pq.top();       pq.pop();       ans -= x.first;       pq.push({divide(x.second.first, x.second.second) -                    divide(x.second.first, x.second.second + 1),                {x.second.first, x.second.second + 1}});     }     cout << ans <<   n ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     solve();   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define ull unsigned long long   #define inf INT_MAX   #define minf INT_MIN   #define infl LLONG_MAX   #define minfl LLONG_MIN   #define mod 1000000007         /*----------------------Debugger-----------------------------------*/      #ifndef ONLINE_JUDGE   #define show(x) cerr<< #x << :  ; _print(x); cerr <<endl;   #else   #define show(x)   #endif      template<class T> void _print(T x){ cerr<<x<<endl; }   template<class T> void _print(vector<T> x){cerr<< [ ; for(auto i: x) cerr<<i<< ,  ; cerr<< ] n ;}   template<class T> void _print(set<T> x){ cerr<< {  ; for(auto i: x) cerr<<i<< ,  ; cerr<< } n ;}         /*-------------------------------------------------------------------------------------------------*/      ll exp(int a,int b,int p){ll res=1; a=a%p;     while(b){ if(b & 1) res=(res*a)%p; a=((ll)a*a)%p; b=b>>1; } return res; }      ll mmiPrime(int a, int p){ return exp(a,p-2,p); }      pair<int,int> extendedGCD(int a, int b){ if(b==0){ pair<int,int> ans; ans.first=1; ans.second=0; return ans; }    pair<int,int> temp=extendedGCD(b,a%b); pair<int,int> ans;    ans.first=temp.second; ans.second=temp.first - (a/b)*temp.second; return ans; }      int mmi(int a, int m){ pair<int,int> tmp=extendedGCD(a,m); return tmp.first; }      int ncr(int n,int r, int p, int fact[]){ return ((fact[n] * mmiPrime(fact[r],p) % p) * mmiPrime(fact[n-r],p))%p; }      /*-------------------------------------------------------------------------------------------------*/         void solve(){    int n,k;    cin>>n>>k;    int a[k];    int t[k];       for(int i=0;i<k;i++)     cin>>a[i];          for(int i=0;i<k;i++)     cin>>t[i];       vector<ll> ac(n+1,INT_MAX);       for(int i=0;i<k;i++){     ac[a[i]]=t[i];    }          ll L[n+1],R[n+1];       ll p=INT_MAX;    for(int i=1;i<=n;i++){     p=min(p+1,ac[i]);     L[i]=p;    }       p=INT_MAX;    for(int i=n;i>0;i--){     p=min(p+1,ac[i]);     R[i]=p;    }       for(int i=1;i<=n;i++)     cout<<min(L[i],R[i])<<   ;    cout<<  n ;      }      int main(){    ios_base::sync_with_stdio(false); cin.tie(NULL);       #ifndef ONLINE_JUDGE     freopen( input.txt , r ,stdin);     freopen( output.txt , w ,stdout);     freopen( error.txt , w ,stderr);    #endif       clock_t time = clock();       int t;    cin>>t;    while(t--){     solve();    }       time = clock() - time;        #ifndef ONLINE_JUDGE     cout<< time:  <<time*1000/CLOCKS_PER_SEC<<  miliseconds n ;    #endif       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int main() {     int n;     cin >> n;     long long int n1 = 0, n0 = 0, x1 = 0, x0 = 0;     string a, b;     cin >> a >> b;     for (int i = 0; i < n; i++) {       if (a[i] ==  0  && b[i] ==  1 ) n0++;       if (a[i] ==  1  && b[i] ==  1 ) n1++;       if (a[i] ==  1  && b[i] ==  0 ) x1++;       if (a[i] ==  0  && b[i] ==  0 ) x0++;     }     long long int ans = 0;     for (int i = 0; i < n; i++) {       if (b[i] ==  0 ) {         if (a[i] ==  1 )           ans += n0;         else           ans += n1;       }     }     ans += x1 * x0;     cout << ans;     return 0;   }