malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long a[100005];   long long count[100005];   int vis[100005];   struct Element {     long long l, r;     Element(long long l, long long r) : l(l), r(r) {}   };   Element getCount(long long k, int n) {     long long lower = 0, upper = 0;     int met = 0;     for (int i = 1; i <= n; i++) {       long long l = 1, r = a[i];       long long res = 0;       while (l <= r) {         long long m = (l + r) / 2;         long long value = a[i] - 3ll * m * m + 3 * m - 1;         if (value >= k) {           res = m;           l = m + 1;         } else           r = m - 1;       }       lower += res, upper += res;       count[i] = res;       long long value = a[i] - 3ll * res * res + 3 * res - 1;       if (value == k) {         vis[i] = 1;         count[i]--;         if (!met)           met = 1;         else           lower--;       } else         vis[i] = 0;     }     return Element(lower, upper);   }   int main() {     int n;     long long k;     scanf( %d%lld , &n, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     long long l = -3e18, r = 1e10;     while (l <= r) {       long long m = (l + r) / 2;       Element u = getCount(m, n);       if (u.l > k)         l = m + 1;       else if (u.r < k)         r = m - 1;       else {         break;       }     }     long long need = k;     for (int i = 1; i <= n; i++) need -= count[i];     for (int i = 1; i <= n; i++) {       if (need && vis[i]) {         need--;         count[i]++;       }       printf( %lld  , count[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s, k, a[2010], b[2010], nxt[2010], sum[2010], dp[2010][2010];   inline int read() {     int s = 0, w = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) w = -1;     for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);     return s * w;   }   bool check(int mid) {     for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + (a[i] <= b[mid]);     memset(dp, 0, sizeof(dp));     for (int i = 1; i <= s; ++i) {       for (int j = 1; j <= n; ++j) dp[i][j] = max(dp[i][j], dp[i - 1][j]);       for (int j = 1; j <= n; ++j)         if (nxt[j])           dp[i][nxt[j]] =               max(dp[i][nxt[j]], dp[i - 1][j - 1] + sum[nxt[j]] - sum[j - 1]);       for (int j = 1; j <= n; ++j) dp[i][j] = max(dp[i][j - 1], dp[i][j]);     }     return dp[s][n] >= k;   }   int main() {     n = read(), m = read(), s = read(), k = read();     for (int i = 1; i <= n; ++i) a[i] = read(), b[i] = a[i];     sort(b + 1, b + 1 + n);     for (int i = 1; i <= m; ++i) {       int l = read(), r = read();       for (int j = l; j <= r; ++j) nxt[j] = max(nxt[j], r);     }     int l = 1, r = n, ans = -1;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid))         ans = b[mid], r = mid - 1;       else         l = mid + 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   string a;   int b[10000];   int memo[2000][2000];   int dp(int i, int d) {     if (abs(d) == k && i == a.length()) return 0;     if (i == a.length() || abs(d) == k) return 1;     if (memo[i][d] != -1) return memo[i][d];     int x;     if (a[i] ==  L )       x = dp(i + 1, d - 1);     else if (a[i] ==  W )       x = dp(i + 1, d + 1);     else if (a[i] ==  D )       x = dp(i + 1, d);     else {       b[i] =  W  -  A ;       x = dp(i + 1, d + 1);       if (x == 1) {         b[i] =  L  -  A ;         x = dp(i + 1, d - 1);       }       if (x == 1) {         b[i] =  D  -  A ;         x = dp(i + 1, d);       }     }     return memo[i][d] = x;   }   int main() {     memset(memo, -1, sizeof(memo));     cin >> n >> k >> a;     if (dp(0, 0) == 1)       cout <<  NO ;     else {       for (int i = 0; i < a.length(); i++) {         if (a[i] !=  ? )           cout << a[i];         else           cout << (char)(b[i] +  A );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e3 + 5;   const double eps = 1e-10;   struct TARGET {     int x, y, t;     double p;   } mp[MAX_N];   int n;   double dis[MAX_N][MAX_N];   double dp[MAX_N];   bool MAP_CMP(TARGET a, TARGET b) { return a.t < b.t; }   void input() {     scanf( %d , &n);     for (int i = 0; i < n; i++)       scanf( %d%d%d%lf , &mp[i].x, &mp[i].y, &mp[i].t, &mp[i].p);   }   int sqr(int x) { return x * x; }   void solve() {     sort(mp, mp + n, MAP_CMP);     for (int i = 0; i < n; i++)       for (int j = 0; j < i; j++)         dis[i][j] = dis[j][i] = sqr(mp[i].x - mp[j].x) + sqr(mp[i].y - mp[j].y);     for (int i = 0; i < n; i++) dp[i] = mp[i].p;     for (int i = 0; i < n; i++)       for (int j = 0; j < i; j++) {         if (1ll * (mp[i].t - mp[j].t) * (mp[i].t - mp[j].t) >= dis[i][j])           dp[i] = max(dp[i], dp[j] + mp[i].p);       }     double ans = 0.0;     for (int i = 0; i < n; i++)       if (dp[i] > ans) ans = dp[i];     printf( %.6f n , ans);   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, c = 0;     cin >> n >> m;     int a[n], i;     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = 0; i < m; i++)       if (a[i] <= 0) c = c + a[i];     cout << abs(c);   }
#include <bits/stdc++.h>   const int M = 1e9 + 7, N = 2 * 1e5 + 3;   using namespace std;   int main() {     long long a, b, f, k, b0;     cin >> a >> b >> f >> k;     b0 = b;     int ans = 0;     if (b < f || b < a - f) {       cout << -1;       return 0;     }     b0 = b - f;     if (b0 < 0) {       cout << -1;       return 0;     }     bool q = 1;     while (k > 1) {       if (q) {         if (b0 < (a - f) * 2) b0 = b, ans++;         b0 -= (a - f) * 2;         if (b0 < 0) {           cout << -1;           return 0;         }         q = 0;         k--;       } else {         if (b0 < 2 * f) b0 = b, ans++;         b0 -= 2 * f;         if (b0 < 0) {           cout << -1;           return 0;         }         q = 1;         k--;       }     }     if (q && b0 < a - f || !q && b0 < f)       cout << ans + 1;     else       cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e5 + 7;   const long long inf = 0x3f3f3f3f3f3f3f;   const long long mod = 20000311;   int n;   vector<int> a(100), b(100);   vector<int> step[100], ves[100];   void solve(int n) {     int st = 0;     for (int i = 0; i < step[n].size(); i++) {       ves[i].clear();       for (int j = st; j < st + step[n][i]; j++) ves[i].push_back(a[j]);       st += step[n][i];     }     a.clear();     for (int i = step[n].size() - 1; i >= 0; i--)       for (auto j : ves[i]) a.push_back(j);   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i], b[a[i]] = i;     if (n == 1) {       cout << 0 <<   n ;       return 0;     }     step[1].push_back(b[1]), step[1].push_back(n - b[1]);     solve(1);     int flag = n % 2 == 0;     for (int go = 2; go + flag <= n; go++) {       if (go % 2 == 0) {         for (int i = 1; i < go; i++) step[go].push_back(1);         int cnt = 1;         while (a[cnt] != go) cnt++;         if (cnt - go + 2) step[go].push_back(cnt - go + 2);         if (n - cnt - 1) step[go].push_back(n - cnt - 1);         solve(go);       } else {         int cnt = n - 1;         while (a[cnt] != go) cnt--;         if (cnt) step[go].push_back(cnt);         if (n - go + 1 - cnt) step[go].push_back(n - go + 1 - cnt);         for (int i = 1; i < go; i++) step[go].push_back(1);         solve(go);       }     }     int tot = 0, st = 1;     if (b[1] == 0) st = 2;     cout << n - flag - st + 1 <<   n ;     for (int i = st; i <= n - flag; i++) {       cout << step[i].size() <<    ;       for (auto j : step[i]) cout << j <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     map<pair<int, int>, int> f;     int t, it, n, res, tmp, x, y, resr, resl, i;     string s;     cin >> t;     for (it = 1; it <= t; it++) {       cin >> n;       cin >> s;       s =     + s;       x = 0;       y = 0;       resr = 1e8;       resl = -1e8;       for (i = 1; i <= n; i++) {         if (s[i] ==  D ) {           x--;           if (f[{x, y}] != 0) {             if ((i - f[{x, y}] - 1) < (resr - resl)) {               resr = i;               resl = f[{x, y}] + 1;             }           }           if ((x == 0) && (y == 0)) {             if ((i - 1) < (resr - resl)) {               resr = i;               resl = 1;             }           }           f[{x, y}] = i;         } else if (s[i] ==  U ) {           x++;           if (f[{x, y}] != 0) {             if ((i - f[{x, y}] - 1) < (resr - resl)) {               resr = i;               resl = f[{x, y}] + 1;             }           }           if ((x == 0) && (y == 0)) {             if ((i - 1) < (resr - resl)) {               resr = i;               resl = 1;             }           }           f[{x, y}] = i;         } else if (s[i] ==  L ) {           y--;           if (f[{x, y}] != 0) {             if ((i - f[{x, y}] - 1) < (resr - resl)) {               resr = i;               resl = f[{x, y}] + 1;             }           }           if ((x == 0) && (y == 0)) {             if ((i - 1) < (resr - resl)) {               resr = i;               resl = 1;             }           }           f[{x, y}] = i;         } else if (s[i] ==  R ) {           y++;           if (f[{x, y}] != 0) {             if (((i)-f[{x, y}] - 1) < (resr - resl)) {               resr = i;               resl = f[{x, y}] + 1;             }           }           if ((x == 0) && (y == 0)) {             if ((i - 1) < (resr - resl)) {               resr = i;               resl = 1;             }           }           f[{x, y}] = i;         }       }       if (resr == 1e8) {         cout << -1 <<   n ;       } else {         cout << resl <<     << resr <<   n ;       }       f.clear();     }   }
#include <bits/stdc++.h>   using namespace std;   int vis[5][5];   int ac[5][5], bc[5][5];   pair<int, int> sum[100];   pair<int, int> cal(int a, int b) {     if (a == 1) {       if (b == 1)         return pair<int, int>(0, 0);       else if (b == 2)         return pair<int, int>(0, 1);       return pair<int, int>(1, 0);     } else if (a == 2) {       if (b == 1)         return pair<int, int>(1, 0);       else if (b == 2)         return pair<int, int>(0, 0);       return pair<int, int>(0, 1);     } else {       if (b == 1)         return pair<int, int>(0, 1);       else if (b == 2)         return pair<int, int>(1, 0);       return pair<int, int>(0, 0);     }   }   int main() {     long long k, pa = 0, pb = 0;     int a, b;     scanf( %lld%d%d , &k, &a, &b);     for (int i = 1; i <= 3; i++)       for (int j = 1; j <= 3; j++) scanf( %d , &ac[i][j]);     for (int i = 1; i <= 3; i++)       for (int j = 1; j <= 3; j++) scanf( %d , &bc[i][j]);     int sz = 1;     vis[a][b] = sz++;     sum[1] = cal(a, b);     int last = 1;     for (int i = 1; i <= k; i++) {       int na = ac[a][b];       int nb = bc[a][b];       if (vis[na][nb]) {         last = vis[na][nb];         break;       }       a = na, b = nb;       vis[a][b] = sz;       sum[sz] = pair<int, int>(sum[sz - 1].first + cal(a, b).first,                                sum[sz - 1].second + cal(a, b).second);       sz++;     }     sz--;     if (sz == k) {       printf( %d %d n , sum[sz].first, sum[sz].second);       return 0;     }     pa += sum[last - 1].first;     pb += sum[last - 1].second;     k -= last - 1;     long long dv = k / (sz - last + 1);     pa += dv * (sum[sz].first - sum[last - 1].first);     pb += dv * (sum[sz].second - sum[last - 1].second);     k %= (sz - last + 1);     if (k != 0) {       pa += (sum[last + k - 1].first - sum[last - 1].first);       pb += (sum[last + k - 1].second - sum[last - 1].second);     }     printf( %lld %lld n , pa, pb);   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q, a[501][501], x, y, s, ans;   vector<int> v;   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> q;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> a[i][j];     for (int p = 1; p <= q; p++) {       cin >> x >> y;       if (a[x][y] == 1)         a[x][y] = 0;       else         a[x][y] = 1;       for (int i = 1; i <= n; i++) {         s = 0;         for (int j = 1; j <= m; j++) {           if (a[i][j] == 1)             s++;           else             s = 0;           ans = max(ans, s);         }       }       v.push_back(ans);       ans = 0;     }     for (int i = 0; i < v.size(); i++) cout << v[i] << endl;   }
#include <bits/stdc++.h>   class MapValue {    public:     std::string configuration;     int s1;     MapValue() {}     MapValue(std::string configuration, int s1)         : configuration(configuration), s1(s1) {}   };   class PairHash {    public:     std::size_t operator()(const std::pair<int, int> &p) const {       return std::hash<int>()(p.first) ^ std::hash<int>()(p.second);     }   };   std::unordered_map<std::pair<int, int>, MapValue, PairHash> my_map;   int A[100], B[100], C[100], q_rez = -0x3f3f3f3f;   std::string rrr =  Impossible ;   void back(int s1, int s2, int s3, int k, int max, std::string ss) {     if (k == max + 1) {       my_map.emplace(std::make_pair(s2 - s1, s3 - s2), MapValue(ss, s1));       return;     }     s1 += A[k];     s2 += B[k];     back(s1, s2, s3, k + 1, max, ss +  LM n );     s1 -= A[k];     s3 += C[k];     back(s1, s2, s3, k + 1, max, ss +  MW n );     s2 -= B[k];     s1 += A[k];     back(s1, s2, s3, k + 1, max, ss +  LW n );   }   void back2(int s1, int s2, int s3, int k, int max, std::string ss) {     if (k == max + 1) {       std::string result;       auto it = my_map.find(std::make_pair(s1 - s2, s2 - s3));       if (it != my_map.end()) {         int q = s1 + it->second.s1;         if (q > q_rez) {           rrr = it->second.configuration + ss;           q_rez = q;         }       }       return;     }     s1 += A[k];     s2 += B[k];     back2(s1, s2, s3, k + 1, max, ss +  LM n );     s1 -= A[k];     s3 += C[k];     back2(s1, s2, s3, k + 1, max, ss +  MW n );     s2 -= B[k];     s1 += A[k];     back2(s1, s2, s3, k + 1, max, ss +  LW n );   }   int main() {     int N;     std::cin >> N;     for (int i = 1; i <= N; i++) {       std::cin >> A[i] >> B[i] >> C[i];     }     std::string ss =   ;     back(0, 0, 0, 1, N / 2, ss);     ss =   ;     back2(0, 0, 0, N / 2 + 1, N, ss);     std::cout << rrr;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2.7e5 + 5;   int m, n, k;   int mod;   int f[19][maxn];   vector<long long> g;   int cnt[maxn];   int upd(const int &x) {     if (x < 0) return x + mod;     if (x >= mod) return x - mod;     return x;   }   void add(int &x, const int &y) { x = upd(x + y); }   int ksm(int x, int k) {     int ans = 1;     while (k) {       if (k & 1) ans = 1ll * ans * x % mod;       x = 1ll * x * x % mod;       k >>= 1;     }     return ans;   }   int jc[maxn], inv[maxn];   void init(int n) {     jc[0] = 1;     for (int i(1), endi(n); i <= endi; i++) jc[i] = 1ll * jc[i - 1] * i % mod;     inv[n] = ksm(jc[n], mod - 2);     for (int i(n - 1), endi(0); i >= endi; i--)       inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;   }   void F(int *f, int n, int h) {     for (int p = 1; p < n; p <<= 1)       for (int i = 0; i < n; i += p << 1)         for (int k(i), endk(i + p - 1); k <= endk; k++) {           add(f[k + p], h * f[k]);         }   }   int l;   vector<long long> operator*(vector<long long> &A, vector<long long> &B) {     static vector<long long> C;     C.clear();     C.resize(l + 1);     for (int i(0), endi(l); i <= endi; i++)       for (int j(0), endj(l - i); j <= endj; j++) C[i + j] += A[i] * B[j];     for (int i(0), endi(l); i <= endi; i++) C[i] %= mod;     return C;   }   vector<long long> pksm(vector<long long> A, int k) {     static vector<long long> C;     C.clear();     C.resize(l + 1);     C[0] = 1;     while (k) {       if (k & 1) C = C * A;       A = A * A;       k >>= 1;     }     return C;   }   int main() {     cin >> n >> k >> mod;     init(n);     if (n & 1) {       cout << ksm(k, n);       return 0;     }     m = 1;     while (m <= n) m <<= 1, l++;     for (int i(0), endi(m - 1); i <= endi; i++) cnt[i] = cnt[i >> 1] + (i & 1);     init(m);     for (int i(0), endi(m - 1); i <= endi; i++) {       f[cnt[i]][i] = inv[i];     }     for (int i(0), endi(l); i <= endi; i++) F(f[i], m, 1);     g.resize(l + 1);     for (int s(0), ends(m - 1); s <= ends; s++) {       for (int i(0), endi(l); i <= endi; i++) g[i] = f[i][s];       g = pksm(g, k);       for (int i(0), endi(l); i <= endi; i++) f[i][s] = g[i];     }     F(f[cnt[n]], m, -1);     cout << upd(ksm(k, n) - 1ll * f[cnt[n]][n] * jc[n] % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool issquare(int n) {     int sq = sqrt(n);     if (sq * sq == n) {       return true;     } else {       return false;     }   }   int main() {     long long int n;     cin >> n;     long long int ans = n;     int f = 1;     while (n != 1 and f == 1) {       int sqr = ceil(sqrt((n * 1.0)));       f = 0;       for (int i = 2; i <= sqr; i++) {         if (n % i == 0) {           n = n / i;           ans += n;           f = 1;           break;         }       }     }     if (n != 1) ans += 1;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = ((int)5e5) + 5;   long long int sum[maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     string s;     cin >> s;     for (int i = 0; i < s.length(); i++) {       long long int total = 0;       for (int j = i; j < s.length(); j++) {         total += s[j] -  0 ;         sum[total]++;       }     }     long long int ans = 0;     if (n == 0) {       ans = 2 * sum[0] * ((s.length()) * (s.length() + 1)) / 2 - sum[0] * sum[0];     } else {       for (int i = 1; i < maxn; i++) {         if (n % i == 0 && (n / i) < maxn) {           ans += sum[i] * sum[n / i];         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     long long x = 1;     long long a = 1;     for (int i = 1; i <= m; i++) a = (a << 1) % 1000000009;     for (int i = 1; i <= n; i++) {       a--;       x = x % 1000000009 * (a + 1000000009) % 1000000009;     }     printf( %I64d n , x % 1000000009);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const long long MOD = 1e9 + 7;   pair<int, int> es[200000];   vector<pair<int, int> > g[200000];   int degree[200000];   set<pair<int, int> > st;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     for (long long i = 0; i < m; i++) {       scanf( %d%d , &es[i].first, &es[i].second);       es[i].first--, es[i].second--;       g[es[i].first].push_back({es[i].second, i});       g[es[i].second].push_back({es[i].first, i});       degree[es[i].first]++, degree[es[i].second]++;     }     reverse(es, es + m);     for (long long i = 0; i < n; i++) st.insert({degree[i], i});     while (!st.empty() && st.begin()->first < k) {       auto v = st.begin();       for (pair<int, int> &i : g[v->second]) {         int to = i.first;         if (st.find({degree[to], to}) != st.end()) {           st.erase({degree[to], to});           degree[to]--;           st.insert({degree[to], to});         }       }       st.erase(v);     }     vector<int> out;     for (long long j = 0; j < m; j++) {       out.push_back(st.size());       int u = es[j].first, v = es[j].second;       if (st.find({degree[u], u}) != st.end() &&           st.find({degree[v], v}) != st.end()) {         st.erase({degree[u], u});         degree[u]--;         st.insert({degree[u], u});         st.erase({degree[v], v});         degree[v]--;         st.insert({degree[v], v});         while (!st.empty() && st.begin()->first < k) {           auto v = st.begin();           for (pair<int, int> &i : g[v->second]) {             if (i.second >= m - j - 1) continue;             int to = i.first;             if (st.find({degree[to], to}) != st.end()) {               st.erase({degree[to], to});               degree[to]--;               st.insert({degree[to], to});             }           }           st.erase(v);         }       }     }     reverse(begin(out), end(out));     for (int i : out) printf( %d n , i);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void Read(T &x) {     char c;     bool f(0);     while (c = getchar(), c != EOF) {       if (c ==  - )         f = 1;       else if (c >=  0  && c <=  9 ) {         x = c -  0 ;         while (c = getchar(), c >=  0  && c <=  9 ) x = x * 10 + c -  0 ;         ungetc(c, stdin);         if (f) x = -x;         return;       }     }   }   struct point {     int x, y;     inline point() {}     inline point(int x, int y) : x(x), y(y) {}     inline point operator-(const point &b) const {       return point(x - b.x, y - b.y);     }     inline bool operator<(const point &b) const {       if (x == b.x) return y < b.y;       return x < b.x;     }     inline bool operator>(const point &b) const {       if (x == b.x) return y > b.y;       return x > b.x;     }     inline bool operator==(const point &b) const { return x == b.x && y == b.y; }   } a[100000 + 10];   int Q;   set<point> s;   set<point, greater<point> > s2;   inline long long cross(const point &a, const point &b) {     return 1ll * a.x * b.y - 1ll * a.y * b.x;   }   template <class T>   void insert(T &s, const point &a) {     auto i = s.lower_bound(a);     if (i != s.end() && *i == a) return;     auto j = i;     if (j != s.begin()) {       j--;       while (j != s.begin()) {         auto k = j--;         if (cross(*k - *j, a - *k) > 0) break;         s.erase(k);       }     }     if (i != s.end()) {       auto k = i;       while (++i != s.end()) {         if (cross(*k - a, *i - a) > 0) break;         s.erase(k);         k = i;       }     }     i = s.lower_bound(a);     if (i == s.end() || i == s.begin())       s.insert(a);     else {       auto j = i--;       if (cross(a - *i, *j - *i) > 0) s.insert(a);     }   }   template <class T>   bool check(const T &s, const point &a) {     auto i = s.lower_bound(a);     if (*i == a) return 1;     if (i == s.begin() || i == s.end()) return 0;     auto j = i--;     return cross(a - *i, *j - *i) <= 0;   }   int main() {     Read(Q);     int p, x, y;     while (Q--) {       Read(p), Read(x), Read(y);       if (p == 1) {         insert(s, point(x, y));         insert(s2, point(x, y));       } else         puts(check(s, point(x, y)) && check(s2, point(x, y)) ?  YES  :  NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char *argv[]) {     string s;     int min1 = 200, min2 = 200, min3 = 200, min4 = 200, min5 = 200;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  h  && i < min1) min1 = i;       if (s[i] ==  e  && i < min2 && min1 < i) min2 = i;       if (s[i] ==  l  && i < min3 && min2 < i) {         min3 = i;         s[i] = 0;       }       if (s[i] ==  l  && i < min4 && min3 < i) {         min4 = i;         s[i] = 0;       }       if (s[i] ==  o  && i < min5 && min4 < i) min5 = i;     }     if (min1 < min2 && min2 < min3 && min3 < min4 && min4 < min5 && min1 != 200 &&         min2 != 200 && min3 != 200 && min4 != 200 && min5 != 200)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long a, b;     cin >> a >> b;     cout <<  YES  << endl;     for (long long i = a; i <= b; i += 2) cout << i <<     << i + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 100000;   long long a[N + 5], res;   int n, p;   int main() {     cin >> n >> p;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       a[i] += a[i - 1];     }     for (int i = 1; i < n; ++i) res = max(res, a[i] % p + (a[n] - a[i]) % p);     cout << res;     return 0;   }