malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream& operator<<(ostream& os, const vector<T>& v) {     for (auto i = begin(v); i != end(v); i++)       os << *i << (i == end(v) - 1 ?    :    );     return os;   }   template <class T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto i = begin(v); i != end(v); i++) is >> *i;     return is;   }   vector<vector<int>> g;   vector<int> visited;   vector<int> bad_parents;   bool total_stop = false;   int full_bt_depth(int i) {     visited[i] = true;     vector<int> sizes;     for (int u : g[i]) {       if (visited[u]) continue;       sizes.push_back(full_bt_depth(u));     }     if (sizes.size() == 0) return 1;     if (sizes.size() == 1) {       if (sizes[0] != 1) total_stop = true;       bad_parents.push_back(i);       return -1;     }     if (sizes.size() == 2) {       if (sizes[0] == sizes[1] && sizes[0] != -1) {         return sizes[0] + 1;       }       if (sizes[0] == -1 && sizes[1] == -1) total_stop = true;       return -1;     }     if (sizes.size() == 3) {       sort((sizes).begin(), (sizes).end());       if (sizes[0] == sizes[1] && (sizes[1] + 1) == sizes[2]) {         bad_parents.push_back(i);         return -1;       }     }     total_stop = true;     return -1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n == 2) {       cout <<  2 n 1 2 ;       return 0;     }     int n_vtx = (1 << n) - 1;     g.resize(n_vtx);     visited.resize(n_vtx);     int first_a = -1, first_b = -1;     for (int i = 0; i < (n_vtx - 2); i++) {       int a, b;       cin >> a >> b;       if (first_a == -1) first_a = a;       if (first_b == -1) first_b = b;       a--, b--;       g[a].push_back(b);       g[b].push_back(a);     }     queue<int> leaves;     for (int i = 0; i < n_vtx; i++) {       if (g[i].size() == 1) {         leaves.push(i);         visited[i] = true;       }     }     vector<int> last_row;     while (leaves.size() > 0) {       int sz = leaves.size();       last_row.clear();       while (sz-- > 0) {         int q = leaves.front();         leaves.pop();         last_row.push_back(q);         for (int u : g[q]) {           visited[u]++;           if (visited[u] + 1 == g[u].size()) {             leaves.push(u);           }         }       }     }     for (int x : last_row) {       visited.assign(visited.size(), 0);       full_bt_depth(x);     }     if (total_stop || bad_parents.size() == 0) {       cout << 0;       return 0;     } else {       sort((bad_parents).begin(), (bad_parents).end());       cout << bad_parents.size() <<   n ;       for (int u : bad_parents) cout << u + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const int N = 100010;   int n, k, m;   int a[N];   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     int cnt = 0;     while (k > 0) {       cnt += 1;       k -= cnt;     }     cout << a[k + cnt];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vis[200005];   pair<int, int> seg[200005];   vector<pair<int, pair<int, int> > > v;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long m, n, i, j, t, x, y, w, k, l, r;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> l >> r;       v.push_back({l, {i, 1}});       v.push_back({r + 1, {i, -1}});       seg[i].first = l;       seg[i].second = r + 1;     }     sort(v.begin(), v.end());     vector<int> ans;     priority_queue<pair<int, int> > pq;     int count = 0;     for (i = 0; i < v.size();) {       x = v[i].first;       while (i < v.size() && x == v[i].first) {         if (vis[v[i].second.first]) {           i++;           continue;         }         if (v[i].second.second == 1) {           pq.push({seg[v[i].second.first].second, v[i].second.first});         }         count += v[i].second.second;         i++;       }       if (count > k) {         int rem = count - k;         count = k;         while (true) {           if (vis[pq.top().second] == 1) {             pq.pop();             continue;           }           rem--;           ans.push_back(pq.top().second);           vis[pq.top().second] = 1;           pq.pop();           if (rem == 0) break;         }       }     }     cout << ans.size() <<   n ;     sort(ans.begin(), ans.end());     for (auto x : ans) {       cout << x + 1 <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long niz[1000000];   long long kum[1000000];   int main() {     ios_base::sync_with_stdio(false);     cout.precision(10);     cout << fixed;     int n, s, f;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> niz[i];     }     cin >> s >> f;     long long s1, f1;     for (int i = 1; i <= n; i++) {       s1 = s - i + 1;       if (s1 <= 0) s1 += n;       f1 = f - i + 1;       ;       if (f1 <= 0) f1 += n;       if (s1 > f1) {         kum[1] += niz[i];         kum[f1] -= niz[i];         kum[s1] += niz[i];       } else {         kum[s1] += niz[i];         kum[f1] -= niz[i];       }     }     kum[0] = 0;     long long maxi = 0;     for (int i = 1; i <= n; i++) {       kum[i] = kum[i] + kum[i - 1];       maxi = max(maxi, kum[i]);     }     for (int i = 1; i <= n; i++) {       if (kum[i] == maxi) {         cout << i;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 5;   const long long int inf64 = 1e18 + 5;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, i;     pair<long long int, long long int> fr;     cin >> n;     vector<pair<long long int, long long int> > v;     cin >> fr.first >> fr.second;     for (i = 0; i < n - 1; i++) {       long long int a, b;       cin >> a >> b;       v.push_back({a, b});     }     sort(v.begin(), v.end(), greater<pair<long long int, long long int> >());     int ans = 0;     for (i = 0; i < n - 1; i++) {       if (v[i].first <= fr.first) break;       ++ans;     }     priority_queue<long long int, vector<long long int>, greater<long long int> >         pq;     for (int i = 0, j = 0; i < v.size(); i = j) {       while (j < v.size() && v[j].first > fr.first) {         pq.push(v[j].second - v[j].first + 1);         ++j;       }       if (pq.empty()) break;       ans = min(ans, (int)pq.size());       long long int p = pq.top();       if (p > fr.first) break;       pq.pop();       fr.first -= p;     }     ans = min(ans, (int)pq.size());     while (!pq.empty() && fr.first >= pq.top()) {       fr.first -= pq.top();       pq.pop();       ans = min(ans, (int)pq.size());     }     cout << ans + 1;   }
#include <bits/stdc++.h>   using namespace std;   void print(int x) { cerr << x; }   void print(long x) { cerr << x; }   void print(long long x) { cerr << x; }   void print(unsigned x) { cerr << x; }   void print(unsigned long x) { cerr << x; }   void print(unsigned long long x) { cerr << x; }   void print(float x) { cerr << x; }   void print(double x) { cerr << x; }   void print(long double x) { cerr << x; }   void print(char x) { cerr <<      << x <<     ; }   void print(const char *x) { cerr <<     << x <<    ; }   void print(const string &x) { cerr <<     << x <<    ; }   void print(bool x) { cerr << (x ?  true  :  false ); }   const long long int MOD = 1e9 + 7;   const long long int INF = 1e18;   const long long int maxn = 1e6 + 4;   void answer() {     long long int a;     cin >> a;     vector<long long int> v;     long long int sum = 0;     for (long long int i = 0; i < a; ++i) {       long long int temp;       cin >> temp;       v.push_back(temp);       sum += temp;     }     long long int k = sum / a;     long long int ans = 0;     if (a == 1) {       cout << 0;     } else {       for (long long int i = 0; i < a - 1; ++i) {         if (v[i] < k) {           long long int real = k - v[i];           ans += real;           v[i + 1] -= real;           v[i] = k;         } else {           long long int real = v[i] - k;           ans += real;           v[i + 1] += real;           v[i] = k;         }       }       cout << ans;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t-- > 0) {       answer();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char str1[10], str2[10], str3[10];     int flag1, flag2, flag3;     flag1 = 0;     flag2 = 0;     flag3 = 0;     cin >> str1 >> str2 >> str3;     if (strcmp(str1, str2) == 0) {       flag1 = 1;     } else if (strcmp(str2, str3) == 0) {       flag2 = 1;     } else if (strcmp(str3, str1) == 0) {       flag3 = 1;     }     if ((flag1 | flag2 | flag3) == 0) {       cout <<  ?  << endl;       return 0;     }     if ((flag1 & flag2 & flag3) == 1) {       cout <<  ?  << endl;       return 0;     }     if (flag1 == 1) {       if (strcmp(str3,  rock ) == 0) {         if (strcmp(str2,  scissors ) == 0) {           cout <<  S  << endl;           return 0;         }       }       if (strcmp(str3,  scissors ) == 0) {         if (strcmp(str2,  paper ) == 0) {           cout <<  S  << endl;           return 0;         }       }       if (strcmp(str3,  paper ) == 0) {         if (strcmp(str2,  rock ) == 0) {           cout <<  S  << endl;           return 0;         }       }     }     if (flag2 == 1) {       if (strcmp(str1,  rock ) == 0) {         if (strcmp(str2,  scissors ) == 0) {           cout <<  F  << endl;           return 0;         }       }       if (strcmp(str1,  scissors ) == 0) {         if (strcmp(str2,  paper ) == 0) {           cout <<  F  << endl;           return 0;         }       }       if (strcmp(str1,  paper ) == 0) {         if (strcmp(str2,  rock ) == 0) {           cout <<  F  << endl;           return 0;         }       }     }     if (flag3 == 1) {       if (strcmp(str2,  rock ) == 0) {         if (strcmp(str3,  scissors ) == 0) {           cout <<  M  << endl;           return 0;         }       }       if (strcmp(str2,  scissors ) == 0) {         if (strcmp(str3,  paper ) == 0) {           cout <<  M  << endl;           return 0;         }       }       if (strcmp(str2,  paper ) == 0) {         if (strcmp(str3,  rock ) == 0) {           cout <<  M  << endl;           return 0;         }       }     }     cout <<  ?  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[3010], x, y, c[100], d[100], n, l, r, time, count = 0, p, q, i, j;     scanf( %d%d%d%d , &p, &q, &l, &r);     memset(a, 0, sizeof(a));     while (p--) {       scanf( %d%d , &x, &y);       for (i = x; i <= y; i++) a[i]++;     }     for (i = 0; i < q; i++) {       scanf( %d%d , &c[i], &d[i]);     }     for (time = l; time <= r; time++) {       for (i = 0; i < q; i++) {         int flag = 0;         for (j = c[i] + time; j <= d[i] + time; j++) {           if (a[j] > 0) {             count++;             flag++;             break;           }         }         if (flag > 0) {           break;         }       }     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   std::priority_queue<std::pair<long long, int> > que;   long long dis[2005];   int w[2005][2005];   int main() {     int n, mn = 1e9;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       for (int j = 1; j < n - i; j++) {         int x;         scanf( %d , &x);         w[i][i + j] = w[i + j][i] = x;         mn = std::min(mn, x);       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i != j) w[i][j] -= mn;       }     }     for (int i = 0; i < n; i++) {       dis[i] = 1e18;       for (int j = 0; j < n; j++) {         if (i != j) dis[i] = std::min(dis[i], (long long)w[i][j] << 1);       }       que.push(std::make_pair(-dis[i], i));     }     while (!que.empty()) {       long long d = -que.top().first;       int u = que.top().second;       que.pop();       if (dis[u] != d) continue;       for (int v = 0; v < n; v++) {         if (u != v && d + w[u][v] < dis[v]) {           dis[v] = d + w[u][v];           que.push(std::make_pair(-dis[v], v));         }       }     }     for (int i = 0; i < n; i++)       printf( %lld n , (long long)(n - 1) * mn + dis[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }   long long ar[3];   void solve() {     long long x, y, ans = 0;     cin >> x >> y;     ar[0] = ar[1] = ar[2] = y;     while (ar[0] < x || ar[1] < x || ar[2] < x) {       sort(ar, ar + 3);       ar[0] = ar[1] + ar[2] - 1;       ans++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   typedef class Point {    public:     double x, y;     Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}   } Point, Vector;   Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }   double cross(Vector u, Vector v) { return u.x * v.y - u.y * v.x; }   int n;   Point *ps;   inline void init() {     scanf( %d , &n);     ps = new Point[(n + 1)];     for (int i = 1; i <= n; i++) scanf( %lf%lf , &ps[i].x, &ps[i].y);   }   int cnt = 0;   long long res = 0;   pair<double, int> *ar;   bool *vis;   int getNext(int p) {     if (p == cnt) return 1;     return p + 1;   }   inline void solve() {     vis = new bool[(n + 1)];     ar = new pair<double, int>[(n + 1)];     for (int i = 1; i <= n; i++) {       cnt = 0;       for (int j = 1; j <= n; j++)         if (j ^ i) {           Vector dif = ps[j] - ps[i];           ar[++cnt] = make_pair(atan2(dif.y, dif.x), j);         }       sort(ar + 1, ar + cnt + 1);       int p = 1, cntl = 0;       memset(vis, false, sizeof(bool) * (n + 1));       for (int j = 1; j < n; j++) {         Vector dif = ps[ar[j].second] - ps[i];         for (int np = getNext(p);              np != j && cross(dif, ps[ar[np].second] - ps[i]) > 0;              p = np, np = getNext(np))           cntl += !vis[np], vis[np] = true;         res = res + cntl * 1ll * (cntl - 1) / 2 * (n - cntl - 2) * 1ll *                         (n - cntl - 3) / 2;         int np = ar[getNext(j)].second, nj = getNext(j);         if (cross(dif, ps[np] - ps[i]) > 0)           cntl--, vis[nj] = false;         else {           if (p == j) p = getNext(j);         }       }     }     cout << (res >> 1) << endl;   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   // #include <ext/pb_ds/assoc_container.hpp>   // #include <ext/pb_ds/tree_policy.hpp>   using namespace std;   // using namespace __gnu_pbds;   #define lli long long int   #define llu unsigned long long int   #define pb push_back   #define rt return 0   #define endln   n    #define all(x) x.begin(), x.end()   #define sz(x) (lli)(x.size())   const lli MOD = 1e9 + 7;   const double PI = 2 * acos(0.0);   // cout << fixed << setprecision(0) << pi <<endl;   // typedef tree<int, null_type, less<int>, rb_tree_tag,   //              tree_order_statistics_node_update>   //     new_data_set;   // for multiset   // typedef tree<int, null_type, less_equal<int>, rb_tree_tag,   //              tree_order_statistics_node_update>   //     new_data_set;   // order_of_key(val): returns the number of values less than val   // find_by_order(k): returns an iterator to the kth largest element (0-based)      void solve() {       lli n, a;       cin >> n >> a;       cout << n - 1 <<     << a << endl;   }      int main(void) {       ios::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);       lli t;       cin >> t;       while (t--)           solve();       rt;   }
#include <bits/stdc++.h>   using namespace std;   long long make(long long n) {     if (n % 4 == 3) return 0;     if (n % 4 == 0) return n;     if (n % 4 == 1) return 1;     if (n % 4 == 2) return (n ^ 1);   }   int main() {     long long n;     cin >> n;     long long i, nim = 0;     for (i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       nim ^= (make(a - 1) ^ make(a + b - 1));     }     if (nim != 0)       cout <<  tolik ;     else       cout <<  bolik ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int p = 0; p < t; ++p) {       int n;       cin >> n;       int d[2][n];       for (int i = 0; i <= 1; ++i) {         for (int j = 0; j < n; ++j) cin >> d[i][j];       }       if (n == 1)         cout << 0 << endl;       else {         int suff[n], pref[n];         suff[0] = 0;         pref[0] = 0;         for (int i = 1; i < n; ++i) {           suff[i] = d[0][n - i] + suff[i - 1];           pref[i] = d[1][i - 1] + pref[i - 1];         }         int res = 2e9;         for (int i = 0; i < n; ++i) {           res = min(res, max(suff[n - 1 - i], pref[i]));         }         cout << res << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long p = 1e9 + 7;   struct aaa {     long long x, y;   } a[200010];   long long n, ans = 1, sz[500010], fa[500010], v[500010], fac[500010],                aa[500010], bb[500010], cnt0, cnt1;   map<long long, long long> mp0, mp1;   long long find(long long x) {     if (x == fa[x]) return x;     return fa[x] = find(fa[x]);   }   int main() {     long long i, x, y;     scanf( %lld , &n);     fac[0] = 1;     for (i = 1; i <= n * 2; i++) fac[i] = fac[i - 1] * 2 % p;     for (i = 1; i <= n; i++) {       scanf( %lld%lld , &a[i].x, &a[i].y);       aa[i] = a[i].x;       bb[i] = a[i].y;     }     sort(aa + 1, aa + n + 1);     sort(bb + 1, bb + n + 1);     for (i = 1; i <= n; i++) {       if (i == 1 || aa[i] != aa[i - 1]) mp0[aa[i]] = ++cnt0;     }     for (i = 1; i <= n; i++) {       if (i == 1 || bb[i] != bb[i - 1]) mp1[bb[i]] = ++cnt1;     }     for (i = 1; i <= cnt0 + cnt1; i++) fa[i] = i, sz[i] = 1;     for (i = 1; i <= n; i++) {       x = find(mp0[a[i].x]);       y = find(cnt0 + mp1[a[i].y]);       if (x != y) {         fa[x] = y;         v[y] |= v[x];         sz[y] += sz[x];       } else         v[x] = 1;     }     for (i = 1; i <= cnt0 + cnt1; i++)       if (fa[i] == i) {         if (v[i])           ans = ans * fac[sz[i]] % p;         else           ans = ans * (fac[sz[i]] - 1 + p) % p;       }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, s;     cin >> a >> b >> s;     if (a < 0) a *= (-1);     if (b < 0) b *= (-1);     (s >= (a + b) && (s - a - b) % 2 == 0) ? cout <<  YES  : cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, x;     cin >> n >> x;     long long ans = 0;     for (long long i = 1; i <= n; i++) {       if (i * n >= x) {         if (x % i == 0) ans += 1;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   int t, n, per[200001], where[200001];   int groupcnt;   int main() {     scanf( %d , &t);     for (int test = 0; test < t; test++) {       scanf( %d , &n);       groupcnt = 0;       for (int i = 1; i <= n; i++) {         scanf( %d , &per[i]);         where[per[i]] = i;       }       for (int i = 1; i <= n; i++) {         groupcnt++;         int location = where[i];         if (location > 1 && per[location - 1] < i) groupcnt--;         if (location < n && per[location + 1] < i) groupcnt--;         if (groupcnt == 1)           printf( 1 );         else           printf( 0 );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005], b[100005];   int main() {     int n, m, k;     map<int, int> f1;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < m; i++) {       cin >> b[i];     }     bool f = false;     sort(a, a + n);     sort(b, b + m);     reverse(a, a + n);     reverse(b, b + m);     if (n <= m) {       for (int i = 0; i < n; i++) {         if (a[i] > b[i]) {           f = true;           break;         }       }     } else {       f = true;     }     if (f) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v;     int n, a, b;     while (scanf( %d , &n) != EOF) {       v.assign(n, 0);       for (int i = 0; i < n; i++) {         scanf( %d , &v[i]);       }       sort(v.begin(), v.end());       a = 1;       b = n - 1;       while (a < n && v[a] == v[0]) a++;       while (b >= 0 && v[b] == v[n - 1]) b--;       if (a > b)         printf( 0 n );       else         printf( %d n , b - a + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   using str = string;   using srt = short;   const int INF = (int)1e9 + 4;   const int MOD = (int)1e9 + 7;   const int N = 1005;   const ll inf = (ll)4e18;   const ll mod = 998244353;   bool us[N][N];   set<pair<int, int>> ans;   vector<pair<int, int>> arr(3);   vector<pair<int, int>> dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};   int dist(pair<int, int> a, pair<int, int> b) {     return abs(a.first - b.first) + abs(a.second - b.second);   }   void vToV(int st, int en) {     int x1 = arr[st].first, y1 = arr[st].second, x2 = arr[en].first,         y2 = arr[en].second;     ans.insert({x1, y1});     while (x1 != x2 || y1 != y2) {       us[x1][y1] = 1;       if (x1 < x2 && us[x1 + 1][y1]) {         ans.insert({++x1, y1});       } else if (y1 < y2 && us[x1][y1 + 1]) {         ans.insert({x1, ++y1});       } else if (y1 > y2 && us[x1][y1 - 1]) {         ans.insert({x1, --y1});       } else {         int dst = INF;         pair<int, int> dir;         for (auto it : dirs) {           int now = dist({x1 + it.first, y1 + it.second}, {x2, y2});           if (now < dst) {             dir = it;             dst = now;           }         }         x1 += dir.first;         y1 += dir.second;         ans.insert({x1, y1});       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     for (auto &it : arr) {       cin >> it.first >> it.second;       ans.insert(it);       us[it.first][it.second] = 1;     }     sort(begin(arr), end(arr));     arr.emplace_back(arr.back());     vToV(0, 1);     vToV(1, 2);     cout << ans.size() << endl;     for (auto &it : ans) cout << it.first <<     << it.second << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     long long n;     scanf( %I64d , &n);     printf( %I64d , n - n / 2 - n / 3 - n / 5 - n / 7 + n / (2 * 3) +                         n / (2 * 5) + n / (2 * 7) + n / (3 * 5) + n / (3 * 7) +                         n / (7 * 5) - n / (3 * 2 * 5) - n / (3 * 2 * 7) -                         n / (3 * 5 * 7) - n / (7 * 2 * 5) + n / (2 * 3 * 5 * 7));   }
#include <bits/stdc++.h>   using namespace std;   int row[300000];   int verts[300000];   int main() {     long long int v, p = 0, h, input, answer = 0, tanswer = 1000000000;     cin >> v >> h;     row[0] = 0;     verts[0] = 0;     for (int i = 1; i <= v; i++) {       cin >> verts[i];     }     verts[v + 1] = 1000000000;     v++;     for (int j = 1; j <= h; j++) {       int first;       cin >> first;       if (first == 1) {         p++;         cin >> row[p] >> first;       } else {         cin >> first >> first;       }     }     sort(row, row + p + 1);     sort(verts, verts + v);     int rows = p;     int cr = 1;     for (int c = 1; c <= v; c++) {       for (int r = cr; r <= rows; r++) {         if (row[r] < verts[c]) {           if (r == rows) {             answer = rows - r + c - 1;             cr = r + 1;             break;           }           continue;         } else {           answer = rows - r + c;           cr = r;           break;         }       }       if (answer < tanswer) tanswer = answer;     }     cout << tanswer;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     string s;     map<string, int> m;     for (__typeof((n)) i = (0); i < (n); i++) {       cin >> s;       if (m[s])         cout <<  YES  << endl;       else         cout <<  NO  << endl;       m[s]++;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }