malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int f[1005][1005];   int main() {     int k;     scanf( %d , &k);     int w[39], cnt = 0;     while (k) {       w[cnt++] = k % 2;       k /= 2;     }     f[1][3] = f[3][1] = 1;     int now = 3;     for (int i = 1; i < cnt; i++) {       f[now][now + 1] = f[now + 1][now] = 1;       f[now][now + 2] = f[now + 2][now] = 1;       f[now + 1][now + 3] = f[now + 3][now + 1] = 1;       f[now + 2][now + 3] = f[now + 3][now + 2] = 1;       now += 3;     }     int tmp = now + 1;     f[now][2] = f[2][now] = 1;     for (int i = 0; i < (cnt - 2) * 2; i++) {       f[tmp][tmp + 1] = f[tmp + 1][tmp] = 1;       tmp++;     }     f[tmp][now] = f[now][tmp] = 1;     int pos = now + 1;     now = tmp;     int t = 1;     for (int i = 0; i < cnt; i++) {       if (w[i] == 1) {         f[t * 3][pos] = f[pos][t * 3] = 1;       }       t++;       pos += 2;     }     printf( %d n , now);     for (int i = 1; i <= now; i++) {       for (int j = 1; j <= now; j++)         if (f[i][j])           printf( Y );         else           printf( N );       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int heap(int a, int t) {     int tmp;     if (a > t) swap(a, t);     if (t % a == 0) return a;     return heap(a, t % a);   }   int main() {     string x, y;     cin >> x >> y;     bool f = true;     for (int i = 0; i < x.size(); i++) {       if (x[i] != y[x.size() - 1 - i]) f = false;     }     if (f)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, q, l;   int A[N], sum[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , A + i);       sum[i] = sum[i - 1] + A[i];     }     scanf( %d , &q);     while (q--) {       scanf( %d , &l);       printf( %d n , lower_bound(sum, sum + n + 1, l) - sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 3e5 + 5;   long long a[maxn], ps[maxn], mark[maxn];   set<pair<long long, long long> > st;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n, k;     cin >> n >> k;     for (long long i = 1; i <= n; i++) cin >> a[i];     ps[n] = a[n];     st.insert(pair<long long, long long>(ps[n], n));     for (long long i = n - 1; i >= 1; i--) {       ps[i] = ps[i + 1] + a[i];       if (i == 1) continue;       st.insert(pair<long long, long long>(ps[i], i));     }     for (long long i = 1; i < k; i++) {       pair<long long, long long> p = *st.rbegin();       mark[p.second]++;       st.erase(p);     }     long long c = 1, ans = 0;     for (long long i = 1; i <= n; i++) {       if (mark[i]) {         c++;       }       ans += c * a[i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200010;   char A[MAXN];   char B[MAXN];   int n;   void open() {     freopen( B.in ,  r , stdin);     freopen( B.out ,  w , stdout);   }   void close() {     fclose(stdin);     fclose(stdout);   }   void init() {     scanf( %s , A + 1);     scanf( %s , B + 1);   }   bool equal(int l1, int r1, int l2, int r2) {     int flag = 1;     for (int i = 0, END = r1 - l1; i <= END; i++)       if (A[i + l1] != B[i + l2]) {         flag = 0;         break;       }     if (flag)       return true;     else if ((r1 - l1 + 1) & 1)       return false;     int mid1 = (l1 + r1) / 2, mid2 = (l2 + r2) / 2;     if (equal(l1, mid1, l2, mid2)) {       if (equal(mid1 + 1, r1, mid2 + 1, r2)) return true;     }     if (equal(mid1 + 1, r1, l2, mid2)) {       if (equal(l1, mid1, mid2 + 1, r2)) return true;     }   }   int main() {     init();     int n1 = strlen(A + 1), n2 = strlen(B + 1);     if (n1 != n2) {       printf( NO n );     } else {       if (equal(1, n1, 1, n2))         printf( YES n );       else         printf( NO n );     }     close();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y;     int num;     int mark;   };   point p[100010];   int ans[100010];   point pt;   int sum1, sum2;   bool cmp(point a, point b) {     return (a.x - pt.x) * (b.y - pt.y) - (a.y - pt.y) * (b.x - pt.x) < 0;   }   bool cmp2(point a, point b) { return a.y != b.y ? a.y < b.y : a.x < b.x; }   void work(int l, int r) {     if (r < l) return;     int maxi = 0;     int marki = 0;     maxi = min_element(p + l, p + r + 1, cmp2) - p;     swap(p[maxi], p[l]);     pt = p[l];     int k;     sort(p + l + 1, p + r + 1, cmp);     sum1 = sum2 = 0;     for (k = r; !(pt.mark != p[k].mark && sum1 == sum2); k--)       if (p[k].mark == pt.mark)         sum1++;       else         sum2++;     marki = k;     if (pt.mark)       ans[p[k].num] = pt.num;     else       ans[pt.num] = p[k].num;     work(l + 1, marki - 1);     work(marki + 1, r);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = (1); i <= (2 * n); ++i) {       cin >> p[i].x >> p[i].y;       p[i].mark = (i > n);       p[i].num = i > n ? i - n : i;     }     work(1, 2 * n);     for (int i = (1); i <= (n); ++i) {       cout << ans[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<vector<pair<int, int>>> g;   vector<int> p;   vector<bool> was;   vector<int> sz;   long long res;   void calcSz(int v, int par = -1) {     sz[v] = 1;     for (int i = 0; i < (int)g[v].size(); ++i) {       int to = g[v][i].first;       if (to != par && !was[to]) {         calcSz(to, v);         sz[v] += sz[to];       }     }   }   int findCentroid(int v, int n, int par = -1) {     for (int i = 0; i < (int)g[v].size(); ++i) {       int to = g[v][i].first;       if (to != par && !was[to] && 2 * sz[to] > n) {         return findCentroid(to, n, v);       }     }     return v;   }   int getInc(int v, int edge, int par = -1) {     int res = 1;     for (int i = 0; i < (int)g[v].size(); ++i) {       int to = g[v][i].first;       if (to != par && !was[to] && g[v][i].second >= edge) {         res += getInc(to, g[v][i].second, v);       }     }     return res;   }   int getDec(int v, int edge, int par = -1) {     int res = 1;     for (int i = 0; i < (int)g[v].size(); ++i) {       int to = g[v][i].first;       if (to != par && !was[to] && g[v][i].second <= edge) {         res += getDec(to, g[v][i].second, v);       }     }     return res;   }   int build(int v) {     calcSz(v);     v = findCentroid(v, sz[v]);     was[v] = true;     int inc0 = 0;     int inc1 = 0;     int dec0 = 0;     int dec1 = 0;     for (int i = 0; i < (int)g[v].size(); ++i) {       int to = g[v][i].first;       if (!was[to]) {         int inc = getInc(to, g[v][i].second, v);         int dec = getDec(to, g[v][i].second, v);         if (g[v][i].second == 0) {           res += inc * 1ll * (dec0 + 1);           res += dec * 1ll * (inc0 + inc1 + 1);           inc0 += inc;           dec0 += dec;         } else {           res += inc * 1ll * (dec0 + dec1 + 1);           res += dec * 1ll * (inc1 + 1);           inc1 += inc;           dec1 += dec;         }       }     }     for (int i = 0; i < (int)g[v].size(); ++i) {       int to = g[v][i].first;       if (!was[to]) {         p[build(to)] = v;       }     }     return v;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     g.resize(n);     p.resize(n);     was.resize(n);     sz.resize(n);     for (int i = 0; i < n - 1; ++i) {       int a, b, c;       cin >> a >> b >> c;       --a;       --b;       g[a].push_back({b, c});       g[b].push_back({a, c});     }     build(0);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> arr[100];   int res[100];   int main() {     int N, W;     scanf( %d%d , &N, &W);     for (int i = 0; i < N; i++) {       scanf( %d , &arr[i].first);       arr[i].second = i;     }     sort(arr, arr + N);     for (int i = 0; i < N; i++) {       if (W < (arr[i].first + 1) / 2) {         printf( -1 n );         return 0;       }       W -= (arr[i].first + 1) / 2;       res[arr[i].second] = (arr[i].first + 1) / 2;     }     int p = N - 1;     while (W > 0) {       int delta = min(W, arr[p].first - res[arr[p].second]);       W -= delta;       res[arr[p].second] += delta;       p--;     }     for (int i = 0; i < N; i++) printf( %d  , res[i]);     putchar(  n );   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 10000000;   const int MAX = 150;   string s;   int found(string aux) {     int ans = 0;     int cnt = 0;     for (int i = 0; i < s.size(); i++) {       for (int j = 0, k = i; j < aux.size(); j++, k++) {         if (k == s.size()) break;         if (aux[j] == s[k])           cnt++;         else {           cnt = 0;           break;         }       }       if (cnt == aux.size()) ans++;     }     return ans;   }   int main() {     cin >> s;     int ans = 0;     ans += found( Danil );     ans += found( Olya );     ans += found( Slava );     ans += found( Ann );     ans += found( Nikita );     if (ans == 1)       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<long long, long long> a[1000005];   bool fl1, fl2, fl3, fl4;   long long dist(pair<long long, long long> a, pair<long long, long long> b) {     return abs(a.first - b.first) + abs(a.second - b.second);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long i, j, k, l, m, n, t, r, cnt;     long long flag = 0;     long long an = 0, ans = 0;     t = 1;     while (t--) {       cin >> n;       long long x, y;       for (i = 0; i < n; i++) {         cin >> x >> y;         a[i] = make_pair(x, y);       }       long long xmi, xma, yma, ymi;       xmi = 1LL * 1e18;       ymi = 1LL * 1e18;       yma = -1LL * 1e18;       xma = -1LL * 1e18;       for (i = 0; i < n; i++) {         xmi = min(xmi, a[i].first);         xma = max(xma, a[i].first);         ymi = min(ymi, a[i].second);         yma = max(yma, a[i].second);       }       ans = 2LL * (xma - xmi + yma - ymi);       vector<pair<long long, long long> > b;       for (i = 0; i < n; i++) {         if (a[i].first == xmi && !fl1) {           fl1 = true;           b.push_back(a[i]);         }         if (a[i].first == xma && !fl2) {           fl2 = true;           b.push_back(a[i]);         }         if (a[i].second == ymi && !fl3) {           fl3 = true;           b.push_back(a[i]);         }         if (a[i].second == yma && !fl4) {           fl4 = true;           b.push_back(a[i]);         }       }       b.push_back(make_pair(xmi, ymi));       b.push_back(make_pair(xmi, yma));       b.push_back(make_pair(xma, yma));       b.push_back(make_pair(xma, ymi));       an = -1LL * 1e18;       for (i = 0; i < n; i++) {         for (j = 0; j < 4; j++) {           for (k = 0; k < 4; k++) {             if (b[j] == a[i] || b[k] == a[i]) continue;             an = max(an, dist(a[i], b[j]) + dist(b[k], a[i]) + dist(b[j], b[k]));           }         }       }       cout << an <<    ;       for (i = 4; i <= n; i++) {         cout << ans <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char arr[1503][1503];   int inix, iniy;   bool visit[4503][4504];   int X[] = {0, 0, 1, -1};   int Y[] = {1, -1, 0, 0};   int nn, mm;   int colax[4503 * 4503];   int colay[4503 * 4503];   bool dentro(int a, int b) {     if (a < 0 || b < 0 || a >= nn || b >= mm) return false;     return true;   }   inline void bfs(int x, int y) {     visit[x][y] = true;     int xx, yy;     int q = 0;     colax[q] = x;     colay[q++] = y;     for (int j = 0; j < q; j++) {       x = colax[j];       y = colay[j];       for (int i = 0; i < 4; i++) {         xx = x + X[i];         yy = y + Y[i];         if (!visit[(xx + nn) % nn][(yy + mm) % mm] &&             arr[(xx + n) % n][(yy + m) % m] !=  # ) {           visit[(xx + nn) % nn][(yy + mm) % mm] = true;           colax[q] = (xx + nn) % nn;           colay[q++] = (yy + mm) % mm;         }       }     }   }   int main() {     scanf( %d %d , &n, &m);     nn = n * 3;     mm = m * 3;     for (int i = 0; i < n; i++) scanf( %s , arr[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (arr[i][j] ==  S ) {           inix = i, iniy = j;         };     iniy += m;     inix += n;     bfs(inix, iniy);     for (int i = -1; i < 2; i++)       for (int j = -1; j < 2; j++) {         if (i == j && i == 0) continue;         if (visit[inix + i * n][iniy + j * m]) {           cout <<  Yes  << endl;           return 0;         }       }     cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, w, a[105], cnt1 = 0, cnt = 0, b[105], c[105], e[105], colour[105];     memset(colour, 0, sizeof colour);     scanf( %d%d , &n, &w);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       c[i] = a[i];       cnt1 = a[i] / 2;       if (a[i] % 2 == 1) cnt1++;       b[i] = cnt1;       cnt += cnt1;     }     if (cnt > w) {       printf( -1 n );       return 0;     }     if (w > cnt) {       int dif = w - cnt;       sort(c + 1, c + n + 1);       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           if (c[i] == a[j] && colour[j] == 0) {             e[i] = j;             colour[j] = 1;             break;           }         }       }       int d = n;       while (d > 0) {         if (c[d] % 2 == 1) {           int k = c[d] / 2 + 1;           int diff = c[d] - k;           if (dif > diff) {             dif -= diff;             b[e[d]] += diff;           } else             b[e[d]] += dif, dif = 0;         } else {           int k = c[d] / 2;           int diff = c[d] - k;           if (dif > diff) {             dif -= diff;             b[e[d]] += diff;           } else             b[e[d]] += dif, dif = 0;         }         if (dif == 0) break;         d--;       }       if (dif > 0) {         printf( -1 n );         return 0;       }       for (int i = 1; i <= n; i++) printf( %d  , b[i]);     } else if (cnt == w) {       for (int i = 1; i <= n; i++) printf( %d  , b[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   template <typename T>   inline void read(T &AKNOI) {     T x = 0, flag = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) flag = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     AKNOI = flag * x;   }   template <typename T>   inline void cmin(T &x, T y) {     if (y < x) x = y;   }   template <typename T>   inline void cmax(T &x, T y) {     if (x < y) x = y;   }   char s[MAXN], t[MAXN];   int n, m, k[MAXN], len[MAXN];   int tot, ch[MAXN][26], fail[MAXN], ed[MAXN], ff[MAXN];   int q[MAXN], head, tail;   vector<int> mtch[MAXN];   void Insert(int id) {     int p = 0, l = len[id] = strlen(t + 1);     for (int i = 1; i <= l; ++i) {       int x = t[i] -  a ;       if (!ch[p][x]) {         ch[p][x] = ++tot;       }       p = ch[p][x];     }     ed[p] = id;   }   void GetFail() {     head = 1, tail = 0;     for (int i = 0; i < 26; ++i) {       if (ch[0][i]) {         q[++tail] = ch[0][i];       }     }     while (head <= tail) {       int u = q[head++];       for (int i = 0; i < 26; ++i) {         if (ch[u][i]) {           int v = ch[u][i];           fail[v] = ch[fail[u]][i];           ff[v] = (ed[fail[v]] ? fail[v] : ff[fail[v]]);           q[++tail] = v;         } else {           ch[u][i] = ch[fail[u]][i];         }       }     }   }   void Run() {     int p = 0;     for (int i = 1; i <= n; ++i) {       p = ch[p][s[i] -  a ];       int u = (ed[p] ? p : ff[p]);       for (; u; u = ff[u]) {         mtch[ed[u]].push_back(i);       }     }   }   void init() {     scanf( %s , s + 1);     n = strlen(s + 1);     read(m);     for (int i = 1; i <= m; ++i) {       read(k[i]);       scanf( %s , t + 1);       Insert(i);     }     GetFail();   }   void solve() {     Run();     for (int i = 1; i <= m; ++i) {       if (mtch[i].size() < k[i]) {         printf( -1 n );       } else {         int ans = n + 1;         for (int j = 0, sz = mtch[i].size(); j + k[i] - 1 < sz; ++j) {           cmin(ans, mtch[i][j + k[i] - 1] - mtch[i][j]);         }         printf( %d n , ans + len[i]);       }     }   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXINT = 1073741823;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t, n, a, b, x;     bool win;     cin >> t;     for (int q = 0; q < t; q++) {       cin >> n >> a >> b;       win = false;       for (int i = 0; i < a; i++) {         cin >> x;         if (x == n) win = true;       }       for (int i = 0; i < b; i++) cin >> x;       cout << (win ?  YES  :  NO ) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const char elem[][4] = {        H ,   He ,  Li ,  Be ,  B ,    C ,   N ,    O ,   F ,    Ne ,   Na ,  Mg ,        Al ,  Si ,  P ,   S ,   Cl ,   Ar ,  K ,    Ca ,  Sc ,   Ti ,   V ,   Cr ,        Mn ,  Fe ,  Co ,  Ni ,  Cu ,   Zn ,  Ga ,   Ge ,  As ,   Se ,   Br ,  Kr ,        Rb ,  Sr ,  Y ,   Zr ,  Nb ,   Mo ,  Tc ,   Ru ,  Rh ,   Pd ,   Ag ,  Cd ,        In ,  Sn ,  Sb ,  Te ,  I ,    Xe ,  Cs ,   Ba ,  La ,   Ce ,   Pr ,  Nd ,        Pm ,  Sm ,  Eu ,  Gd ,  Tb ,   Dy ,  Ho ,   Er ,  Tm ,   Yb ,   Lu ,  Hf ,        Ta ,  W ,   Re ,  Os ,  Ir ,   Pt ,  Au ,   Hg ,  Tl ,   Pb ,   Bi ,  Po ,        At ,  Rn ,  Fr ,  Ra ,  Ac ,   Th ,  Pa ,   U ,   Np ,   Pu ,   Am ,  Cm ,        Bk ,  Cf ,  Es ,  Fm ,  Md ,   No ,  Lr ,   Rf ,  Db ,   Sg ,   Bh ,  Hs ,        Mt ,  Ds ,  Rg ,  Cn ,  Uut ,  Fl ,  Uup ,  Lv ,  Uus ,  Uuo ,   };   const int MAXN = 18;   string ele;   vector<int> can[110];   map<string, int> ele_map;   int n, m, max_v, vec[MAXN], tar[MAXN], dp[1 << MAXN][MAXN],       pre[1 << MAXN][MAXN];   int main() {     ele_map.clear();     for (int i = 1; i <= 100; ++i) ele_map[elem[i - 1]] = i;     while (cin >> n >> m) {       for (int i = 0; i < n; ++i) {         cin >> ele;         vec[i] = ele_map[ele];       }       max_v = 0;       for (int i = 0; i < m; ++i) {         cin >> ele;         tar[i] = ele_map[ele];         max_v = max(max_v, tar[i]);       }       for (int i = 0; i <= max_v; ++i) can[i].clear();       for (int mask = 0; mask < (1 << n); ++mask) {         int sum = 0;         for (int i = 0; i < n; ++i) {           if (mask & (1 << i)) sum += vec[i];         }         if (sum <= max_v) can[sum].push_back(mask);       }       memset(dp, 0, sizeof(dp));       dp[0][0] = 1;       for (int mask = 0; mask < (1 << n); ++mask) {         for (int i = 0; i < m; ++i) {           if (dp[mask][i]) {             int v = tar[i];             for (int j = 0; j < can[v].size(); ++j) {               int nmask = can[v][j];               if ((mask & nmask) == 0) {                 dp[mask | nmask][i + 1] = 1;                 pre[mask | nmask][i + 1] = mask;               }             }           }         }       }       int mask = (1 << n) - 1;       if (dp[mask][m] == 0) {         puts( NO );       } else {         puts( YES );         for (int i = m; i > 0; --i) {           vector<int> add;           int nmask = mask ^ pre[mask][i];           for (int j = 0; j < n; ++j) {             if (nmask & (1 << j)) add.push_back(j);           }           for (int j = 0; j < add.size(); ++j) {             if (j) putchar( + );             printf( %s , elem[vec[add[j]] - 1]);           }           printf( ->%s n , elem[tar[i - 1] - 1]);           mask = pre[mask][i];         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100005;   int N;   bool vis[MAX];   vector<pair<int, bool> > neigh[MAX];   bool islucky(int a) {     while (a > 0) {       if (a % 10 != 4 and a % 10 != 7) return false;       a /= 10;     }     return true;   }   long long p3(long long N) { return (N) * (N - 1) * (N - 2); }   long long solve(int a) {     vector<int> q;     int qnum = 0;     q.push_back(a);     while (qnum < q.size()) {       int cur = q[qnum];       vis[cur] = true;       for (int i = 0; i < neigh[cur].size(); i++) {         if (neigh[cur][i].second) continue;         int cneigh = neigh[cur][i].first;         if (vis[cneigh]) continue;         q.push_back(cneigh);       }       qnum++;     }     long long sz = q.size();     return (2 * (sz) * (sz - 1) * ((long long)N - sz) + p3(sz));   }   int main() {     cin >> N;     for (int i = 0; i < N - 1; i++) {       int a, b, c;       cin >> a >> b >> c;       a--;       b--;       bool il = islucky(c);       neigh[a].push_back(pair<int, bool>(b, il));       neigh[b].push_back(pair<int, bool>(a, il));     }     long long ans = p3(N);     for (int i = 0; i < MAX; i++) vis[i] = false;     for (int i = 0; i < N; i++) {       if (vis[i]) continue;       ans -= solve(i);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, l, r, ql, qr;   int w[100010];   int main() {     cin >> n >> l >> r >> ql >> qr;     for (int i = 1; i <= n; ++i) cin >> w[i];     int f[100010];     f[0] = 0;     for (int i = 1; i <= n; ++i) f[i] = f[i - 1] + w[i];     int ans = INT_MAX;     for (int i = 0; i <= n; ++i) {       int v = f[i] * l + (f[n] - f[i]) * r;       if (i < n / 2)         v += qr * max(0, (n - 2 * i - 1));       else         v += ql * max(0, (2 * i - n - 1));       ans = min(ans, v);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int m, k = 1, i;     for (i = 0; i < s.size(); i++) {       m = int(s[i]) - 96;       if (m == k)         k++;       else if (m > k) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, x, y, a[179000];   int main() {     for (cin >> n >> x >> y, i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) {       for (j = max(1, i - x); j <= min(n, i + y); j++)         if (i != j && a[j] <= a[i]) break;       if (j > min(n, i + y)) break;     }     cout << i;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     double arr[n];     double temp = 0;     for (int i = 0; i < n; i++) {       cin >> temp;       arr[i] = temp;     }     long long sum = 0;     double fractpart, intpart;     int arr2[n];     for (int i = 0; i < n; i++) {       arr2[i] = ((int)floor(arr[i]));       sum += arr2[i];     }     int count = -sum;     int total = 0, index = 0;     while (count != 0) {       if (arr[index] - floor(arr[index]) < 0.000001) {         index++;         continue;       }       count--;       arr2[index]++;       index++;     }     for (int i = 0; i < n; i++) {       cout << arr2[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   string A, B;   int a[N], b[N];   int main() {     while (cin >> A >> B) {       int len1 = A.size(), len2 = B.size();       for (int i = 0; i <= len1 - 1; i++) a[i] = A[i] -  0 ;       for (int i = 0; i <= len2 - 1; i++) b[i] = B[i] -  0 ;       int sum = 0;       for (int i = 0; i <= len2 - 1; i++) sum ^= (a[i] ^ b[i]);       int ans = sum == 0;       for (int i = 1; i <= len1 - len2; i++) {         sum ^= a[i - 1];         sum ^= a[i - 1 + len2];         ans += sum == 0;       }       printf( %d n , ans);     }     return 0;   }