malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   ifstream in( in.txt );   bool needToDelete(char c) {     return tolower(c) ==  a  || tolower(c) ==  o  || tolower(c) ==  y  ||            tolower(c) ==  e  || tolower(c) ==  u  || tolower(c) ==  i ;   }   int main(int argc, char** argv) {     string s;     cin >> s;     string ans;     for (int i = 0; i < s.size(); i++) {       if (!needToDelete(s[i])) {         ans +=  . ;         ans += tolower(s[i]);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> getPrimes(int n) {     vector<bool> sieve(n + 1, true);     sieve[0] = sieve[1] = false;     for (int i = 2; i * i <= n; i++)       if (sieve[i])         for (int j = i * i; j <= n; j += i) sieve[j] = false;     vector<int> primes;     for (int i = 2; i <= n; i++)       if (sieve[i]) primes.push_back(i);     return primes;   }   void storePrimes(int n, unordered_map<int, int> &m, vector<int> &primes) {     for (int p : primes) {       if (p * p > n) break;       while (n % p == 0) {         m[p]++;         n /= p;       }       if (n == 1) break;     }     if (n > 1) m[n]++;   }   void removePrimes(int n, unordered_map<int, int> &m, vector<int> &primes) {     for (int p : primes) {       if (p * p > n) break;       while (n % p == 0) {         m[p]--;         n /= p;       }       if (n == 1) break;     }     if (n > 1) m[n]--;   }   bool isAtleast(unordered_map<int, int> &m1, unordered_map<int, int> &m2) {     for (auto it = m2.begin(); it != m2.end(); it++) {       int num = it->first, freq = it->second;       if (m1.find(num) == m1.end() or m1[num] < freq) return false;     }     return true;   }   void printMap(unordered_map<int, int> &m) {     for (auto it = m.begin(); it != m.end(); it++)       cout << it->first <<  :   << it->second <<   n ;   }   long long int solve(int arr[], int n, int k) {     vector<int> primes = getPrimes(1000003);     unordered_map<int, int> mapK, currMap;     storePrimes(k, mapK, primes);     int i = 0, j = 0;     long long int count = 0;     while (j < n) {       storePrimes(arr[j], currMap, primes);       if (isAtleast(currMap, mapK)) {         while (i <= j and isAtleast(currMap, mapK)) {           count += (n - j);           removePrimes(arr[i], currMap, primes);           i++;         }       }       j++;     }     return count;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k;     cin >> n >> k;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     long long int ans = solve(arr, n, k);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, q, p, p1, maxi, a[1000000], idx;   stack<int> t, t1, id;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     maxi = -1;     id.push(0);     t.push(200000);     t1.push(-1);     for (int i = 1; i < n; i++) {       p = 0;       q = 5;       while (q == 5) {         idx = id.top();         p1 = t.top();         p = t1.top() + 1;         if (a[idx] > a[i] && p <= p1) {           q = 6;           t1.top() = p;           if (p > maxi) maxi = p;           id.push(i);           t.push(p);           t1.push(-1);         } else if (p1 == 200000) {           q = 7;           id.push(i);           t.push(200000);           t1.push(-1);         } else {           id.pop();           t.pop();           t1.pop();         }       }     }     printf( %d , maxi + 1);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int i, n, m;     cin >> n >> m;     vector<int> a(n + m);     for (i = 0; i < n + m; i++) {       cin >> a[i];     }     set<int> tax, per;     for (i = 0; i < n + m; i++) {       int t;       cin >> t;       if (t == 0) {         per.insert(a[i]);       } else {         tax.insert(a[i]);       }     }     map<int, int> ans;     for (auto cur : per) {       auto right = tax.upper_bound(cur);       auto left = --tax.upper_bound(cur);       if (left == tax.end()) {         ans[*right]++;       } else if (right == tax.end()) {         ans[*left]++;       } else {         int l = *left, r = *right;         if (cur - l <= r - cur) {           ans[l]++;         } else {           ans[r]++;         }       }     }     for (auto cur : tax) {       cout << ans[cur] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   auto fio = (ios::sync_with_stdio(0), cin.tie(0), cout.tie(0));   int32_t main() {     long long n;     cin >> n;     vector<long long> g(n);     for (long long& x : g) cin >> x;     vector<vector<long long>> idx(8192);     for (long long i = 0; i < n; i++) idx[g[i]].push_back(i);     vector<long long> mn(8192, n);     mn[0] = -1;     for (long long i = 0; i <= 5000; i++) {       if (idx[i].empty()) continue;       for (long long j = 0; j < 8192; j++) {         if (mn[j] <= mn[i ^ j] || mn[i ^ j] >= idx[i].back()) continue;         auto it = upper_bound(idx[i].begin(), idx[i].end(), mn[i ^ j]);         if (it != idx[i].end() && *it < mn[j]) mn[j] = *it;       }     }     cout << 8192 - count(mn.begin(), mn.end(), n) << endl;     for (long long i = 0; i < 8192; i++)       if (mn[i] != n) cout << i <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct _ {     _() { ios_base::sync_with_stdio(0); }   } _;   template <class T>   void PV(T a, T b) {     while (a != b) cout << *a++, cout << (a != b ?     :   n );   }   template <class T>   inline bool chmin(T &a, T b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   inline bool chmax(T &a, T b) {     return a < b ? a = b, 1 : 0;   }   const int inf = 0x3f3f3f3f;   const int mod = int(1e9) + 7;   const int N = 3 * 111111;   int n, q;   int d[N];   int p[N];   int v[N];   void add(int first, int t) {     if (first == 0) return;     while (first <= n) {       v[first] += t;       first += first & (first ^ (first - 1));     }   }   int sum(int first) {     int r = 0;     while (first > 0) {       r += v[first];       first -= first & (first ^ (first - 1));     }     return r;   }   int main() {     cin >> n;     p[0] = 0, p[n + 1] = n + 1;     for (int i = 1; i <= n; i++) cin >> d[i], p[d[i]] = i;     for (int i = 1; i <= n; i++)       if (p[d[i] - 1] > i) add(d[i], 1);     cin >> q;     while (q--) {       int op, l, r, t;       cin >> op >> l >> r;       if (op == 1) {         cout << sum(r) - sum(l) + 1 << endl;       } else {         if (d[l] > d[r]) {           t = p[d[r] - 1];           if (l < t && t < r) add(d[r], 1);           t = p[d[r] + 1];           if (l < t && t < r) add(d[r] + 1, -1);           t = p[d[l] + 1];           if (l < t && t < r) add(d[l] + 1, 1);           t = p[d[l] - 1];           if (l < t && t < r) add(d[l], -1);           if (d[l] == d[r] + 1) add(d[l], -1);         } else if (d[l] < d[r]) {           t = p[d[l] - 1];           if (l < t && t < r) add(d[l], -1);           t = p[d[l] + 1];           if (l < t && t < r) add(d[l] + 1, 1);           t = p[d[r] + 1];           if (l < t && t < r) add(d[r] + 1, -1);           t = p[d[r] - 1];           if (l < t && t < r) add(d[r], 1);           if (d[l] == d[r] - 1) add(d[r], 1);         }         swap(d[l], d[r]);         p[d[l]] = l, p[d[r]] = r;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( popcnt )   using namespace std;   mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());   const long long N = 2e5 + 100;   const long long mod = 1e9 + 7;   const long long big = 1e17;   long long t, n, h;   long long a[N];   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> t;     while (t--) {       cin >> n >> h;       for (int i = 1; i <= n; i++) cin >> a[i];       sort(a + 1, a + n + 1);       long long l = 1, r = 1e18, ans = h;       while (l <= r) {         long long m = (l + r) >> 1ll;         long long sum = 0, rtst = 0;         for (int i = 1; i <= n; i++) {           long long l = max(a[i] - 1ll, rtst), r = a[i] + m - 1;           sum = sum + (r - l);           rtst = r;         }         if (sum >= h)           r = m - 1ll, ans = m;         else           l = m + 1ll;       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k = -1, c, d;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d %d , &c, &d);       if (k == -1 || (d - c + 1) < k) {         k = d - c + 1;       }     }     printf( %d n , k);     c = 0;     for (i = 1; i <= n; i++) {       printf( %d  , c);       c = (c + 1) % k;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long xa, ya, xb, yb, xc, yc;     cin >> xa >> ya >> xb >> yb >> xc >> yc;     long long s1 = (ya - yb) * (xa - xc);     long long s2 = (xa - xb) * (ya - yc);     if (s1 == s2) {       cout <<  TOWARDS ;       return 0;     }     if (s1 > s2)       cout <<  RIGHT ;     else       cout <<  LEFT ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int big = 0, small = 1000000000;     int a[1000];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] > big) {         big = a[i];       }       if (a[i] < small) {         small = a[i];       }     }     cout << big - small + 1 - n;   }
#include <bits/stdc++.h>   using namespace std;   int a, ta, b, tb, hh, mm, res1, res2;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> a >> ta >> b >> tb;     char tmp;     cin >> hh >> tmp >> mm;     hh -= 5;     mm += hh * 60;     if (mm - tb >= 0) res1 = (mm - tb) / b + 1;     mm += ta;     mm = min(mm, (24 - 5) * 60);     mm--;     res2 = mm / b + 1;     cout << res2 - res1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     string K;     cin >> K;     if (K.size() == 1 and k != 0) {       cout << 0;       return 0;     }     if (k == 0) {       cout << K;       return 0;     }     if (K[0] !=  1 ) {       K[0] =  1 ;       k -= 1;       for (int i = 1; i < n; ++i) {         if (k == 0) {           cout << K;           return 0;         }         if (K[i] !=  0 ) {           K[i] =  0 ;           k--;         }       }     } else {       for (int i = 1; i < n; ++i) {         if (k == 0) {           cout << K;           return 0;         }         if (K[i] !=  0 ) {           K[i] =  0 ;           k--;         }       }     }     cout << K;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, p, a[100000], sum = 0;     cin >> n >> p;     for (int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];       sum %= p;     }     sum = (sum + p - (a[0] % p)) % p;     int cur = a[0] % p, ans = cur + sum;     for (int i = 1; i < n - 1; ++i) {       cur = (cur + a[i]) % p, sum = (sum + p - (a[i] % p)) % p;       ans = max(ans, cur + sum);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, c, i, j, flag = 0;     cin >> r >> c;     char a1[r][c];     for (i = 0; i < r; i++) {       for (j = 0; j < c; j++) {         cin >> a1[i][j];       }     }     for (i = 0; i < r; i++) {       for (j = 0; j < c; j++) {         if (a1[i][j] ==  . ) {           a1[i][j] =  D ;         }       }     }     for (i = 0; i < r; i++) {       for (j = 0; j < c; j++) {         if (a1[i][j] ==  S ) {           if (i > 0) {             if (a1[i - 1][j] ==  W ) {               cout <<  No ;               return 0;             }           }           if (i < r - 1) {             if (a1[i + 1][j] ==  W ) {               cout <<  No ;               return 0;             }           }           if (j > 0) {             if (a1[i][j - 1] ==  W ) {               cout <<  No ;               return 0;             }           }           if (j < c - 1) {             if (a1[i][j + 1] ==  W ) {               cout <<  No ;               return 0;             }           }         }       }     }     cout <<  Yes  << endl;     for (i = 0; i < r; i++) {       for (j = 0; j < c; j++) {         cout << a1[i][j];       }       cout << endl;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   long long w, m, k;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());     cin >> w >> m >> k;     long long aa = 0;     int nc = 0;     while (aa < m) aa = aa * 10 + 9, ++nc;     long long m2 = m;     while (w) {       if ((aa - m + 1) <= w / k / nc) {         w = w - k * (aa - m + 1) * nc;         ++nc;         m = aa + 1;         aa = aa * 10 + 9;       } else {         m = m + w / k / nc;         break;       }     }     cout << m - m2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x;   vector<int> w;   vector<int> v;   bool volt[1111];   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> x;       v.push_back(x);     }     reverse(v.begin(), v.end());     for (int i = 0; i < v.size(); i++) {       if (volt[v[i]] == false) {         w.push_back(v[i]);         volt[v[i]] = true;       }     }     reverse(w.begin(), w.end());     cout << w.size() << endl;     for (int i = 0; i < w.size(); i++) {       cout << w[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2005;   int n, m;   int a[maxn];   int cnt[maxn], vis[maxn];   int ans2 = 0;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int ans1 = n / m;     int p = n % m;     for (int i = 1; i <= n; i++) {       if (a[i] > m) continue;       if (cnt[a[i]] >= ans1) continue;       cnt[a[i]]++;       vis[i] = 1;     }     for (int i = 1; i <= n; i++) {       if (vis[i]) continue;       int Ans1 = 1e9, Ans2 = 1e9;       for (int j = 1; j <= m; j++) {         if (cnt[j] < Ans2) Ans2 = cnt[j], Ans1 = j;       }       if (Ans2 == ans1) continue;       ans2++;       cnt[Ans1]++, a[i] = Ans1;     }     cout << ans1 <<     << ans2 << endl;     for (int i = 1; i <= n; i++) cout << a[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i = 0, j = 0, cs = 0, in;     int n;     cin >> n;     vector<int> v;     int sum = 0, s = 0;     for (int i = 1; i < n; i++) {       cout <<  ?   << i <<     << n <<   n ;       int x;       cin >> x;       if (i > 1) {         v.push_back(sum - x - s);         s += v.back();       } else         sum = x;     }     cout <<  ?   << 1 <<     << n - 1 <<   n ;     int x;     cin >> x;     cout <<  !  ;     for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout << x - s <<     << sum - x <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5;   int N, M, A[MAXN + 10], ans[MAXN + 10];   int main() {     int i, j;     scanf( %d%d , &N, &M);     long long sum = 0;     for (i = 1; i <= M; i++) scanf( %d , &A[i]), sum += A[i];     if (sum < N) return !printf( -1 );     int last = 987654321;     for (i = M; i >= 1; i--) {       int t = min(N - A[i] + 1, last - 1);       if (t <= 0) return !printf( -1 );       ans[i] = t;       last = t;     }     int start = 1;     for (i = 1; i <= M; i++) {       if (start >= ans[i]) break;       ans[i] = start;       start = A[i] + ans[i];     }     for (i = 1; i <= M; i++) printf( %d  , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int n;   double p[100008];   struct Tprogram {     void open() {       freopen( 1.in ,  r , stdin);       freopen( 1.out ,  w , stdout);     }     void close() {}     void init() {       scanf( %d , &n);       for (int i = 0; i <= n; i++) scanf( %lf , &p[i]);     }     void work() {       double ans = 0;       for (int i = 0; i <= n >> 1; i++)         for (int j = (n >> 1) + 1; j <= n; j++)           ans = ((p[i] * (2 * j - n) + p[j] * (n - 2 * i)) / (2 * j - 2 * i) > ans                      ? (p[i] * (2 * j - n) + p[j] * (n - 2 * i)) / (2 * j - 2 * i)                      : ans);       printf( %.10lf n , ans);     }   } Program;   int main() {     Program.init();     Program.work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int m;     cin >> n >> m;     vector<int> zahlen(n);     for (int i = 0; i < n; i++) cin >> zahlen[i];     for (int i = 0; i < m; i++) {       int l, r, x;       cin >> l >> r >> x;       l--;       x--;       r--;       int tr = zahlen[x];       int count = 0;       for (int i = l; i <= r; i++) {         if (zahlen[i] < tr) count++;       }       if ((l + count) == x)         cout <<  Yes  << endl;       else         cout <<  No  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ii = pair<int, int>;   using vi = vector<int>;   using vll = vector<ll>;   using vii = vector<ii>;   const ll MOD = 998244353;   const ll INF = 1e15 + 9;   const int MAXN = 1000006;   int n, m, a[MAXN], p[MAXN], b[MAXN];   int rev[MAXN];   vi pos[MAXN];   vll sum[MAXN];   ll dp[MAXN], negsum[MAXN];   inline ll isum(int val, int R) {     int index =         lower_bound(pos[val].begin(), pos[val].end(), R) - pos[val].begin();     return sum[val][index];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     for (int i = 1; i <= n; ++i) {       cin >> p[i];     }     cin >> m;     for (int i = 1; i <= m; ++i) {       cin >> b[i];     }     a[n + 1] = n + 1;     b[m + 1] = n + 1;     ++n, ++m;     for (int i = 0; i <= m; ++i) {       sum[2 * i + 1] = sum[2 * i] = vll(1);     }     for (int i = 0; i <= n; ++i) {       int bi = lower_bound(b, b + m, a[i]) - b;       a[i] = 2 * bi - (b[bi] != a[i]);       pos[a[i]].push_back(i);       ll prevsum = sum[a[i]].back();       sum[a[i]].push_back(prevsum + max(p[i], 0));       negsum[i + 1] = negsum[i] + min(p[i], 0);     }     for (int i = 1; i <= n; ++i) {       if (a[i] & 1) {         dp[i] = INF;         continue;       }       auto it = lower_bound(pos[a[i] - 2].begin(), pos[a[i] - 2].end(), i);       if (it == pos[a[i] - 2].begin()) {         dp[i] = INF;         continue;       }       --it;       dp[i] = dp[*it] + isum(a[i] - 1, i) + isum(a[i], i) + negsum[i] -               negsum[*it + 1];       it = lower_bound(pos[a[i]].begin(), pos[a[i]].end(), i);       if (it != pos[a[i]].begin()) {         --it;         dp[i] = min(dp[i], dp[*it] + negsum[i + 1] - negsum[*it + 1]);       }     }     if (dp[n] >= INF / 2) {       cout <<  NO n ;     } else {       cout <<  YES n  << dp[n] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, a, b, ans;   vector<long long> v[100005];   vector<long long> res;   long long cost(long long num) {     res.clear();     long long sum = 0;     long long need = num - v[0].size();     for (long long i = 1; i <= 100000; i++) {       for (long long j = 0; j < v[i].size(); j++) {         if (v[i].size() - j >= num) {           need--;           sum += v[i][j];         } else           res.push_back(v[i][j]);       }     }     sort(res.begin(), res.end());     for (long long i = 1; i <= need; i++) {       sum += res[i - 1];     }     return sum;   }   int main() {     scanf( %lld , &n);     for (long long i = 1; i <= n; i++) {       scanf( %lld%lld , &a, &b);       v[a].push_back(b);     }     for (long long i = 1; i <= 100000; i++) sort(v[i].begin(), v[i].end());     long long l = v[0].size(), r = n, m1, m2;     ans = min(cost(l), cost(r));     while (l + 2 < r) {       m1 = l + (r - l) / 3;       m2 = r - (r - l) / 3;       long long a1 = cost(m1);       long long a2 = cost(m2);       if (a1 > a2)         l = m1, ans = min(ans, a2);       else         r = m2, ans = min(ans, a1);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Container>   void print(Container& container) {     auto Start = container.begin(), End = container.end();     while (Start != End) cout << *(Start++) <<    ;     cout <<   n ;   }   const int N = 5e2 + 1;   int dp[2][N][N], a[N];   inline void solve() {     int n, m, b, mod;     cin >> n >> m >> b >> mod;     for (int i = 1; i <= n; ++i) cin >> a[i];     dp[0][0][0] = 1;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= m; ++j) {         for (int k = 0; k <= b; ++k) {           dp[i & 1][j][k] = dp[i & 1 ^ 1][j][k];           if (j && k >= a[i]) dp[i & 1][j][k] += dp[i & 1][j - 1][k - a[i]];           dp[i & 1][j][k] %= mod;         }       }     }     int ans = 0;     for (int k = 0; k <= b; ++k) ans = (ans + dp[n & 1][m][k]) % mod;     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int T = 1;     while (T--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     getline(cin, s1);     getline(cin, s2);     sort(s1.begin(), s1.end());     sort(s2.begin(), s2.end());     int j(0);     for (int i = 0; i < s1.size(); i++) {       while (s2[j] ==    ) j++;       while (s1[i] ==    ) i++;       if (s1[i] == s2[j]) j++;       if (j == s2.size()) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<int> list;       int maxx, ma;       for (int i = 0; i < n; i++) {         int u;         cin >> u;         list.push_back(u);       }       int u1, u2, u3;       int flag;       for (int i = 1; i < n - 1; i++) {         flag = 0;         for (int j = 0; j < i; j++) {           if (list[i] > list[j]) {             flag = 1;             u1 = j;             break;           }         }         for (int j = i + 1; j < n; j++) {           if (list[i] > list[j]) {             if (flag == 1) {               flag = 2;               u2 = j;               break;             } else {               break;             }           }         }         if (flag == 2) {           u3 = i;           break;         }       }       if (flag == 2) {         cout <<  YES  << endl;         cout << u1 + 1 <<     << u3 + 1 <<     << u2 + 1 << endl;       } else {         cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a1[1000007], b1[1000007];   int main() {     long long n, i, j, k = 0;     cin >> n;     for (i = 0; i < n; i++) {       string st;       cin >> st;       long long si = st.size(), c1 = 0, c2 = 0;       for (j = 0; j < si; j++) {         if (st[j] ==  ( ) {           c1++;         }         if (st[j] ==  ) ) {           if (c1 > 0) {             c1--;           } else {             c2++;           }         }       }       if (c1 == 0 && c2 == 0)         k++;       else if (c2 == 0)         a1[c1]++;       else if (c1 == 0)         b1[c2]++;     }     long long ans = 0;     ans = ans + (k / 2);     for (i = 0; i <= 1000007; i++) {       ans = ans + min(a1[i], b1[i]);     }     cout << ans << endl;     return 0;   }