malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 300100;   const int K = 1001000;   vector<int> v[K];   int a[N], s[N];   int l[N], r[N];   int q[N], id[N];   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     s[0] = a[0] % k;     v[0].push_back(-1);     v[s[0]].push_back(0);     for (int i = 1; i < n; i++) {       s[i] = (s[i - 1] + a[i]) % k;       v[s[i]].push_back(i);     }     int c = 0;     for (int i = 0; i < n; i++) {       while (c && a[q[c - 1]] < a[i]) c--;       l[i] = 0;       if (c) {         l[i] = q[c - 1] + 1;       }       q[c++] = i;     }     c = 0;     for (int i = n - 1; i >= 0; i--) {       while (c && a[q[c - 1]] <= a[i]) c--;       r[i] = n - 1;       if (c) {         r[i] = q[c - 1] - 1;       }       q[c++] = i;     }     long long ans = 0;     for (int i = 0; i < n; i++) {       if (i - l[i] >= r[i] - i) {         for (int j = i; j <= r[i]; j++) {           int x = (s[j] - a[i]) % k;           if (x < 0) {             x += k;           }           int ll = l[i] - 1, rr = i - 1;           if (j == i) rr = i - 2;           ans += upper_bound(v[x].begin(), v[x].end(), rr) -                  lower_bound(v[x].begin(), v[x].end(), ll);         }       } else {         for (int j = l[i]; j <= i; j++) {           int x = (a[i] + s[j - 1]) % k;           if (x < 0) {             x += k;           }           int ll = i, rr = r[i];           if (j == i) ll = i + 1;           ans += upper_bound(v[x].begin(), v[x].end(), rr) -                  lower_bound(v[x].begin(), v[x].end(), ll);         }       }     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     char ch = getchar();     x = 0;     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();   }   const int N = 1e5 + 10;   int n, a[N], s[N], c[N << 1];   inline void add(int x) {     for (; x; x -= (x & (-x))) ++c[x];   }   inline void _add(int x) {     for (; x; x -= (x & (-x))) --c[x];   }   inline int ask(int x) {     int res = 0;     for (; x <= (n << 1); x += (x & (-x))) res += c[x];     return res;   }   signed main() {     int T;     read(T);     while (T--) {       int k, ok = 0, kk = 0;       read(n), read(k);       for (int i = 1; i <= n; ++i) read(a[i]);       for (int i = 1; i <= n; ++i)         if (a[i] == k) {           kk = 1;           break;         }       if (n == 1) {         a[1] == k ? puts( yes ) : puts( no );         continue;       }       if (n == 2) {         if (a[1] == k && a[2] >= k || a[2] == k && a[1] >= k)           puts( yes );         else           puts( no );         continue;       }       for (int i = 3; i <= n; ++i) {         int c = 0;         for (int j = i - 2; j <= i; ++j) c += (a[j] >= k);         if (c >= 2) {           ok = 1;           break;         }       }       (ok && kk) ? puts( yes ) : puts( no );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1.0e-5;   const int maxn = 100000 + 10;   const int mod = 1e9 + 7;   int a, b[505], n;   int main() {     memset(b, 0, sizeof(b));     long long ans = 0;     int tmp;     scanf( %d , &n);     for (int i = 1; i <= n - 1; i++) ans = (2 * ans + 1) % mod;     for (int i = 1; i <= n; i++) {       scanf( %d , &tmp);       if (tmp >= 0) {         ans -= (long long)b[tmp] + 1;         b[tmp] = (2 * b[tmp] + 1) % mod;       }     }     printf( %lld n , (ans % mod + mod) % mod);   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 5e5 + 10;   const long long INF = 1e18;   long long n, a[maxn], po, maxx = 0, m[maxn];   int main() {     std::ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> m[i];       if (m[i] > maxx) {         maxx = m[i];         po = i;       }     }     long long ans, maxx = 0;     for (int po = 1; po <= n; po++) {       long long sum = 0;       a[po] = m[po];       sum += a[po];       for (int i = po - 1; i >= 1; i--) {         a[i] = min(m[i], a[i + 1]);         sum += a[i];       }       for (int i = po + 1; i <= n; i++) {         a[i] = min(m[i], a[i - 1]);         sum += a[i];       }       if (sum > maxx) {         maxx = sum;         ans = po;       }     }     long long po = ans;     a[po] = m[po];     for (int i = po - 1; i >= 1; i--) {       a[i] = min(m[i], a[i + 1]);     }     for (int i = po + 1; i <= n; i++) {       a[i] = min(m[i], a[i - 1]);     }     for (int i = 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     scanf( %d%d%d%d , &a, &b, &c, &d);     int a1 = abs(a - c) * 2;     int b1 = abs(b - d) * 2;     int ans = a1 + b1 + 4;     if (a != c && b != d)       printf( %d n , ans);     else       printf( %d n , ans + 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, a, b;   long long mini = (long long)1e15;   long long maxi = 0;   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   void calc(long long l) {     if (l <= 0 || l > n * k) return;     long long tmp = n * k / gcd(n * k, l);     mini = min(tmp, mini);     maxi = max(tmp, maxi);   }   int main() {     cin >> n >> k >> a >> b;     for (int i = -2; i <= n; ++i) {       calc(k * i + b - a);       calc(k * i - b - a);       calc(k * i + b + a);       calc(k * i - b + a);     }     cout << mini <<     << maxi << endl;   }
#include <bits/stdc++.h>   int main() {     int n, m;     scanf( %d%d , &n, &m);     std::vector<std::vector<int>> graph(n);     for (int i = 0; i < m; ++i) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       graph.at(a).push_back(b);       graph.at(b).push_back(a);     }     std::vector<int> color(n, -1);     bool ok = true;     for (int s = 0; s < n && ok; ++s) {       if (!~color[s]) {         std::vector<int> queue;         queue.push_back(s);         color[s] = 0;         for (int h = 0; h < static_cast<int>(queue.size()); ++h) {           auto u = queue[h];           for (int v : graph.at(u)) {             if (!~color[v]) {               color[v] = color[u] ^ 1;               queue.push_back(v);             }             ok &= color[u] != color[v];           }         }       }     }     if (ok) {       std::vector<std::vector<int>> result(2);       for (int i = 0; i < n; ++i) {         result[color[i]].push_back(i);       }       for (int i = 0; i < 2; ++i) {         printf( %d n , static_cast<int>(result[i].size()));         for (auto&& v : result[i]) {           printf( %d  , v + 1);         }         puts(  );       }     } else {       puts( -1 );     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int main() {     int n, l[300], c[300];     cin >> n;     for (int i = 0; i < n; i++) cin >> l[i];     for (int i = 0; i < n; i++) cin >> c[i];     unordered_map<int, int> um;     for (int i = 0; i < n; i++)       if (um.find(l[i]) != um.end())         um[l[i]] = min(um[l[i]], c[i]);       else         um.emplace(l[i], c[i]);     for (int i = 0; i < n; i++) {       vector<pair<int, int>> ve;       for (auto& elem : um) {         int g = gcd(elem.first, l[i]);         if (um.find(g) != um.end())           um[g] = min(um[g], elem.second + c[i]);         else           ve.emplace_back(g, elem.second + c[i]);       }       for (auto& elem : ve) um.insert(elem);     }     cout << (um[1] ?: -1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct B {     int p, id;   };   priority_queue<B> q;   bool operator<(const B &a, const B &b) { return a.p < b.p; }   int main() {     string s;     long long a, b, l, len, cost, i;     B tmp;     cin >> s;     l = 0;     len = s.size();     cost = 0;     for (i = 0; i < len; i++) {       if (s[i] ==  ( )         l++;       else if (s[i] ==  ) )         l--;       else {         cin >> a >> b;         tmp.p = b - a;         tmp.id = i;         q.push(tmp);         s[i] =  ) ;         l--;         cost += b;       }       if (l < 0) {         if (q.empty()) break;         tmp = q.top();         q.pop();         cost -= tmp.p;         s[tmp.id] =  ( ;         l += 2;       }     }     if (l != 0)       cout << -1 << endl;     else {       cout << cost << endl;       cout << s << endl;     }     while (!q.empty()) q.pop();   }
#include <bits/stdc++.h>   using namespace std;   struct p {     int x;     int i;   } a[200123];   int cmp(p a, p b) {     if (a.x != b.x)       return a.x < b.x;     else       return a.i < b.i;   }   int main() {     int n;     int i, j;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i].x);       a[i].i = i;     }     sort(a, a + n, cmp);     int mi = 0;     long long y = 0;     i = 1;     while (i < n && a[i].x == a[0].x) {       if (a[i].i - a[i - 1].i - 1 > mi) mi = a[i].i - a[i - 1].i - 1;       i++;     }     if (a[0].i + n - a[i - 1].i - 1 > mi) mi = a[0].i + n - a[i - 1].i - 1;     y = (long long)a[0].x * n + mi;     printf( %lld n , y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000000;   const double pi = 2 * acos(0.0);   const int MOD = 1000000007;   vector<int> g[5];   int id[222][222], k[222];   bool ok[222];   int wh[222];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> wh[i];       g[wh[i]].push_back(i);     }     for (int i = 1; i <= n; ++i) {       cin >> k[i];       for (int j = 1; j <= k[i]; ++j) cin >> id[i][j];     }     int res = inf;     for (int ST = 1; ST <= 3; ++ST) {       int st = ST;       memset(ok, false, sizeof(ok));       int cnt = 0, ans = 0;       for (;;) {         if (cnt == n) break;         for (;;) {           bool doing = false;           for (int c = 0; c <= (int)g[st].size() - 1; ++c) {             int work = g[st][c];             if (ok[work]) continue;             bool is = true;             for (int i = 1; i <= k[work]; ++i)               if (!ok[id[work][i]]) is = false;             if (is) {               doing = true;               ++ans;               ok[work] = true;               ++cnt;             }           }           if (!doing) break;         }         if (cnt == n) break;         ++ans;         st++;         if (st == 4) st = 1;       }       res = min(res, ans);     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     int i = 1;     while (true) {       int cnt = i / 2 + 1;       if (cnt == a) {         break;       }       ++i;     }     cout << i <<     << 2 << endl;     cout <<  1 2 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   const long long INF = 1e18;   const double eps = 1e-10;   mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());   template <class T>   inline void upmin(T &x, T y) {     x = x > y ? y : x;   }   template <class T>   inline void upmax(T &x, T y) {     x = x < y ? y : x;   }   const int maxn = 1e5 + 233;   vector<int> G[maxn];   int n;   int col[maxn];   int fa[maxn];   int cnt[maxn];   void dfs(int u, int f) {     for (auto v : G[u]) {       if (v == f) continue;       col[v] = 3 - col[u];       fa[v] = u;       dfs(v, u);     }   }   int deg[maxn];   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cout << fixed << setprecision(10);     cin >> n;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       G[u].emplace_back(v);       G[v].emplace_back(u);       deg[u]++;       deg[v]++;     }     for (int i = 1; i <= n; i++) {       if (deg[i] > 1) {         col[i] = 1;         dfs(i, 0);         break;       }     }     int f1 = 0, f2 = 0;     for (int i = 1; i <= n; i++) {       if (deg[i] == 1) {         if (col[i] == 1)           f1 = 1;         else           f2 = 1;         cnt[fa[i]]++;       }     }     int mn, mx;     if (f1 && f2)       mn = 3;     else       mn = 1;     mx = n - 1;     for (int i = 1; i <= n; i++) {       if (cnt[i]) mx -= cnt[i] - 1;     }     cout << mn <<     << mx <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   stack<pair<long long, long long> > q;   long long n, a[N], go[N];   struct cell {     long long max_l, max_r, or_l, or_r;   };   bool d[N][35];   cell b[N];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = 1; i <= n; i++) {       long long q = a[i], k = 1;       while (q != 0) {         d[i][k] = q % 2;         q /= 2;         k++;       }     }     q.push({0, 2e9});     for (long long i = 1; i <= n; i++) {       while (q.top().second <= a[i]) q.pop();       b[i].max_l = q.top().first;       q.push({i, a[i]});     }     while (!q.empty()) q.pop();     q.push({n + 1, 2e9});     for (long long i = n; i > 0; i--) {       while (q.top().second < a[i]) q.pop();       b[i].max_r = q.top().first;       q.push({i, a[i]});     }     while (!q.empty()) q.pop();     for (long long i = 1; i <= n; i++) {       long long k = 0;       for (long long j = 1; j < 35; j++)         if (d[i][j] == 0)           k = max(k, go[j]);         else           go[j] = i;       b[i].or_l = k;     }     for (long long i = 1; i < 35; i++) go[i] = n + 1;     for (long long i = n; i > 0; i--) {       long long k = n + 1;       for (long long j = 1; j < 35; j++)         if (d[i][j] == 0)           k = min(k, go[j]);         else           go[j] = i;       b[i].or_r = k;     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       if (b[i].max_l >= b[i].or_l)         if (b[i].max_r <= b[i].or_r)           continue;         else           ans += (i - b[i].max_l) * (b[i].max_r - b[i].or_r);       else if (b[i].max_r <= b[i].or_r)         ans += (b[i].or_l - b[i].max_l) * (b[i].max_r - i);       else {         ans += (b[i].or_l - b[i].max_l) * (b[i].or_r - i);         ans += (b[i].max_r - b[i].or_r) * (i - b[i].or_l);         ans += (b[i].or_l - b[i].max_l) * (b[i].max_r - b[i].or_r);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> ev[1000099];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> p(n), pos(n);     for (int(i) = (0); (i) < (int)(n); ++(i)) {       cin >> p[i];       p[i]--;       pos[p[i]] = i;       ev[n - i].push_back(p[i]);       int k = (p[i] - i + n) % n;       if (k != n - i) ev[k].push_back(p[i]);     }     long long sm = 0;     int x = 0, y = 0;     vector<int> state(n);     for (int(i) = (0); (i) < (int)(n); ++(i)) {       if (i < p[i])         x++, state[p[i]] = -1;       else         y++, state[p[i]] = 1;       sm += abs(i - p[i]);     }     long long mi = LLONG_MAX;     int ans = -1;     for (int(i) = (0); (i) < (int)(n); ++(i)) {       if (i > 0) {         for (auto &(num) : (ev[i])) {           int nextPos = (pos[num] + i) % n;           int prePos = (pos[num] + i - 1) % n;           int nextState = nextPos < num ? -1 : 1;           sm += abs(nextPos - num) - abs(prePos - num);           if (state[num] == -1 && nextState == 1) {             sm--;             x--;             y++;             state[num] = 1;           } else if (state[num] == 1 && nextState == -1) {             sm++;             x++;             y--;             state[num] = -1;           } else if (state[num] == nextState) {             if (state[num] == 1)               sm--;             else               sm++;           }         }         sm -= x;         sm += y;       }       if (sm < mi) {         ans = i;         mi = sm;       }     }     cout << mi <<     << ans << endl;   }
#include <bits/stdc++.h>   int main() {     int a, b, c, d, p1, p2, p3, p4;     scanf( %d %d %d %d , &a, &b, &c, &d);     p1 = ((3 * a / 10));     p2 = (a - (a * c / 250));     if (p1 > p2) {       p1 = p1;     } else if (p2 > p1) {       p1 = p2;     } else if (p2 == p1) {       p1 = p1;     }     p3 = ((3 * b / 10));     p4 = (b - (b * d / 250));     if (p3 > p4) {       p3 = p3;     } else if (p4 > p3) {       p3 = p4;     } else if (p3 == p4) {       p3 = p3;     }     if (p1 > p3) {       printf( Misha n );     } else if (p3 > p1) {       printf( Vasya n );     } else if (p1 == p3) {       printf( Tie n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int numOfComparisons, HomeUniform, GuestUniform, count = 0;     cin >> numOfComparisons;     int *Home = new int[numOfComparisons];     int *Guest = new int[numOfComparisons];     for (int i = 0; i < numOfComparisons; i++) {       cin >> Home[i] >> Guest[i];     }     for (int i = 0; i < numOfComparisons; i++) {       for (int j = 0; j < numOfComparisons; j++) {         if (Home[i] == Guest[j]) count++;       }     }     cout << count;     return 0;   }
// Author : Mc_LaReN      #include <bits/stdc++.h>   #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)   using namespace std;   const int MOD = 1e9 + 7, MX = 400005;      #define DEBUG       cerr<< /n>>>I m Here<<</n <<endl;   #define what_is(x) cerr << #x <<   is   << x << endl;   #define pf push_front   #define pb push_back   #define endl   n    #define ll int64_t   #define sz(x) (int)x.size()   #define max(x, y) (y-x >> 31 & (x^y) ^ y)   #define min(x, y) (y-x >> 31 & (x^y) ^ x)      template <class X> void swp( X &a, X &b) { X tp = a; a = b; b = tp; }   template <class X> void print(vector<X> &a) {for(auto& it : a) cout<<it<<   ; cout<<endl;}      ll gcd(ll x,ll y){       return (y==0 ? x : gcd(y, x % y) );   }   ll LCM(ll x,ll y){       return (x/gcd(x,y))*y;   }      char ch,ch1,ch2,ch3;   string s,s1,s2,s3;   vector<long long> v,v1,v2,v3;   vector<int> vi;   vector<string> vstr,vstr2,vstr3;      void run();      int32_t main()   {       IOS;              #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       freopen( error.txt ,  w , stderr);       freopen( output.txt ,  w , stdout);       #endif          int t;       cin >> t;       while(t--)       {           run();           cout <<   n ;       }                    #ifndef ONLINE_JUDGE       cerr<< time taken :  <<(float)clock()/CLOCKS_PER_SEC<<  secs <<endl;       #endif             return 0;   }         void run()   {       ll n;       cin>>n;       ll a=1, ans = 0;       for(ll i = 1; i <= n; ++i){       //     ans+=n/a;       //     // a=LCM(a,i);           a=LCM(a,i);           if(a>n)break;           ans+=n/a;       }       cout<< (ans+n) % MOD;   }
#include <bits/stdc++.h>   using namespace std;   long long int a[200];   int main() {     long long int n, ans = 0, m, i, j, x, y;     cin >> n >> m;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= m; i++) {       cin >> x >> y;       long long int ret = 0;       for (j = x; j <= y; j++) {         ret += a[j];       }       if (ret > 0) ans += ret;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long a, b, c, d;       long long ar[6];       cin >> a >> b >> c;       ar[0] = a;       ar[1] = b;       ar[2] = c;       sort(ar, ar + 3);       cout << ar[2] + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   bool mark[72][72][72];   int a[10];   pair<int, pair<int, int> > Par[72][72][72];   pair<int, int> par[72][72][72];   queue<pair<int, pair<int, int> > > q;   vector<pair<int, int> > v;   char c[100][100];   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     cin >> a[3] >> a[1] >> a[2];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) cin >> c[i][j];     sort(a + 1, a + 3 + 1);     if (a[1] == 1 && a[2] == 2 && a[3] == 3) {       cout << 0;       return 0;     }     bool ans = false;     mark[a[1]][a[2]][a[3]] = true;     q.push(make_pair(a[1], make_pair(a[2], a[3])));     while (q.size()) {       int A = q.front().first;       int B = q.front().second.first;       int C = q.front().second.second;       if (A == 1 && B == 2 && C == 3) {         ans = true;         while (par[A][B][C].first != 0) {           v.push_back(par[A][B][C]);           int AA = A, BB = B, CC = C;           A = Par[AA][BB][CC].first;           B = Par[AA][BB][CC].second.first;           C = Par[AA][BB][CC].second.second;         }       }       for (int i = 1; i <= n; i++) {         if (i != A && i != B && i != C) {           if (c[A][i] == c[B][C]) {             a[1] = i;             a[2] = B;             a[3] = C;             sort(a + 1, a + 3 + 1);             if (!mark[a[1]][a[2]][a[3]]) {               par[a[1]][a[2]][a[3]] = make_pair(A, i);               Par[a[1]][a[2]][a[3]] = make_pair(A, make_pair(B, C));               mark[a[1]][a[2]][a[3]] = true;               q.push(make_pair(a[1], make_pair(a[2], a[3])));             }           }         }       }       for (int i = 1; i <= n; i++) {         if (i != A && i != B && i != C) {           if (c[B][i] == c[A][C]) {             a[1] = A;             a[2] = i;             a[3] = C;             sort(a + 1, a + 3 + 1);             if (!mark[a[1]][a[2]][a[3]]) {               par[a[1]][a[2]][a[3]] = make_pair(B, i);               Par[a[1]][a[2]][a[3]] = make_pair(A, make_pair(B, C));               mark[a[1]][a[2]][a[3]] = true;               q.push(make_pair(a[1], make_pair(a[2], a[3])));             }           }         }       }       for (int i = 1; i <= n; i++) {         if (i != A && i != B && i != C) {           if (c[C][i] == c[B][A]) {             a[1] = A;             a[2] = B;             a[3] = i;             sort(a + 1, a + 3 + 1);             if (!mark[a[1]][a[2]][a[3]]) {               par[a[1]][a[2]][a[3]] = make_pair(C, i);               Par[a[1]][a[2]][a[3]] = make_pair(A, make_pair(B, C));               mark[a[1]][a[2]][a[3]] = true;               q.push(make_pair(a[1], make_pair(a[2], a[3])));             }           }         }       }       q.pop();     }     if (!ans) {       cout << -1;       return 0;     }     cout << v.size() << endl;     for (int i = v.size() - 1; i >= 0; i--)       cout << v[i].first <<     << v[i].second << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, p;   bool prime(int num) {     for (int i = 2; i <= sqrt(num); i++) {       if (num % i == 0) return 0;     }     return 1;   }   int main() {     cin >> n;     if (prime(n)) {       return cout << 1 << endl << n, 0;     }     p = (n - 3) / 2;     cout << 3 <<   n  << 3 <<    ;     for (int i = 0; i < p; i++) {       if (prime(p - i) && prime(p + i)) {         cout << p - i <<     << p + i;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void my_functions() { return; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     string s;     cin >> s;     long long int b[n], i;     b[0] = a[0];     for (i = 1; i < n; i++) {       b[i] = a[i] + b[i - 1];     }     long long int m1 = 0, m2 = 0;     for (i = 0; i < n; i++) {       if (s[i] ==  1 ) {         m1 = a[i] + m1;         if (i > 0) {           m2 = b[i - 1];         }         m1 = max(m1, m2);       }     }     long long int ans = max(m1, m2);     cout << ans;     return 0;   }