malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, a, k;   int x[200030], xx[200030];   bool judge(int m) {     for (int i = 1; i <= m; i++) xx[i] = x[i];     sort(xx + 1, xx + 1 + m);     int ans = 0;     xx[0] = 0;     for (int i = 1; i <= m; i++) ans += (xx[i] - xx[i - 1]) / (a + 1);     ans += (n - xx[m] + 1) / (a + 1);     return ans < k;   }   int main() {     int m;     scanf( %d%d%d , &n, &k, &a);     scanf( %d , &m);     for (int i = 1; i <= m; i++) scanf( %d , x + i);     int ans = 1 << 30;     int l = 1, r = m, mid;     while (l <= r) {       mid = (l + r) >> 1;       if (judge(mid))         ans = min(ans, mid), r = mid - 1;       else         l = mid + 1;     }     if (ans == (1 << 30)) ans = -1;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000;   const int inf = (int)1e9 + 1;   const long long big = (long long)1e18 + 1;   const int P = 239;   const int MOD = (int)1e9 + 7;   const int MOD1 = (int)1e9 + 9;   const double eps = 1e-9;   const double pi = atan2(0, -1);   const int ABC = 26;   int nim0[10] = {0, 1, 2, 0, 1, 0, 1, 0, 1, 0};   int nim1[10] = {0, 1, 0, 1, 2, 0, 2, 0, 1, 0};   int get0(int x) {     if (x < 10)       return nim0[x];     else       return (x % 2 == 0 ? 1 : 0);   }   int get1(int x) {     if (x < 10)       return nim1[x];     else {       if (x % 2 == 1) return 0;       int tmp = get1(x / 2);       int ans = 0;       while (ans == 0 || ans == tmp) ans++;       return ans;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.precision(20);     int n, k;     cin >> n >> k;     int ans = 0;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (k % 2 == 0)         ans ^= get0(x);       else         ans ^= get1(x);     }     cout << (ans ?  Kevin n  :  Nicky n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   int used[10];   int main() {     cin >> N >> M;     int len1 = 1, len2 = 1;     for (int a = 7; a < N; a *= 7) {       ++len1;     }     for (int b = 7; b < M; b *= 7) {       ++len2;     }     int answer = 0;     if (len1 + len2 <= 7) {       for (int i = 0; i != N; ++i) {         for (int j = 0; j != M; ++j) {           for (int k = 0; k <= 6; ++k) {             used[k] = 0;           }           for (int a = i, k = 0; k != len1; ++k, a /= 7) {             used[a % 7]++;           }           for (int b = j, k = 0; k != len2; ++k, b /= 7) {             used[b % 7]++;           }           int mx = 0;           for (int i = 0; i < 7; ++i) {             mx = max(mx, used[i]);           }           if (mx < 2) {             ++answer;           }         }       }     }     cout << answer <<   n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define int long long   const int maxn = 2000005;   int tag[maxn],summ[maxn];   int len[maxn];   int n,k;   void push_up(int p){    summ[p] = summ[p<<1] + summ[p<<1|1];   }   void push_down(int p,int l,int r){    if(tag[p] == 0) return;    int x = tag[p];    tag[p] = 0; int mid = (l+r)>>1;    tag[p<<1] += x,tag[p<<1|1] += x;    summ[p<<1] += x * (mid - l + 1);    summ[p<<1|1] += x * (r - mid);   }   void build(int l,int r,int p)   {    tag[p] = 0;    if(l == r){     if(l == 1) summ[p] = 1;     else summ[p] = 0;     return;    }    int mid = (l+r)>>1;    build(l,mid,p<<1);    build(mid+1,r,p<<1|1);    push_up(p);   }   void gai(int l,int r,int p,int ll,int rr,int z){    if(ll > rr) return;    if(l != r) push_down(p,l,r);    if(ll <= l && r <= rr){     summ[p] += (r - l + 1) * z;     tag[p] += z;     if(l != r) push_down(p,l,r);     return;    }    int mid = (l+r)>>1;    if(ll <= mid) gai(l,mid,p<<1,ll,rr,z);    if(rr > mid) gai(mid+1,r,p<<1|1,ll,rr,z);    push_up(p);   }   int cha(int l,int r,int p,int z){   // printf( %lld %lld %lld n ,l,r,summ[p]);    if(l == r) return l;    else push_down(p,l,r);    int mid = (l+r)>>1;    if(z <= summ[p<<1]){     return cha(l,mid,p<<1,z);//第z小    }    z -= summ[p<<1];    return cha(mid+1,r,p<<1|1,z);   }   void chong(int l,int r,int p)   {    if(l == r) return;    push_down(p,l,r);    int mid = (l+r)>>1;    chong(l,mid,p<<1);    chong(mid+1,r,p<<1|1);   }   signed main()   {    scanf( %lld%lld ,&n,&k);    for(int i=1;i<=n;++i) scanf( %lld ,&len[i]);    sort(len + 1,len + n + 1);    reverse(len + 1,len + n + 1);    build(1,300000,1);    int ans = 1e9;   // for(int i=1;i<=n;++i) printf( %lld  ,len[i]);   // return 0;    for(int i=1;i<=n+1;++i){    // printf(  n n );     if(summ[1] >= k)     {      int ak = cha(1,300000,1,k);      ans = min(ans,ak);      //printf( %lld n ,ak);     }     if(n == i - 1) break;    // chong(1,300000,1);     int akk = cha(1,300000,1,1);     gai(1,300000,1,akk,akk,-1);//直接-1    // printf( %lld n ,akk);   //  return 0;     int x = len[i];     x --;     akk += 2;//在这里减     if(x % 2 == 0){      gai(1,300000,1,akk,akk + x/2 - 1,2);     }     else{     // printf( %lld n ,akk);      gai(1,300000,1,akk,akk + x/2-1,1);//3      gai(1,300000,1,akk,akk + x/2,1);//3 4     }    }    if(ans != 1e9)    printf( %lld n ,ans-1);    else printf( -1 );   }
#include <bits/stdc++.h>   using namespace std;   int a[123456];   int main() {     int n, ans = 0;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     a[n + 1] = a[0] = 0;     for (int i = 1; i <= n; i++)       a[i] = min(a[i], min(a[i - 1] + 1, a[i + 1] + 1));     for (int i = n; i > 0; i--) {       a[i] = min(a[i], min(a[i - 1] + 1, a[i + 1] + 1));       ans = max(ans, a[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     while (scanf( %d %d , &n, &k) == 2) {       char s[1000005];       memset(s, 0, sizeof(s));       int t = 0;       if (n == 1 && k == 1)         printf( a n );       else if (k == 1)         printf( -1 n );       else if (n < k)         printf( -1 n );       else if (k == 2) {         int l = k - 2;         for (int i = 1; i <= n - l; i++) {           if (i & 1)             s[t++] =  a ;           else             s[t++] =  b ;         }         s[t] =   0 ;         printf( %s n , s);       } else if (k == 3) {         int l = k - 2;         for (int i = 1; i <= n - l; i++) {           if (i & 1)             s[t++] =  a ;           else             s[t++] =  b ;         }         for (int i = 1; i <= l; i++) {           s[t++] = char( b  + i);         }         s[t] =   0 ;         printf( %s n , s);       } else {         int l = k - 2;         for (int i = 1; i <= n - l; i++) {           if (i & 1)             s[t++] =  a ;           else             s[t++] =  b ;         }         for (int i = 1; i <= l; i++) {           s[t++] = char( b  + i);         }         s[t] =   0 ;         printf( %s n , s);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.14159265358979323;   const double EPS = 1e-12;   const int N = 1e6 + 5;   const int MOD = 1e9 + 7;   long long int n, m;   long long int dp[2005][2005];   long long int ad(long long int a, long long int b) {     return ((a % MOD + b % MOD) % MOD);   }   long long int go(long long int idx, long long int ct) {     long long int res = 0;     if (ct == m) {       return 1;     }     if (dp[idx][ct] != -1) return dp[idx][ct];     for (int i = idx; i <= n; i += idx) {       res = ad(res, go(i, ct + 1));     }     dp[idx][ct] = res;     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     memset(dp, -1, sizeof(dp));     cin >> n >> m;     cout << go(1, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long u, v;     cin >> u >> v;     if (v - u < 0 || (v - u) % 2) {       cout << -1;       return 0;     }     if (u == 0 && v == 0) {       cout << 0;       return 0;     }     if (v == u) {       cout << 1 <<   n  << v;       return 0;     }     long long x = (v - u) / 2;     if ((x & u) == 0) {       cout << 2 <<   n  << u + x <<     << x;     } else {       cout << 3 <<   n  << u <<     << x <<     << x;     }   }
#include <bits/stdc++.h>   using namespace std;   bool ok1, ok2, ok3, ok4, p1, p2;   int n, m, maxx, minx, maxy, miny;   string a[4002];   int main() {     cin >> n >> m;     minx = miny = 1000000;     maxx = maxy = -1000000;     for (int i = 0; i < n; ++i) {       cin >> a[i];       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  w ) {           if (i > maxx) maxx = i;           if (i < minx) minx = i;           if (j > maxy) maxy = j;           if (j < miny) miny = j;         }       }     }     if (maxx == -1000000) return cout << -1, 0;     ok1 = ok2 = ok3 = ok4 = true;     p1 = p2 = false;     for (int j = 0; j < m; ++j) {       if (a[maxx][j] ==  w  && j != maxy && j != miny) ok1 = false;     }     for (int j = 0; j < m; ++j) {       if (a[minx][j] ==  w  && j != maxy && j != miny) ok2 = false;     }     if (minx == maxx && !ok1) {       ok1 = ok2 = true;       p1 = true;     }     for (int i = 0; i < n; ++i) {       if (a[i][maxy] ==  w  && i != maxx && i != minx) ok3 = false;     }     for (int i = 0; i < n; ++i) {       if (a[i][miny] ==  w  && i != maxx && i != minx) ok4 = false;     }     if (miny == maxy && !ok3) {       ok3 = ok4 = true;       p2 = true;     }     if (maxx - minx > maxy - miny) {       if (ok3) {         int oll = maxx - minx;         int y = maxy;         maxy = miny + oll;         if (maxy >= m && !p2) {           if (!ok4) return cout << -1, 0;           while (maxy >= m) {             maxy--;             miny--;           }           if (miny < 0) return cout << -1, 0;         } else if (maxy >= m) {           miny = y - oll;           maxy = y;           if (miny < 0 || !ok4) return cout << -1, 0;         }       } else if (ok4) {         miny = maxy - maxx + minx;         if (miny < 0) return cout << -1, 0;       } else         return cout << -1, 0;     } else if (maxx - minx < maxy - miny) {       if (ok1) {         int oll = maxy - miny;         int x = maxx;         maxx = minx + oll;         if (maxx >= n && !p1) {           if (!ok2) return cout << -1, 0;           while (maxx >= n) {             maxx--;             minx--;           }           if (minx < 0) return cout << -1, 0;         } else if (maxx >= n) {           minx = x - oll;           maxx = x;           if (minx < 0 || !ok2) return cout << -1, 0;         }       } else if (ok2) {         minx = maxx - maxy + miny;         if (minx < 0) return cout << -1, 0;       } else         return cout << -1, 0;     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  w  && i != minx && i != maxx && j != miny && j != maxy)           return cout << -1, 0;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  w )           cout <<  w ;         else if (((i == minx || i == maxx) && (miny <= j && j <= maxy)) ||                  ((j == miny || j == maxy) && (minx <= i && i <= maxx)))           cout <<  + ;         else           cout <<  . ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   typedef struct Node {     int xi;     int yi;   };   int main() {     int s, n;     scanf( %d%d , &s, &n);     struct Node Q[n];     int i;     for (i = 0; i < n; i++) {       scanf( %d , &Q[i].xi);       scanf( %d , &Q[i].yi);     }     for (i = 0; i < n; i++) {       for (int j = 0; j < n - 1; j++) {         if (Q[j].xi > Q[j + 1].xi) {           int t_xi, t_yi;           t_xi = Q[j].xi;           t_yi = Q[j].yi;           Q[j].xi = Q[j + 1].xi;           Q[j].yi = Q[j + 1].yi;           Q[j + 1].xi = t_xi;           Q[j + 1].yi = t_yi;         }       }     }     for (i = 0; i < n; i++) {       if (Q[i].xi < s) {         s += Q[i].yi;       } else         break;     }     if (i == n) {       printf( YES );     } else       printf( NO );   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 7;   const int inf = 1e9;   const long long inff = 1e18;   const long long mod = 1e9 + 7;   int a[maxn];   vector<int> v[maxn];   vector<int> tmp;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     int _1 = 0, _2 = 0;     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = n; i >= 1; i--) {       if (a[i] == 1) {         v[_1 + 1].push_back(i);         _1++;       } else if (a[i] == 2) {         _2++;         if (_2 > _1) return cout << -1 << endl, 0;         v[_2].push_back(i);       } else if (a[i] == 3) {         if (_2 > 0) {           v[1].push_back(i);         } else {           v[1].push_back(i);           _2++;           if (_2 > _1) return cout << -1 << endl, 0;         }       }     }     int cntt = 1;     vector<pair<int, int> > ans;     for (int i = 1; i <= n; i++) {       reverse((v[i]).begin(), (v[i]).end());       for (int j = 0; j < ((int)(v[i]).size()); j++) {         if (a[v[i][j]] >= 2) {           ans.push_back({cntt, v[i][j]});           ans.push_back({cntt, v[i][j + 1]});           cntt++;         } else {           if (((int)(v[i]).size()) == 1 || a[v[i][j - 1]] == 3) {             ans.push_back({cntt, v[i][j]});             cntt++;           }         }       }     }     cout << ((int)(ans).size()) << endl;     for (pair<int, int> i : ans) cout << i.first <<     << i.second << endl;   }
#include <bits/stdc++.h>   int main() {     long long t, i, x, y, a, b;     scanf( %lld , &t);     for (i = 1; i <= t; i++) {       scanf( %lld%lld%lld%lld , &x, &y, &a, &b);       if ((y - x) % (a + b) == 0)         printf( %lld n , (y - x) / (a + b));       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     long long i, j, n, m;     cin >> n;     long long a[n - 1];     for (int i = 0; i < n - 1; i++) cin >> a[i];     long long dp[n][2][2];     memset(dp, 0, sizeof(dp));     for (int j = 0; j < 2; j++)       for (int k = 0; k < 2; k++) dp[1][j][k] = a[0] - 1;     if (a[0] % 2 == 0)       dp[1][0][0]++, dp[1][1][1]++;     else       dp[1][1][0]++, dp[1][0][1]++;     long long maxi = a[0];     for (int i = 2; i < n; i++) {       long long t = a[i - 1];       if (t % 2 == 0) {         dp[i][0][0] = dp[i - 1][0][0] + t;         dp[i][1][1] =             max(dp[i - 1][1][1], max(dp[i - 1][0][0], dp[i - 1][0][1])) + t;         dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + t - 1;         dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]) + t - 1;       } else if (t == 1) {         dp[i][0][0] = 0;         dp[i][1][1] = 0;         dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + 1;         dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]) + 1;       } else {         dp[i][0][0] = dp[i - 1][0][0] + t - 1;         dp[i][1][1] =             max(dp[i - 1][1][1], max(dp[i - 1][0][0], dp[i - 1][0][1])) + t - 1;         dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + t;         dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]) + t;       }       for (int j = 0; j < 2; j++)         for (int k = 0; k < 2; k++) maxi = max(maxi, dp[i][j][k]);     }     cout << maxi;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s;       cin >> s;       vector<vector<int>> lcp(n, vector<int>(n));       for (int i = n - 1; i >= 0; --i) {         for (int j = n - 1; j >= 0; --j) {           lcp[i][j] =               (s[i] == s[j]                    ? ((i < n - 1 && j < n - 1) ? lcp[i + 1][j + 1] : 0) + 1                    : 0);         }       }       vector<int> dp(n);       for (int i = 0; i < n; ++i) {         dp[i] = n - i;         for (int j = 0; j < i; ++j) {           if (i + lcp[i][j] < n && s[j + lcp[i][j]] < s[i + lcp[i][j]]) {             dp[i] = max(dp[i], dp[j] + (n - lcp[j][i] - i));           }         }       }       cout << *max_element(dp.begin(), dp.end()) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   string dat[64];   int dp[64][64][64][64];   int main(void) {     int n, m, q;     scanf( %d%d%d , &n, &m, &q);     for (int i = (0); i < (int)(n); ++i) cin >> dat[i];     for (int i = (0); i < (int)(n); ++i)       for (int j = (0); j < (int)(m); ++j)         dp[i][j][i][j] = (int)( 1  - dat[i][j]);     for (int i = (0); i < (int)(n); ++i)       for (int j = (0); j < (int)(m); ++j)         for (int k = (i); k < (int)(n); ++k)           for (int l = (j); l < (int)(m); ++l) {             if ((k == i || dp[i][j][k - 1][l] == 1) &&                 (l == j || dp[i][j][k][l - 1] == 1) && dp[k][l][k][l] == 1)               dp[i][j][k][l] = 1;           }     for (int i = (0); i < (int)(n); ++i)       for (int j = (0); j < (int)(m); ++j)         for (int k = (0); k < (int)(n); ++k)           for (int l = (0); l < (int)(m); ++l)             if (k > 0) dp[i][j][k][l] += dp[i][j][k - 1][l];     for (int i = (0); i < (int)(n); ++i)       for (int j = (0); j < (int)(m); ++j)         for (int k = (0); k < (int)(n); ++k)           for (int l = (0); l < (int)(m); ++l)             if (l > 0) dp[i][j][k][l] += dp[i][j][k][l - 1];     for (int i = n - 1; i >= 0; i--)       for (int j = m - 1; j >= 0; j--)         for (int k = (0); k < (int)(n); ++k)           for (int l = (0); l < (int)(m); ++l)             if (i < n - 1) dp[i][j][k][l] += dp[i + 1][j][k][l];     for (int i = n - 1; i >= 0; i--)       for (int j = m - 1; j >= 0; j--)         for (int k = (0); k < (int)(n); ++k)           for (int l = (0); l < (int)(m); ++l)             if (j < m - 1) dp[i][j][k][l] += dp[i][j + 1][k][l];     for (int i = (0); i < (int)(q); ++i) {       int a, b, c, d;       scanf( %d%d%d%d , &a, &b, &c, &d);       printf( %d n , dp[a - 1][b - 1][c - 1][d - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t MAXN = 1000000007;   struct point {     int64_t x = 0;     int64_t y = 0;     point(const int64_t& x, const int64_t& y) : x(x), y(y) {}     static point read() {       int64_t x, y;       cin >> x >> y;       return point(x, y);     }   };   double distance(const int64_t& x1, const int64_t& y1, const int64_t& x2,                   const int64_t& y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   }   signed main() {     int64_t n, k;     cin >> n >> k;     double total = 0.0;     int64_t x1, y1;     int64_t x2, y2;     cin >> x1 >> y1;     while (--n) {       cin >> x2 >> y2;       total += distance(x1, y1, x2, y2);       x1 = x2;       y1 = y2;     }     total = total * k / 50;     printf( %.6f , total);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     os <<  [  ;     for (auto v : V) os << v <<    ;     return os <<  ] ;   }   template <class T>   ostream& operator<<(ostream& os, set<T> second) {     os <<  {  ;     for (auto s : second) os << s <<    ;     return os <<  } ;   }   template <class L, class R>   ostream& operator<<(ostream& os, map<L, R> M) {     os <<  {  ;     for (auto m : M) os <<  (  << m.first <<   :   << m.second <<  )  ;     return os <<  } ;   }   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   | ;     __f(comma + 1, args...);   }   void solve() {     map<int, int> cnt;     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       cnt[x]++;     }     int a = -1;     for (int i = 0; i <= 101; ++i) {       if (cnt[i] == 0) {         cout << i + (a == -1 ? i : a) <<   n ;         return;       } else if (cnt[i] == 1 and a == -1) {         a = i;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T = 1, tc = 1;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)2e5 + 7;   int n, m, q;   set<int> ds[N];   set<int> us[N];   struct T {     int min_d;     int max_u;     bool ok;   };   T operator+(T a, T b) {     int min_d = min(a.min_d, b.min_d);     int max_u = max(a.max_u, b.max_u);     bool ok = a.ok & b.ok & (a.min_d > b.max_u);     return {min_d, max_u, ok};   }   T t[4 * N];   void rec(int v, int tl, int tr, int i) {     if (tr < i || i < tl) {       return;     }     if (tl == tr) {       auto it1 = ds[tl].begin();       t[v].min_d = *it1;       auto it2 = us[tl].end();       it2--;       t[v].max_u = *it2;       t[v].ok = (t[v].min_d > t[v].max_u);       return;     }     int tm = (tl + tr) / 2;     rec(2 * v, tl, tm, i);     rec(2 * v + 1, tm + 1, tr, i);     t[v] = t[2 * v] + t[2 * v + 1];   }   void ins(int r, int c) {     int x = (r + 1) / 2, y = (c + 1) / 2;     if (r % 2 == 1) {       ds[x].insert(y);     } else {       us[x].insert(y);     }     rec(1, 1, n, x);   }   void del(int r, int c) {     int x = (r + 1) / 2, y = (c + 1) / 2;     if (r % 2 == 1) {       ds[x].erase(y);     } else {       us[x].erase(y);     }     rec(1, 1, n, x);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) {       ds[i].insert((int)1e9);       us[i].insert(-(int)1e9);       rec(1, 1, n, i);     }     set<pair<int, int>> s;     for (int i = 1; i <= q; i++) {       int r, c;       cin >> r >> c;       if (s.count({r, c}) == 0) {         ins(r, c);         s.insert({r, c});       } else {         del(r, c);         s.erase({r, c});       }       if (t[1].ok) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, K, dp[505][505];   char g[505][505];   bool check(int r, int c) {     int dx[] = {-1, 1, 0, 0};     int dy[] = {0, 0, -1, 1};     if (r < 0 || c < 0) return false;     if (g[r][c] ==  0 ) return false;     for (int i = 0; i < 4; ++i) {       int nextR = r + dx[i];       int nextC = c + dy[i];       if (nextR < 0 || nextC < 0) return false;       if (g[nextR][nextC] ==  0 ) return false;     }     return true;   }   int cntStars(int r1, int c1, int r2, int c2) {     return dp[r2][c2] - dp[r1 + 1][c2] - dp[r2][c1 + 1] + dp[r1 + 1][c1 + 1];   }   int main() {     scanf( %d %d %d , &N, &M, &K);     for (int i = 0; i < N; ++i) scanf( %s , &g[i]);     for (int i = 0; i < N; ++i) {       for (int j = 0; j < M; ++j) {         dp[i + 1][j + 1] =             dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + check(i - 1, j - 1);       }     }     long long res = 0;     for (int r2 = 3; r2 <= N; ++r2) {       for (int c2 = 3; c2 <= M; ++c2) {         int c1 = c2 - 2;         for (int r1 = 1; r1 < r2 - 1; ++r1) {           while (c1 >= 1 && cntStars(r1, c1, r2, c2) < K) --c1;           if (c1 >= 1 && cntStars(r1, c1, r2, c2) >= K) res += c1;         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INFI = 2000000000;   const int goX[4] = {-1, 0, 1, 0};   const int goY[4] = {0, 1, 0, -1};   const string PROBLEM_NAME =  test ;   const string INPUT_FILE = PROBLEM_NAME +  .in ;   const string OUTPUT_FILE = PROBLEM_NAME +  .out ;   ofstream fout(OUTPUT_FILE.c_str());   ifstream fin(INPUT_FILE.c_str());   void read_input() {}   long long a, b, c, d, e, f;   string solve() {     if (c == 0 && d > 0) return  Ron ;     if (a == 0 && b > 0 && d > 0) return  Ron ;     if (b == 0 || d == 0 || f == 0) return  Hermione ;     if (a == 0 || c == 0 || e == 0) return  Ron ;     return (a * c * e < b * d * f) ?  Ron  :  Hermione ;   }   void m_main() {     cin >> a >> b >> c >> d >> e >> f;     cout << solve() << endl;   }   int main() {     read_input();     m_main();     return 0;   }