malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   struct Edge {     int u, v;     int w;   };   struct RowEdges {     int sum;     std::vector<Edge> vs;     RowEdges() : sum(0) {}     Edge &back() { return vs.back(); }     Edge &front() { return vs.front(); }     Edge &operator[](int i) { return vs[i]; }     int size() { return (int)vs.size(); }     void pop_back() { vs.pop_back(); }     void push_back(Edge ae) { vs.push_back(ae); }     bool operator<(RowEdges ot) const { return sum < ot.sum; }   };   struct Graph {     Graph(int n) : ves(n), vals(nullptr) {}     ~Graph() {       if (vals) {         delete[] vals;         vals = nullptr;       }     }     void addTwoEdge(int a, int b, int awei = 0, int bwei = 0) {       int minWei = std::min(awei, bwei);       addEdge(a, b, minWei);       addEdge(b, a, minWei);     }     void removeTwoEdge(int a, int b) {       removeEdge(a, b);       removeEdge(b, a);     }     void removeEdge(int a, int b) {       auto &tv = ves[a];       for (int i = 0; i < (int)tv.size(); i++) {         if (tv[i].v == b) {           tv.sum -= std::min(vals[a], vals[b]);           tv[i] = tv.back();           tv.pop_back();           break;         }       }     }     void addEdge(int a, int b, int addWeight = 0) {       ves[a].push_back(Edge());       auto &bn = ves[a].back();       bn.u = a, bn.v = b;       ves[a].sum += addWeight;     }     void sort(int off = 0) {       std::sort(ves.begin() + off, ves.end());       std::vector<int> oldToNewId(ves.size());       std::vector<int> newToOldId(ves.size());       for (size_t i = off; i < ves.size(); i++) {         if (ves[i].size()) {           oldToNewId[ves[i].front().u] = i;           newToOldId[i] = ves[i].front().u;         }       }       for (size_t i = off; i < ves.size(); i++) {         for (int j = 0; j < ves[i].size(); j++) {           ves[i][j].u = oldToNewId[ves[i][j].u];           ves[i][j].v = oldToNewId[ves[i][j].v];         }       }       int n = ves.size();       int *varr = new int[n];       memcpy(varr, vals, n * sizeof(int));       for (int i = off; i < n; i++) {         int j = newToOldId[i];         vals[i] = varr[j];       }       delete[] varr;     }     int getAns() {       int ans = 0;       for (size_t i = 1; i < ves.size(); i++) {         sort(i);         if (ves[i].size()) {           ans += ves[i].sum;           while (ves[i].size()) {             removeTwoEdge(i, ves[i].front().v);           }         }       }       return ans;     }     std::vector<RowEdges> ves;     int *vals;   };   int main() {     int n = 0, m = 0, n1 = 0;     scanf( %d %d , &n, &m);     n1 = n + 1;     int *v = new int[n1];     v[0] = 0;     for (int i = 1; i < n1; i++) {       scanf( %d , v + i);     }     Graph g(n1);     g.vals = v;     int a = 0, b = 0;     for (int i = 0; i < m; i++) {       scanf( %d %d , &a, &b);       g.addTwoEdge(a, b, v[a], v[b]);     }     printf( %d , g.getAns());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     vector<pair<long long, long long>> ar(4);     for (long long i = 1; i <= 3; i++) {       long long a, b;       cin >> a >> b;       ar[i] = {a, b};     }     sort(ar.begin() + 1, ar.end());     set<pair<long long, long long>> ans;     for (long long i = ar[1].first; i <= ar[2].first; i++) {       ans.insert({i, ar[1].second});     }     long long dy = 1;     if (ar[2].second < ar[1].second) dy = -1;     for (long long i = ar[1].second; i != ar[2].second; i += dy) {       ans.insert({ar[2].first, i});     }     ans.insert({ar[2].first, ar[2].second});     long long low = ar[1].second, high = ar[2].second;     long long temp = min(high, low);     high = max(high, low);     low = temp;     if (ar[3].second >= low && ar[3].second <= high) {       for (long long i = ar[3].first; i >= ar[2].first; i--) {         ans.insert({i, ar[3].second});       }     } else if (ar[3].second > high) {       for (long long i = ar[3].first; i >= ar[2].first; i--) {         ans.insert({i, ar[3].second});       }       for (long long i = ar[3].second; i > high; i--) {         ans.insert({ar[2].first, i});       }     } else {       for (long long i = ar[3].first; i >= ar[2].first; i--) {         ans.insert({i, ar[3].second});       }       for (long long i = ar[3].second; i < low; i++) {         ans.insert({ar[2].first, i});       }     }     cout << signed(ans.size()) <<   n ;     for (auto i : ans) cout << i.first <<     << i.second <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   long long a[2001], b[2001], n, m, x, sa[2001], sb[2001], ans;   long long max(long long a, long long b) { return a > b ? a : b; }   long long min(long long a, long long b) { return a < b ? a : b; }   int main() {     std::cin >> n >> m;     for (int i = 1; i <= n; i++)       std::cin >> a[i], a[i] += a[i - 1], sa[i] = 100000000000;     for (int i = 1; i <= m; i++)       std::cin >> b[i], b[i] += b[i - 1], sb[i] = 100000000000;     std::cin >> x;     for (int i = 1; i <= n; i++)       for (int j = i; j <= n; j++)         sa[j - i + 1] = min(sa[j - i + 1], a[j] - a[i - 1]);     for (int i = 1; i <= m; i++)       for (int j = i; j <= m; j++)         sb[j - i + 1] = min(sb[j - i + 1], b[j] - b[i - 1]);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (sa[i] * sb[j] <= x) ans = max(ans, i * j);     std::cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   char mp[1000];   int main() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     for (int i = 0; i < n; i++) {       mp[s[i] -  a ]++;       if (mp[s[i] -  a ] > k) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int nex = 2e5 + 5;   void solve() {     int a, b;     cin >> a >> b;     string s;     cin >> s;     int cnt = 0;     vector<int> v;     for (int i = 0; i < ((int)s.size()); i++) {       if (s[i] ==  X ) {         if (cnt) v.push_back(cnt);         cnt = 0;       } else {         cnt++;       }     }     if (cnt) v.push_back(cnt);     cnt = 0;     int val = 0;     for (int x : v) {       if (x < a && x >= b) {         cout <<  NO n ;         return;       }       if (x >= a && x < 2 * b)         cnt++;       else if (x >= 2 * b) {         if (val) {           cout <<  NO n ;           return;         }         val = x;       }     }     cnt = cnt;     for (int i = 0; i <= (val - a); i++) {       int x = i, y = val - a - i, lcnt = cnt;       if (x < 2 * b && y < 2 * b) {         if (x < a && x >= b) continue;         if (y < a && y >= b) continue;         if (y >= a) lcnt++;         if (x >= a) lcnt++;         if (lcnt % 2 == 0) {           cout <<  YES n ;           return;         }       }     }     if (val == 0) {       if (cnt % 2)         cout <<  YES n ;       else         cout <<  NO n ;       return;     }     cout <<  NO n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     cout << fixed << setprecision(11);     clock_t beg = clock();     int t = 1, n;     cin >> t;     while (t--) {       solve();     }     clock_t end = clock();     fprintf(stderr,  %lf sec n , (double)(end - beg) / (CLOCKS_PER_SEC));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, n;     int s = 0;     cin >> a >> b >> c >> d >> n;     for (int i = 1; i <= n; i++) {       if (i % a && i % b && i % c && i % d) {         s++;       }     }     cout << n - s;   }
#include <bits/stdc++.h>   using namespace std;   int gr[1005][1005], n, m, a[1005], x, y;   long long g[1005];   bool vis[1005];   int main() {     scanf( %d , &n), scanf( %d , &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int mi = 100000100, l1 = 0;     int ans = 0;     for (int i = 0; i < m; i++) {       scanf( %d , &x), scanf( %d , &y);       ans += min(a[x], a[y]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct _ {     _() { ios_base::sync_with_stdio(0); }   } _;   template <class A, class B>   ostream &operator<<(ostream &o, pair<A, B> t) {     o <<  (  << t.first <<  ,   << t.second <<  ) ;     return o;   }   template <class T>   string tostring(T first, int len = 0, char c =  0 ) {     stringstream ss;     ss << first;     string r = ss.str();     if (r.length() < len) r = string(len - r.length(), c) + r;     return r;   }   template <class T>   void PV(T a, T b, int n = 0, int w = 0, string s =    ) {     int c = 0;     while (a != b) {       cout << tostring(*a++, w,    );       if (a != b && (n == 0 || ++c % n))         cout << s;       else         cout << endl;     }   }   template <class T>   inline bool chmin(T &a, T b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   inline bool chmax(T &a, T b) {     return a < b ? a = b, 1 : 0;   }   const long long linf = 0x3f3f3f3f3f3f3f3fLL;   const int inf = 0x3f3f3f3f;   const int mod = int(1e9) + 7;   const int N = 111111;   vector<int> f(int n) {     vector<int> r;     if (n == 1) {       r.push_back(1);       return r;     }     if (n == 2) {       r.push_back(3);       r.push_back(4);       return r;     }     for (int i = 0; i < n - 1; i++) r.push_back(2);     r.push_back(n - 2);     return r;   }   int main() {     int n, m;     cin >> n >> m;     vector<int> A = f(n);     vector<int> B = f(m);     for (int i : A) {       for (int j : B) cout << i * j <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,inline,unroll-loops,fast-math )   #pragma GCC target( popcnt,abm,mmx,tune=native )   using namespace std;   long long n, i, j;   int main() {     [=]() {       ios_base ::sync_with_stdio(false);       cin.tie(nullptr);     }();     cin >> n;     for (; i < n; i++) {       for (j ^= j; j < n; j++) cout <<  WB [(i + j) % 2];       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int cnt[2];   int main() {     int n, k, m;     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &m);       cnt[m % 2]++;     }     int r = n - k;     if (r == 0) {       if (cnt[1] % 2 == 1)         puts( Stannis );       else         puts( Daenerys );       return 0;     }     int sec = r / 2;     int fst = r - sec;     if (fst >= cnt[0] && k % 2 == 1) {       puts( Stannis );       return 0;     }     if (sec >= cnt[1]) {       puts( Daenerys );       return 0;     }     if (sec >= cnt[0] && k % 2 == 0) {       puts( Daenerys );       return 0;     }     if (r % 2 == 0) {       puts( Daenerys );       return 0;     }     puts( Stannis );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int sz = 317;   int t[100002], a[100002];   int l[100002], r[100002];   long long sum[2][100002];   long long ans[100002];   struct node {     int b, r, i;   };   bool cmp(node a, node b) {     if (a.b != b.b) return a.b < b.b;     return a.r < b.r;   }   int n, k, q;   long long res = 0;   node block[100002];   int val[3][100002];   int dp[300006];   void add1(int i) {     res += dp[val[1][i]];     dp[val[0][i]]++;   }   void del1(int i) {     dp[val[0][i]]--;     res -= dp[val[1][i]];   }   void add2(int i) {     res += dp[val[2][i]];     dp[val[0][i]]++;   }   void del2(int i) {     dp[val[0][i]]--;     res -= dp[val[2][i]];   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &t[i]), t[i]--;     vector<long long> v;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       sum[0][i] = sum[0][i - 1];       sum[1][i] = sum[1][i - 1];       sum[t[i]][i] += a[i];       v.emplace_back(sum[0][i] - sum[1][i]);       v.emplace_back(sum[0][i] - sum[1][i] - k);       v.emplace_back(sum[0][i] - sum[1][i] + k);     }     v.emplace_back(0);     v.emplace_back(-k);     v.emplace_back(+k);     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     for (int i = 0; i <= n; i++) {       val[0][i] =           lower_bound(v.begin(), v.end(), sum[0][i] - sum[1][i]) - v.begin() + 1;       val[1][i] = lower_bound(v.begin(), v.end(), sum[0][i] - sum[1][i] - k) -                   v.begin() + 1;       val[2][i] = lower_bound(v.begin(), v.end(), sum[0][i] - sum[1][i] + k) -                   v.begin() + 1;     }     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       scanf( %d%d , &l[i], &r[i]);       l[i]--;       block[i] = {l[i] / sz, r[i], i};     }     sort(block + 1, block + 1 + q, cmp);     int curl = 0, curr = 0;     dp[val[0][0]]++;     for (int i = 1; i <= q; i++) {       int idx = block[i].i;       int ll = l[idx], rr = r[idx];       while (curl < ll) del2(curl++);       while (curl > ll) add2(--curl);       while (curr < rr) add1(++curr);       while (curr > rr) del1(curr--);       ans[idx] = res;     }     for (int i = 1; i <= q; i++) printf( %lld n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int DAYS = 7;   int val[DAYS];   void solve() {     int k;     cin >> k;     int tot = 0;     for (int i = 0; i < DAYS; ++i) {       cin >> val[i];       tot += val[i];     }     int res = 1 << 30;     for (int start = 0; start < DAYS; ++start) {       if (val[start]) {         int tmp = k;         int passed = 0;         for (int j = start; j < DAYS && tmp > 0; ++j) {           passed++;           tmp -= val[j];         }         if (tmp > tot) {           tmp -= tot;           int cycles = tmp / tot;           passed += cycles * DAYS;           tmp %= tot;           tmp += tot;         }         int j = 0;         while (tmp > 0) {           tmp -= val[j];           passed++;           j = (j + 1) % DAYS;         }         res = min(res, passed);       }     }     cout << res << endl;   }   int main() {     ios::sync_with_stdio(false);     int T;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300000000 + 10;   bitset<MAXN> check;   void Get_prime(int n) {     check.set();     check[0] = check[1] = 0;     for (int i = 2; i <= sqrt(n + 0.5); ++i) {       if (check[i])         for (int j = 2; i * j <= n; ++j) check[i * j] = 0;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int l, r;     cin >> l >> r;     Get_prime(r);     int cnt = 0, i;     if (l <= 2 && 2 <= r) ++cnt;     if (l % 4 <= 1)       i = l / 4 * 4 + 1;     else       i = (l / 4 + 1) * 4 + 1;     for (i; i <= r; i += 4)       if (check[i]) ++cnt;     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 100010;   long long n, S[maxn], top, ans[maxn], cnt;   int main() {     cin >> n;     for (long long i = 1; i * i <= n; i++)       if (n % i == 0) {         S[++top] = i;         if (i * i != n) S[++top] = n / i;       }     for (long long i = 1; i <= top; i++) {       long long temp = (n - 1) / S[i];       temp++;       long long temp2 = (n - 1) / S[i];       temp2 = temp2 * S[i] + 2;       temp = temp * temp2;       ans[++cnt] = temp / 2;     }     sort(ans + 1, ans + 1 + cnt);     cnt = unique(ans + 1, ans + 1 + cnt) - ans - 1;     for (int i = 1; i <= cnt; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, res;   void mo() {     freopen( 1091A.inp ,  r , stdin);     freopen( 1091A.out ,  w , stdout);   }   void nhap() { cin >> a >> b >> c; }   void xuli() {     if (c - 1 <= b && c - 2 <= a) {       res = max(res, c + c - 1 + c - 2);     }     if (b + 1 <= c && b - 1 <= a) {       res = max(res, b + b + 1 + b - 1);     }     if (a + 1 <= b && a + 2 <= c) res = max(res, a + 1 + a + a + 2);     cout << res;   }   int main() {     nhap();     xuli();   }
#include <bits/stdc++.h>   using namespace std;      const int INF = 0x3f3f3f3f;      int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<long long> t(n), x(n);       for (int i = 0; i < n; i++) {         cin >> t[i] >> x[i];       }       long long start = 0, end = 0, from = 0, to = 0, ans = 0;       for (int i = 0; i < n; i++) {         if (end <= t[i]) {           start = t[i];           end = t[i] + llabs(to - x[i]);           from = to;           to = x[i];         }         if (min(from, to) <= x[i] && max(from, to) >= x[i]) {           long long arrival = start + abs(from - x[i]);           if (t[i] <= arrival && (i == n - 1 ? true : (arrival <= t[i + 1]))) {             ans++;           }         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> Max[3005][3005];   struct ans {     int a, b, c;     int i, j, k;     ans(int _a, int _b, int _c, int _i, int _j, int _k) {       a = _a;       b = _b;       c = _c;       i = _i;       j = _j;       k = _k;     }   };   bool operator<(const ans &a, const ans &b) {     if (a.a != b.a)       return a.a < b.a;     else if (a.b != b.b)       return a.b < b.b;     else       return a.c < b.c;   }   int main() {     int n;     scanf( %d , &n);     pair<int, int> a[3005];     memset(Max, -1, sizeof(Max));     for (int i = 0; i < n; i++) {       int first;       scanf( %d , &first);       a[i] = make_pair((first), (i));     }     sort(a, a + n);     reverse(a, a + n);     a[n] = make_pair((0), (n));     for (int i = 0; i < n; i++) {       for (int j = i + 1; j <= n; j++) {         Max[i][j - 1] =             max(Max[i][j - 2], make_pair((a[j - 1].first - a[j].first), (j)));       }     }     ans aa = ans{-1, -1, -1, 0, 0, 0};     for (int i = 1; i <= n; i++) {       for (int j = (i + 1) / 2; j <= i * 2 && i + j <= n; j++) {         int l = max((i + 1) / 2, (j + 1) / 2), r = min(i * 2, j * 2);         l += i + j;         r += i + j;         l--;         r--;         if (l >= n) continue;         if (r >= n) r = n - 1;         aa = max(aa, ans(a[i - 1].first - a[i].first,                          a[i + j - 1].first - a[i + j].first, Max[l][r].first, i,                          i + j, Max[l][r].second));       }     }     int ans[3005];     memset(ans, -1, sizeof(ans));     for (int i = 0; i < aa.i; i++) ans[a[i].second] = 1;     for (int i = aa.i; i < aa.j; i++) ans[a[i].second] = 2;     for (int i = aa.j; i < aa.k; i++) ans[a[i].second] = 3;     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long x = 0;     int zf = 1;     char ch =    ;     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) zf = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * zf;   }   long long val[1000005];   long long f[1000005];   int n;   long long cnt[9];   int main() {     long long w = read(), tmp = w, sum = 0;     for (int i = 1; i <= 8; ++i) cnt[i] = read(), sum += cnt[i] * i;     if (sum < w) {       printf( %lld , sum);       return 0;     }     if (w > 900) {       long long w2 = w - 900, use;       for (int i = 8; i >= 1 && w2; --i) {         if (cnt[i] * i <= w2)           w2 -= cnt[i] * i;         else {           use = (w2 / i) + 1;           cnt[i] -= use;           w2 -= use * i;           break;         }       }       w = 900 + w2;     }     for (int i = 1; i <= 8; ++i) {       long long j = 1;       while (cnt[i] >= j) {         cnt[i] -= j;         val[++n] = i * j;         j <<= 1;       }       if (cnt[i]) val[++n] = cnt[i] * i;     }     for (int i = 1; i <= n; ++i)       for (int j = w; j >= val[i]; --j) f[j] = max(f[j - val[i]] + val[i], f[j]);     printf( %lld , tmp - (w - f[w]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int k1, k2, i;   } node[105];   bool cmp1(const Node& a, const Node& b) { return a.k1 < b.k1; }   bool cmp2(const Node& a, const Node& b) { return a.i < b.i; }   int main() {     int n, w;     scanf( %d%d , &n, &w);     for (int i = 0; i < n; i++) {       scanf( %d , &node[i].k1);       node[i].i = i;     }     sort(node, node + n, cmp1);     for (int i = 0; i < n; i++) {       int f = node[i].k1 / 2;       if (node[i].k1 & 1) f++;       node[i].k2 = f;       w -= f;     }     if (w < 0) {       puts( -1 );       return 0;     }     for (int i = n - 1; i >= 0 && w; i--) {       if (w >= node[i].k1 - node[i].k2) {         w -= node[i].k1 - node[i].k2;         node[i].k2 = node[i].k1;       } else {         node[i].k2 += w;         w = 0;       }     }     sort(node, node + n, cmp2);     for (int i = 0; i < n; i++) {       if (i)         printf(  %d , node[i].k2);       else         printf( %d , node[i].k2);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int y, l, r, x, rem;     cin >> l >> r;     for (x = l; x <= r; x++) {       y = x;       set<int> s;       while (y != 0) {         rem = y % 10;         if (s.find(rem) == s.end())           s.insert(rem);         else           break;         y /= 10;       }       if (y == 0) break;     }     if (y == 0)       cout << x;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast ,  unroll-loops )   using namespace std;   int a[100005];   int n;   int solve() {     sort(a, a + n);     int i = n - 1;     int sum = 0;     while (i >= 0 and a[i] >= 0) sum += a[i--];     if (sum % 2) return sum;     int j = i;     while (j >= 0 and abs(a[j]) % 2 == 0) j--;     i++;     while (i < n and a[i] % 2 == 0) i++;     if (j < 0) return sum - a[i];     if (i == n) return sum + a[j];     return sum - min(a[i], abs(a[j]));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t) {       cin >> n;       for (int i = 0; i < n; i++) cin >> a[i];       cout << solve();       t--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long TC = 1;     cin >> TC;     while (TC--) {       int n, f = 1, c = 0;       cin >> n;       int a[n], feq[110] = {0};       for (int i = 0; i < n; i++) {         cin >> a[i];         feq[a[i]]++;       }       sort(a, a + n);       for (int i = 0; i < n - 1; i++) {         if (a[i + 1] - a[i] > 1) f = 0;       }       if (f)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long i, j, k, n, m, ans = 0;     string a, b;     cin >> n >> a >> b;     for (i = 0; i < n / 2; i++) {       int j = n - i - 1;       if (a[i] == b[i] && a[j] == b[j])         continue;       else if (a[i] == b[i] && a[j] != b[j])         ans++;       else if (a[i] != b[i] && a[j] == b[j])         ans++;       else {         set<char> se({a[i], b[i], a[j], b[j]});         if (se.size() == 4)           ans += 2;         else if (se.size() == 3) {           ans++;           if (a[i] == a[j]) ans++;         }       }     }     if (n % 2 == 1) ans += (a[n / 2] != b[n / 2]);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z, t1, t2, t3, ts, te;     cin >> x >> y >> z >> t1 >> t2 >> t3;     ts = abs(x - y) * t1;     te = t3 * 2 + abs(x - z) * t2 + t3 + abs(x - y) * t2;     if (ts >= te)       cout <<  YES ;     else       cout <<  NO ;   }