malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int n;     cin >> n;     string s;     cin >> s;     vector<long long int> v(n + 1, 0);     for (long long int i = 1; i <= n; i++) {       if (s[i - 1] ==  ( )         v[i] = v[i - 1] + 1;       else         v[i] = v[i - 1] - 1;     }     if (v[n] != 0) {       cout <<  -1  <<   n ;       return 0;     }     long long int ans = 0;     long long int temp = 0;     for (long long int i = 1; i <= n; i++) {       if (v[i] < 0) {         temp++;       } else if (v[i] == 0 && v[i - 1] < 0) {         temp++;         ans += temp;         temp = 0;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using vi = vector<int>;   using vll = vector<ll, ll>;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   ll modpow(ll a, ll b, ll mod = (ll)(1e9 + 7)) {     if (!b) return 1;     a %= mod;     return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int DEBUG = 1;   const int mxk = 13, mxm = 4, dsz = (1 << mxm) * mxk, mod = 1e9 + 7;   int n, m, k;   void add(ll &a, ll b) {     a += b;     if (a >= mod) a -= mod;   }   struct Matrix {     ll a[dsz][dsz];     Matrix() {       for (int i = 0; i < dsz; i++)         for (int j = 0; j < dsz; j++) a[i][j] = 0;     }   } id;   void init() {     for (int i = 0; i < dsz; i++) id.a[i][i] = 1;   }   Matrix operator*(Matrix a, Matrix b) {     Matrix ret;     for (int i = 0; i < dsz; i++)       for (int j = 0; j < dsz; j++)         for (int kk = 0; kk < dsz; kk++)           add(ret.a[i][kk], a.a[i][j] * b.a[j][kk] % mod);     return ret;   }   int cnv(int mask, int kk) { return (kk << mxm) + mask; }   int rot(int mask) { return (mask << 1) % (1 << m); }   Matrix modpow(Matrix a, ll b) {     Matrix ans = id;     while (b) {       if (b & 1) ans = ans * a;       a = a * a;       b /= 2;     }     return ans;   }   void solve() {     init();     Matrix op;     for (int mask = 0; mask < 1 << m; mask++)       for (int kk = 0; kk <= k; kk++) {         add(op.a[cnv(rot(mask), kk)][cnv(mask, kk)], 1);         if (kk < k)           add(op.a[cnv(rot(mask) + 1, kk + 1)][cnv(mask, kk)],               1 + __builtin_popcount(mask));       }     Matrix b;     b.a[0][0] = 1;     Matrix res = modpow(op, n) * b;     ll ans = 0;     for (int mask = 0; mask < 1 << m; mask++) add(ans, res.a[cnv(mask, k)][0]);     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     while (cin >> n >> k >> m) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   bool chmax(T& a, const T& b) {     return a < b ? (a = b, true) : false;   }   template <typename T>   bool chmin(T& a, const T& b) {     return b < a ? (a = b, true) : false;   }   int N;   string S;   int main() {     cin >> S;     N = S.size();     for (int i = (1); i < (N); i++) {       if (S[i] == S[i - 1]) {         cout <<  Impossible  << endl;         return 0;       }     }     char twice;     for (char c =  A ; c <=  Z ; c++) {       if (count((S).begin(), (S).end(), c) == 2) {         twice = c;         break;       }     }     int x = S.find(twice), y = S.find(twice, x + 1);     string a = S.substr(0, x), b = S.substr(x + 1, y - x - 1),            c = S.substr(y + 1);     string t = b + c + a;     vector<string> ans(2, string(13,  . ));     ans[0][12 - b.size() / 2] = twice;     int idx = 0;     bool flag = false;     while (true) {       for (int i = 0; i < 13; i++) {         if (ans[0][i] == twice && flag == false) {           flag = true;         } else if (ans[0][i] == twice && flag == true) {           cout << ans[0] << endl;           cout << ans[1] << endl;           return 0;         } else if (flag && idx < t.size()) {           ans[0][i] = t[idx++];         }       }       for (int i = 12; i >= 0; i--) {         if (flag && idx < t.size()) {           ans[1][i] = t[idx++];         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const long long INFLL = 1000000000000000000LL;   const int h = 300000000;   int l, r;   int pr[(h >> 6) + 1];   int main() {     scanf( %d%d , &l, &r);     int res = 0;     int r2 = (r - 1) / 2;     pr[0] |= 1;     for (int i = (1), _b = ((sqrt(2.0 * r2 + 1) + 1) / 2); i < _b; ++i)       if ((~pr[i >> 5]) & (1 << (i & 31)))         for (int i2 = 2 * i + 1, v = i * (i + 1) << 1; v <= r2; v += i2)           pr[v >> 5] |= 1 << (v & 31);     if (l <= 2 && 2 <= r) ++res;     for (int v = 2; v <= r2; v += 2)       if (l <= 2 * v + 1 && (~pr[v >> 5]) & (1 << (v & 31))) ++res;     printf( %d n , res);     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define pb push_back   #define f first   #define s second   #define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)   /*      ll dx[8]={-1,-1,-1,0,0,1,1,1};   ll dy[8]={-1,0,1,-1,1,-1,0,1};   bool sortbysec(const pair<int,int> &a,                 const pair<int,int> &b)   {       return (a.second < b.second);   }   */   int main()   {        ll t;        cin>>t;        while(t--)        {            ll n;            cin>>n;            for(int i=2;i<=n;i++)               cout<<i<<   ;            cout<< 1 <<endl;        }      }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   map<int, int> mp;   int n;   struct pnt {     int x, w;     bool operator<(const pnt &p) const { return x < p.x; }   } p[maxn];   int ask(int x) {     int res = 0;     for (int i = x; i > 0; i -= (i & -i))       if (mp.count(i)) res = max(res, mp[i]);     return res;   }   void update(int x, int v) {     for (int i = x; i < 0x3f3f3f3f; i += (i & -i)) mp[i] = max(mp[i], v);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d%d , &p[i].x, &p[i].w);     sort(p, p + n);     int ans = 0;     for (int i = 0; i < n; i++) {       int tmp = ask(p[i].x - p[i].w);       ans = max(ans, tmp + 1);       update(p[i].x + p[i].w, tmp + 1);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     for (int i = n + 1; i < 10000; i++) {       int d = i % 10;       int c = (i % 100 - d) / 10;       int a = i / 1000;       int b = (i - 1000 * a) / 100;       if (a != b && a != c && a != d && b != c && b != d && c != d) {         printf( %d%d%d%d , a, b, c, d);         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 2;   long long n, m;   long long a[N], b[N];   long long f(long long x) {     long long res = 0;     for (long long(i) = (0); (i) < (n); (i)++) {       if (a[i] < x) res += llabs(a[i] - x);     }     for (long long(i) = (0); (i) < (m); (i)++) {       if (b[i] > x) res += llabs(b[i] - x);     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n >> m;     for (long long(i) = (0); (i) < (n); (i)++) cin >> a[i];     for (long long(i) = (0); (i) < (m); (i)++) cin >> b[i];     long long le = 1, ri = 1e9;     while (llabs(ri - le) > 3) {       long long m1 = le + (ri - le) / 3;       long long m2 = ri - (ri - le) / 3;       if (f(m1) < f(m2))         ri = m2;       else         le = m1;     }     long long ans = 1e18;     for (long long(x) = (le); (x) < (ri + 1); (x)++) {       ans = min(ans, f(x));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       long long ma = -1e15, need = 0;       for (int i = 0; i < n; i++) {         long long a;         cin >> a;         ma = max(a, ma);         need = max(need, ma - a);       }       long long ans = 0;       while ((1ll << ans) - 1 < need) ans++;       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double eps = 1e-12;     double y1, y2, yw, xb, yb, r;     cin >> y1 >> y2 >> yw >> xb >> yb >> r;     double yk = yw - r;     double yt = y1 + r;     double d1 = yk - yt;     double d2 = yk - yb;     double xk = xb * d1 / (d2 + d1);     double A = yt - yk;     double B = xk;     double C = -B * yt;     double h = fabs(B * y2 + C) / sqrt(A * A + B * B);     if (r > h - eps) {       cout << -1 << endl;     } else {       printf( %.12lf n , xk - eps);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int mod = 1e9 + 7;   int n, a[500010], b[500010], c[500010], bit[500010];   void init() {     for (int i = 1; i <= n; i++) {       bit[i] = 0;     }   }   int lowbit(int x) { return x & (-x); }   void add(int u, int x) {     for (; u <= n; u += lowbit(u)) {       bit[u] = (bit[u] + x) % mod;     }   }   int sum(int u) {     int res = 0;     for (; u >= 1; u -= lowbit(u)) {       res = (res + bit[u]) % mod;     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     sort(b + 1, b + n + 1);     for (int i = 1; i <= n; i++) {       a[i] = lower_bound(b + 1, b + n + 1, a[i]) - b;     }     int ans = 0;     init();     for (int i = 1; i <= n; i++) {       ans = (ans + 1LL * b[a[i]] * sum(a[i]) % mod * (n - i + 1) % mod) % mod;       c[a[i]] += sum(a[i]) * (n - i + 1);       add(a[i], i);     }     init();     for (int i = n; i >= 1; i--) {       ans = (ans + 1LL * b[a[i]] * sum(a[i]) % mod * i % mod) % mod;       c[a[i]] += sum(a[i]) * i;       add(a[i], n - i + 1);     }     for (int i = 1; i <= n; i++) {       ans = (ans + 1LL * b[a[i]] * i % mod * (n - i + 1) % mod) % mod;       c[a[i]] += i * (n - i + 1);     }     printf( %d n , ans);     return 0;   }
#include<bits/stdc++.h>   // #define int long long   #define ld long double   #define fi first   #define se second   #define vll vector<int>   #define pii pair<int,int>   #define pb push_back   #define sz(v) (int)(v).size()   #define inf (int)(1e8)   #define md (int)(1e9+7)   #define all(v) (v).begin(),(v).end()   #define rep(i,a,b) for(int i=a;i<b;++i)   using namespace std;      const int M = 50 + 11;   const int K = 251;      int n;   string s;   int dp[2][M][K][K];   /*   int f(int i,int car,int pos,int neg) {    if(pos<0 or neg<0 or car+30>=M or car+30<0) return inf;    if(i>=n) return car?inf:0;    if(dp[i][car+30][pos][neg]!=-1) return dp[i][car+30][pos][neg];    int ans=min(f(i,car,pos-1,neg),f(i,car,pos,neg-1));    int now=s[i]- 0 ,tot=pos-neg+car;    if((tot%10+10)%10==now) {     ans=min(ans,f(i+1,tot/10+(tot>0?0:-1)*(bool)(tot%10),pos,neg)+pos+neg);    }    return dp[i][car+30][pos][neg]=ans;   }   */   int32_t main(){       ios_base::sync_with_stdio(false);       cin.tie(0);              cin>>s;       reverse(all(s));       s+= 0 ;       n=sz(s);       rep(i,0,2)rep(car,0,M)rep(pos,0,K)rep(neg,0,K) dp[i][car][pos][neg]=inf;      rep(pos,0,K)rep(neg,0,K) dp[0][0+M/2][pos][neg]=0;      for(int i=n-1;i>=0;--i) {       rep(car,-M/2,M/2+1)rep(pos,0,K)rep(neg,0,K) {        int &ans=dp[1][car+M/2][pos][neg];        if(pos) ans=min(ans,dp[1][car+M/2][pos-1][neg]);        if(neg) ans=min(ans,dp[1][car+M/2][pos][neg-1]);        int now=s[i]- 0 ,tot=pos-neg+car;        if((tot%10+10)%10==now) {         int ncar=tot/10+(tot>0?0:-1)*(bool)(tot%10)+M/2;         if(ncar<0 or ncar>=M) continue;         ans=min(ans,dp[0][ncar][pos][neg]+pos+neg);        }       }       rep(car,-M/2,M/2+1)rep(pos,0,K)rep(neg,0,K) {        dp[0][car+M/2][pos][neg]=dp[1][car+M/2][pos][neg];        dp[1][car+M/2][pos][neg]=inf;       }      }      cout<<dp[0][0+M/2][K-1][K-1];      /*       memset(dp,-1,sizeof(dp));       cout<<f(0,0,K-1,K-1);       */              return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mx, mx2;   void solve(long long m, long long blocks, long long sum) {     if (m == 0) {       if (blocks > mx) {         mx = blocks;         mx2 = sum;       } else if (blocks == mx && sum > mx2) {         mx2 = sum;       }       return;     }     long long x = 1;     while ((x + 1) * (x + 1) * (x + 1) <= m) x++;     solve(m - x * x * x, blocks + 1, sum + x * x * x);     solve(x * x * x - 1 - (x - 1) * (x - 1) * (x - 1), blocks + 1,           sum + (x - 1) * (x - 1) * (x - 1));   }   int main() {     long long m;     cin >> m;     solve(m, 0, 0);     cout << mx <<     << mx2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int num[300];   int main() {     int n, a, minn = 99999, sum = 0, sum2 = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &num[i]);     for (int i = 1; i <= n; i++) sum += abs(num[i]);     printf( %d n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long t, n, m;     cin >> t;     while (t--) {       cin >> n >> m;       if (n == 1 || m == 1 || (n == 2 && m == 2)) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma )   #pragma GCC optimize( unroll-loops )   using namespace std;   const double eps = 1e-12;   const long long MOD = 1e9 + 7;   const double PI = acos(-1.0);   const long long INF = 1e18;   void solve() {     long long n, m, k;     cin >> n >> m >> k;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     vector<long long> pref(n + 1, 0);     pref[1] = a[0];     for (long long i = 2; i <= n; i++) {       pref[i] = pref[i - 1] + a[i - 1];     }     vector<long long> sums(n + 1, 0);     for (long long i = 0; i + m <= n; i++) {       sums[i] = pref[i + m] - pref[i];     }     long long dp[n + 1][k + 1];     memset(dp, 0, sizeof(dp));     for (long long i = 0; i <= n; i++) {       for (long long j = 1; j <= k; j++) {         if (i < j - 1) continue;         dp[i][j] = max(((i - m >= 0) ? dp[i - m][j - 1] : 0) + sums[i],                        ((i - 1 >= 0) ? dp[i - 1][j] : 0));       }     }     long long ans = 0;     for (long long i = 0; i <= n; i++) {       ans = max(dp[i][k], ans);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int k = a + b + c + d;     if (k % 2 == 0) {       if (a + b == k / 2 || a + c == k / 2 || a + d == k / 2 || b + c == k / 2 ||           b + d == k / 2 || c + d == k / 2 || a + b + c == k / 2 ||           a + b + d == k / 2 || a + c + d == k / 2 || b + c + d == k / 2)         cout <<  YES n ;       else         cout <<  NO n ;     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 510;   const int MAXQ = 100010;   const double EPS = 1e-10;   const double DINF = 1e30;   const int IINF = ~0U >> 3;   const long long LINF = 1LL << 61;   void debug() { cout <<  error_here  << endl; }   char str[MAXN][MAXN];   int a[MAXN][MAXN], b[MAXN][MAXN];   int n, m, k;   void init() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < n; ++i) scanf( %s , str[i]);     memset(a, 0, sizeof(a));     memset(b, 0, sizeof(b));     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) a[i][j] = (str[i - 1][j - 1] ==  1 );     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] && a[i - 1][j] && a[i + 1][j] && a[i][j - 1] && a[i][j + 1])           b[i][j] = 1;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];   }   int get_sum(int x, int y, int xx, int yy) {     return b[xx][yy] - b[xx][y - 1] - b[x - 1][yy] + b[x - 1][y - 1];   }   void solve() {     long long ans = 0;     for (int u = 1; u <= n; ++u)       for (int v = u + 2; v <= n; ++v) {         for (int i = 1, j = 3; i <= m && j <= m;) {           if (get_sum(u + 1, i + 1, v - 1, j - 1) >= k)             ans += m - j + 1, i++;           else             j++;         }       }     cout << ans << endl;   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int comp(pair<long long int, long long int> a,                      pair<long long int, long long int> b) {     if (a.first != b.first) return a < b;     return a.second < b.second;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     vector<pair<long long int, long long int>> v;     for (long long int i = 0; i < n; i++) {       long long int x, y;       cin >> x >> y;       x += 1000;       y += 1000;       v.push_back({x, y});     }     sort(v.begin(), v.end(), comp);     long long int cnt = 0;     for (long long int i = 0; i < n; i++) {       for (long long int j = i + 1; j < n; j++) {         if (((((v[i].first + v[j].first)) % 2 == 0) &&              (((v[i].second + v[j].second)) % 2 == 0))) {           long long int x1, y1;           x1 = (v[i].first + v[j].first) / 2;           y1 = (v[i].second + v[j].second) / 2;           long long int lo = i + 1, hi = j - 1, id = -1;           while (lo <= hi) {             long long int mid = (lo + hi) / 2;             if (v[mid].first >= x1) {               id = mid;               hi = mid - 1;             } else if (v[mid].first < x1)               lo = mid + 1;           }           if (id != -1) {             while (v[id].first == x1 && id < n) {               if (v[id].second == y1) {                 cnt++;                 break;               }               id++;             }           }         }       }     }     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1e5 + 10;   int p[mx];   int main() {     int n;     cin >> n;     if (n % 4 > 1) {       puts( -1 );       return 0;     }     int l = 1, r = n;     while (l < r) {       p[l] = l + 1;       p[l + 1] = r;       p[r] = r - 1;       p[r - 1] = l;       l += 2;       r -= 2;     }     if (l == r) p[l] = l;     for (int i = 1; i <= n; i++) printf( %d  , p[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int b) {     long long int res = 1;     a %= 1000000007;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % 1000000007;       a = a * a % 1000000007;     }     return res;   }   long long int modInverse(long long int a) { return power(a, 1000000007 - 2); }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     a %= b;     return gcd(b, a);   }   const int N = 500023;   bool vis[N];   vector<int> adj[N];   void solve() {     int n;     cin >> n;     vector<long long int> a(n + 1);     for (long long int i = 0; i < n; i++) cin >> a[i + 1];     int moves = 1;     long long int by_ana = 0;     long long int by_bob = 0;     int prev_a = 1;     int prev_b = n + 1;     by_ana += a[1];     int to_comp_by_bob = a[1];     int to_comp_by_ana = 0;     int turn = 2;     int f = 0;     int eaten[n + 1];     for (int i = 1; i <= n; i++) eaten[i] = 0;     eaten[1] = 1;     while (1) {       moves++;       int temp = 0;       if (prev_a == prev_b - 1 || prev_a > n || prev_b < 1) {         moves--;         break;       }       if (turn == 2) {         while (temp <= to_comp_by_bob) {           if (prev_b == prev_a || prev_b < 1) {             f = 1;             break;           }           prev_b--;           if (eaten[prev_b] == 1) {             f = 1;             break;           }           temp += a[prev_b];           by_bob += a[prev_b];           eaten[prev_b] = 1;         }         to_comp_by_ana = temp;         turn = 1;         if (f == 1) break;       } else if (turn == 1) {         while (temp <= to_comp_by_ana) {           if (prev_b == prev_a || prev_a > n) {             f = 1;             break;           }           prev_a++;           if (eaten[prev_a] == 1) {             f = 1;             break;           }           temp += a[prev_a];           by_ana += a[prev_a];           eaten[prev_a] = 1;         }         if (f == 1) break;         to_comp_by_bob = temp;         turn = 2;       }       if (f == 1) {         if (temp == 0) moves--;         break;       }     }     if (n == 1) moves = 1;     cout << moves <<     << by_ana <<     << by_bob << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     cin >> T;     int t = 0;     while (t++ < T) {       solve();     }     cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC          <<  ms n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int pp(long long int a, long long int b) {     if (b == 0) return 1;     long long int t = pp(a, b / 2);     if (b % 2 == 0)       return t * t;     else       return t * t * a;   }   string ss(string s, long long int j) {     for (long long int i = 0; i < j; i++) {       if (s[i] ==  0 )         s[i] =  1 ;       else         s[i] =  0 ;     }     long long int l = 0, r = j - 1;     while (l < r) {       swap(s[l], s[r]);       l++;       r--;     }     return s;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int q;     cin >> q;     while (q--) {       long long int i, j, k, n, m, x, y, l, r, c = 0;       string s, s1, s2 =   ;       cin >> n;       cin >> s >> s1;       vector<long long int> v;       for (i = n - 1; i > 0; i--) {         if (s[i] == s1[i])           continue;         else {           if ((s1[i] ==  0  && s[i] ==  1  && s[0] ==  1 ) ||               (s1[i] ==  1  && s[i] ==  0  && s[0] ==  0 )) {             v.push_back(i + 1);             s = ss(s, i + 1);           } else if (s1[i] ==  0  && s[i] ==  1  && s[0] ==  0 ) {             v.push_back(1);             s[0] =  1 ;             v.push_back(i + 1);             s = ss(s, i + 1);           } else {             v.push_back(1);             s[0] =  0 ;             v.push_back(i + 1);             s = ss(s, i + 1);           }         }       }       if (s[0] != s1[0]) v.push_back(1);       cout << v.size() <<    ;       for (i = 0; i < v.size(); i++) cout << v[i] <<    ;       cout << endl;     }   }