malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int a, b, c, d, h;   int main() {     scanf( %d %d %d %d , &a, &b, &c, &d);     h = a + 8 * c;     if (h >= b) {       printf( 0 );       return 0;     }     if (c <= d) {       printf( -1 );       return 0;     }     printf( %d ,            (b - h) / (12 * (c - d)) + (((b - h) % (12 * (c - d)) == 0) ? 0 : 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   void solve() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     if (count(v.begin(), v.end(), 1) == 1) {       cout << 0 << endl;       return;     }     int s, e;     for (s = 0; s < n; s++) {       if (v[s] == 1) {         break;       }     }     for (e = n - 1; e >= 0; e--) {       if (v[e] == 1) {         break;       }     }     int ans = 0;     for (int i = s; i <= e; i++) {       if (v[i] == 0) {         ans++;       }     }     cout << ans << endl;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[1 << 14];   signed main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     int n, k, maxn = 0;     cin >> n >> k;     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       maxn = max(maxn, a);       ++cnt[a];     }     long long ans = 0;     if (k == 0) {       for (int i = 0; i <= maxn; ++i) ans += cnt[i] * (cnt[i] - 1LL) / 2;       cout << ans <<   n ;       return 0;     }     int l = 32 - __builtin_clz(max(1, maxn));     for (int i = 0; i < (1 << l); ++i) {       if (__builtin_popcount(i) != l - k) continue;       for (int j = 0; j <= maxn; ++j)         ans += 1LL * cnt[j] * cnt[(j & i) | (~j & ~i & ((1 << l) - 1))];     }     cout << ans / 2 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char s[1000];     gets(s);     int a[1000] = {0};     for (int i = 0; i < strlen(s); i++) {       if (s[i] <=  z  && s[i] >=  a ) a[s[i]]++;     }     int m = 0;     for (int i = 0; i < 1000; i++)       if (a[i]) m++;     cout << m;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     long long prev = 0;     long long last = 1e18;     for (int i = 0; i < n / 2; ++i) {       long long x;       cin >> x;       prev = max(prev, x - last);       last = x - prev;       a[i] = prev;       a[n - i - 1] = last;     }     for (int i = 0; i < n; ++i) {       cout << a[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 5;   char a[N][N];   void fileIO() {}   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     fileIO();     int h, w;     int tot = 0;     cin >> h >> w;     for (int i = 0; i < h; i++)       for (int j = 0; j < w; j++) {         cin >> a[i][j];         if (a[i][j] ==  * ) tot++;       }     int now = 0;     int curi, curj;     for (int i = 1; i < h - 1; i++) {       for (int j = 1; j < w - 1; j++) {         now = 0;         if (a[i][j] ==  *  and a[i + 1][j] ==  *  and a[i - 1][j] ==  *  and             a[i][j + 1] ==  *  and a[i][j - 1] ==  * ) {           curi = i, curj = j;           while (a[curi + 1][j] ==  * ) {             now++;             curi++;           }           curi = i, curj = j;           while (a[curi - 1][j] ==  * ) {             now++;             curi--;           }           curi = i, curj = j;           while (a[i][curj + 1] ==  * ) {             now++;             curj++;           }           curi = i, curj = j;           while (a[i][curj - 1] ==  * ) {             now++;             curj--;           }           if (now + 1 == tot) {             cout <<  YES ;             exit(0);           }         }       }     }     cout <<  NO ;     return 0;   }
#include <iostream>   #include <vector>   #include <algorithm>   #include <string>   #include <map>   #include <cstdio>   #include <utility>    #include <queue>   #include <math.h>   #include <set>   #include <bitset>   #include <cmath>   #include <bitset>   #include <stack>   #include <cstring>   #include <deque>   using namespace std;   typedef long long ll;   typedef pair<int, int> pii;      int main() {       ios_base::sync_with_stdio(0);       cin.tie(NULL);       int t; cin >> t;       while(t--) {           int n, m; cin >> n >> m;           vector<ll> k(n + 1);           vector<ll> c(m + 1);           for(int i = 1; i <= n; i++) cin >> k[i];           for(int i = 1; i <= m; i++) cin >> c[i];           int idx = 1;           sort(k.begin(), k.end());           ll ans = 0;           for(int i = n; i >= 1; i--) {               if(idx > k[i] || c[k[i]] < c[idx]) ans += c[k[i]];               else {                   ans += c[idx];                   idx++;               }           }           cout << ans <<   n ;       }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   long long mod = 1e9 + 7;   vector<long long> g[27];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s1, s2;     cin >> s1 >> s2;     long long n1 = s1.size(), n2 = s2.size(), i, j;     for (i = 0; i < n1; ++i) g[s1[i] -  a ].push_back(i);     long long cnt = 1, prev = -1, it, sz;     for (i = 0; i < n2; ++i) {       j = s2[i] -  a ;       sz = g[j].size();       if (sz == 0) return cout << -1, 0;       it = upper_bound(g[j].begin(), g[j].end(), prev) - g[j].begin();       if (it == sz) it = 0, ++cnt;       prev = g[j][it];     }     cout << cnt <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};   int n, m, k;   bool isValid(int i, int j) { return i >= 0 && j >= 0 && i < n && j < m; }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     int freex = -1, freey = -1, remains = 0;     char grid[n][m];     bool visited[n][m];     memset(visited, false, sizeof visited);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> grid[i][j];         if (grid[i][j] ==  . ) {           remains++;           freex = i;           freey = j;         }       }     if (k == 0) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           cout << grid[i][j];         }         cout <<   n ;       }       return 0;     }     queue<pair<int, int>> q;     q.push({freex, freey});     int count = 0;     while (!q.empty()) {       auto tmp = q.front();       q.pop();       int x = tmp.first;       int y = tmp.second;       if (visited[x][y]) continue;       visited[x][y] = true;       count++;       if (count == remains - k) break;       for (int i = 0; i < 4; i++) {         int nx = x + dir[i][0];         int ny = y + dir[i][1];         if (isValid(nx, ny) && grid[nx][ny] ==  .  && !visited[nx][ny])           q.push({nx, ny});       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (!visited[i][j] && grid[i][j] ==  . )           cout <<  X ;         else if (grid[i][j] ==  # )           cout <<  # ;         else           cout <<  . ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int ar[30];   int br[30];   unordered_map<long, long> nm;   int main() {     std::ios::sync_with_stdio(false);     ;     int n;     std::cin >> n;     for (int i = 0; i < n; i++) {       std::cin >> ar[i];       br[i] = ar[i];       nm[ar[i]] = i;     }     sort(ar, ar + n);     for (int i = 0; i < n - 1; i++) {       br[nm[ar[i]]] = ar[i + 1];     }     br[nm[ar[n - 1]]] = ar[0];     for (int i = 0; i < n; i++) {       std::cout << br[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   long long power(long long a, long long b, long long ret = 1LL) {     while (b--) ret = (ret * a);     return ret;   }   char a[105];   int main() {     long long n, k;     cin >> n >> k;     int ans = 0;     for (int i = 1; i <= n; i++) {       int cnt = 0;       long long x;       cin >> x;       while (x > 0) {         if (x % 10 == 7 || x % 10 == 4) {           cnt++;         }         x /= 10;       }       if (cnt <= k) ans++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( -ffloat-store )   #pragma GCC optimize( -fno-defer-pop )   long long int power(long long int a, long long int b, long long int m) {     if (b == 0) return 1;     if (b == 1) return a % m;     long long int t = power(a, b / 2, m) % m;     t = (t * t) % m;     if (b & 1) t = ((t % m) * (a % m)) % m;     return t;   }   long long int modInverse(long long int a, long long int m) {     return power(a, m - 2, m);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int q;     cin >> q;     while (q--) {       long long int i, j, k, l, n;       cin >> n >> k;       long long int ar[n + 1];       for (i = 1; i <= n; i++) {         cin >> ar[i];       }       vector<long long int> an;       long long int s = 0;       for (i = 1; i <= n; i++) {         s += ar[i];         if (s % 2) {           an.push_back(i);           s = 0;         } else if (i == n) {           if (an.size() > 0) {             an.pop_back();             an.push_back(i);           }         }       }       if (an.size() < k) {         cout <<  NO               <<   n ;       } else {         long long int v = (an.size() - k);         if (v % 2 == 0) {           cout <<  YES                 <<   n ;           i = v;           while (i < an.size()) {             cout << an[i] <<    ;             i++;           }           cout <<   n ;         } else {           cout <<  NO                 <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 250 + 7;   int a[MAXN][MAXN], ans[MAXN][MAXN];   bool rmax[MAXN * MAXN], cmax[MAXN * MAXN], vis[MAXN * MAXN];   bool canr[MAXN], canc[MAXN];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         scanf( %d , &a[i][j]);       }     for (int i = 1; i <= n; i++) {       int MAX = 0;       for (int j = 1; j <= m; j++) MAX = max(MAX, a[i][j]);       rmax[MAX] = 1;     }     for (int j = 1; j <= m; j++) {       int MAX = 0;       for (int i = 1; i <= n; i++) MAX = max(MAX, a[i][j]);       cmax[MAX] = 1;     }     int x = 0, y = 0;     queue<pair<int, int> > pos;     for (int num = n * m; num >= 1; num--) {       x += rmax[num];       y += cmax[num];       if (rmax[num] || cmax[num]) {         ans[x][y] = num;       } else {         pair<int, int> p = pos.front();         pos.pop();         ans[p.first][p.second] = num;       }       if (rmax[num]) {         canr[x] = 1;         for (int j = y - 1; j >= 1; j--)           if (canc[j]) pos.push({x, j});         for (int j = y + 1; j <= m; j++)           if (canc[j]) pos.push({x, j});       }       if (cmax[num]) {         canc[y] = 1;         for (int i = x - 1; i >= 1; i--)           if (canr[i]) pos.push({i, y});         for (int i = x + 1; i <= n; i++)           if (canr[i]) pos.push({i, y});       }     }     for (int i = 1; i <= n; i++, puts(  ))       for (int j = 1; j <= m; j++) printf( %d  , ans[i][j]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long i, j, k, n, t, x, l, r, m;     cin >> t;     while (t--) {       cin >> n;       k = n / 2;       long long sum = 0, y, cnt = 1;       x = 3;       y = 1;       while (k--) {         sum += ((x * 2 * cnt) + (y * 2 * cnt));         x += 2;         y += 2;         cnt++;       }       cout << sum <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll MOD = 1000000007;   ll mod = 998244353;   int inf = 1000001000;   ll INF = 1e18 + 5;   int main() {     std::cin.tie(nullptr);     std::ios::sync_with_stdio(false);     int t;     cin >> t;     for (int(_) = 0; (_) < (t); (_)++) {       int n;       cin >> n;       if (n == 1)         cout <<  FastestFinger  << endl;       else if (n == 2)         cout <<  Ashishgup  << endl;       else {         if (n % 2)           cout <<  Ashishgup  << endl;         else {           int cnt = 0;           while (n % 2 == 0) {             n /= 2;             cnt++;           }           if (n == 1) {             cout <<  FastestFinger  << endl;           } else {             if (cnt > 1)               cout <<  Ashishgup  << endl;             else {               int q = 0;               for (ll i = 3; i * i <= n; i += 2) {                 if (n % i == 0) {                   cout <<  Ashishgup  << endl;                   q++;                   break;                 }               }               if (q == 0) cout <<  FastestFinger  << endl;             }           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9 + 7;   const int FFTMOD = 119 << 23 | 1;   const int INF = (int)1e9 + 23111992;   const long long LINF = (long long)1e18 + 23111992;   const long double PI = acos((long double)-1);   const long double EPS = 1e-9;   inline long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline long long fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   template <class T>   inline int chkmin(T& a, const T& val) {     return val < a ? a = val, 1 : 0;   }   template <class T>   inline int chkmax(T& a, const T& val) {     return a < val ? a = val, 1 : 0;   }   inline unsigned long long isqrt(unsigned long long k) {     unsigned long long r = sqrt(k) + 1;     while (r * r > k) r--;     return r;   }   inline long long icbrt(long long k) {     long long r = cbrt(k) + 1;     while (r * r * r > k) r--;     return r;   }   inline void addmod(int& a, int val, int p = MOD) {     if ((a = (a + val)) >= p) a -= p;   }   inline void submod(int& a, int val, int p = MOD) {     if ((a = (a - val)) < 0) a += p;   }   inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }   inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }   inline int sign(long double x, long double y) { return sign(x - y); }   mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());   inline int myrand() { return abs((int)mt()); }   const int maxn = 2e6 + 5;   int fac[maxn];   int ifac[maxn];   int binom(int a, int b) {     if (a > b) return 0;     return mult(fac[b], mult(ifac[a], ifac[b - a]));   }   void chemthan() {     fac[0] = 1;     for (int i = (1); i < (maxn); ++i) fac[i] = mult(fac[i - 1], i);     for (int i = (0); i < (maxn); ++i) ifac[i] = inv(fac[i]);     int n, m, a, b;     cin >> n >> m >> a >> b;     int res = 0;     for (int k = (1); k < (n); ++k) {       int coef = binom(k - 1, m - 1);       int d = n - 1 - k;       int coef2 = !d ? 1 : mult(n - d, fpow(n, d - 1));       coef = mult(coef, fac[k - 1]);       addmod(res, mult(coef, mult(binom(k - 1, n - 2),                                   mult(coef2, fpow(m, n - k - 1)))));     }     cout << res <<   n ;   }   int main(int argc, char* argv[]) {     ios_base::sync_with_stdio(0), cin.tie(0);     if (argc > 1) {       assert(freopen(argv[1],  r , stdin));     }     if (argc > 2) {       assert(freopen(argv[2],  wb , stdout));     }     chemthan();     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long sign = 1;     long long x = 0;     char ch;     while (!isdigit(ch = getchar()))       if (ch ==  - ) sign = -1;     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * sign;   }   inline void wonl() { putchar(  n ); }   inline void wws() { putchar(   ); }   inline void dbg() { cout << endl; }   inline void ww(long long k) {     if (k < 0) putchar( - ), k *= -1;     char ch[20];     int num = 0;     while (k) ch[++num] = k % 10, k /= 10;     if (num == 0) ch[++num] = 0;     while (num) putchar(ch[num--] +  0 );   }   const int N = 1e5 + 4;   template <typename T, typename... V>   inline void wonl(T t, V... v) {     ww(t);     if (sizeof...(v)) putchar(   );     wonl(v...);   }   template <typename T, typename... V>   inline void wws(T t, V... v) {     ww(t);     if (sizeof...(v)) putchar(   );     wws(v...);   }   template <typename T, typename... V>   inline void dbg(T t, V... v) {     cout <<     << t;     dbg(v...);   }   void solve() {     int n = read(), a;     map<int, int> ma;     for (int i = 0; i < n; i++) a = read(), ma[a]++;     vector<int> v;     for (auto it : ma) v.push_back(it.second);     sort(v.begin(), v.end());     reverse(v.begin(), v.end());     long long num = 1;     while (v[0] >= num) num *= 2;     long long fans = 0;     while (num) {       long long ter = num;       long long a = INT_MAX;       int k = 0;       while (ter != 0 && k < v.size()) {         a = min(a, v[k] / ter), ter = ter / 2, k++;       }       if (ter == 0) fans = max(fans, a * (num * 2 - 1));       num = num / 2;     }     wonl(fans);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 300000;   const long long mod = 1e9 + 7;   const long long inf = 1e18;   long long a[MX + 5];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tc, cs = 1, i, j, k, x, y, z, n, m;     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     for (i = 1; i <= n; i++) a[i] += a[i - 1];     cin >> m;     for (i = 1; i <= m; i++) {       cin >> x;       y = a[n] - (a[n - x + 1] - a[n - x]);       cout << y << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int a[n], i, max = 0, f;     for (i = 0; i < n; i++) scanf( %d , &a[i]);     stack<int> s;     for (i = 0; i < n; i++) {       while (!s.empty()) {         if (s.top() < a[i]) {           f = s.top() ^ a[i];           s.pop();           if (f > max) max = f;         } else {           f = s.top() ^ a[i];           if (f > max) max = f;           break;         }       }       s.push(a[i]);     }     printf( %d , max);     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 int n;     cin >> n;     while (n--) {       long long int m;       cin >> m;       if (m % 3 == 0 || m % 7 == 0)         cout <<  YES  << endl;       else {         long long int k = m / 3;         if (k >= 4)           cout <<  YES  << endl;         else {           if (m <= 8 || m == 11) cout <<  NO  << endl;         }         if (m == 10) cout <<  YES  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 5;   const int mod = 998244353;   map<pair<int, int>, int> mp;   pair<int, int> a[maxn], b[maxn];   int n;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].first, &a[i].second);     for (int i = 1; i <= n; ++i) scanf( %d%d , &b[i].first, &b[i].second);     if (n == 1) {       printf( %d %d n , a[1].first + b[1].first, a[1].second + b[1].second);       return 0;     }     for (int i = 1; i <= n; ++i) {       ++mp[{a[1].first + b[i].first, a[1].second + b[i].second}];     }     for (int i = 2; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         int x = a[i].first + b[j].first, y = a[i].second + b[j].second;         if (mp.find({x, y}) != mp.end()) ++mp[{x, y}];       }     }     for (auto it : mp) {       if (it.second == n) {         printf( %d %d n , it.first.first, it.first.second);         break;       }     }     return 0;   }
#include <bits/stdc++.h>   int GCD(int u, int v) {     while (v != 0) {       int r = u % v;       u = v;       v = r;     }     return u;   }   int main() {     int amtV;     int amtE;     std::vector<std::pair<int, int>> graph;     std::cin >> amtV >> amtE;     int connected = 0;     int remaining = amtE;     if (amtE >= amtV - 1) {       for (int i = 2; i <= amtV; i++) {         graph.push_back(std::pair<int, int>(i, 1));       }       remaining = amtE - (amtV - 1);       for (int i = 3; i <= amtV; i += 2) {         if (remaining == 0) break;         graph.push_back(std::pair<int, int>(i, 2));         remaining--;       }       int currInd = 3;       int currCompare;       while (remaining > 0 && currInd < amtV) {         currCompare = currInd + 1;         while (remaining > 0 && currCompare <= amtV) {           if (GCD(currInd, currCompare) == 1) {             graph.push_back(std::pair<int, int>(currInd, currCompare));             remaining--;           }           currCompare++;         }         currInd++;       }     }     if (remaining == 0) {       std::cout <<  Possible  << std::endl;       for (auto it = graph.begin(); it != graph.end(); it++) {         std::cout << it->first <<     << it->second << std::endl;       }     } else {       std::cout <<  Impossible  << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dist(int x, int y) {     if (y > x)       return (y - x);     else       return (12 - x + y);   }   int main() {     int i, j, q, r, t;     string a, b, c;     cin >> a >> b >> c;     map<string, int> m;     m[ C ] = 1;     m[ C# ] = 2;     m[ D ] = 3;     m[ D# ] = 4;     m[ E ] = 5;     m[ F ] = 6;     m[ F# ] = 7;     m[ G ] = 8;     m[ G# ] = 9;     m[ A ] = 10;     m[ B ] = 11;     m[ H ] = 12;     int x, y, z;     x = m[a];     y = m[b];     z = m[c];     if (dist(x, y) == 3 && dist(y, z) == 4)       cout <<  minor ;     else if (dist(x, y) == 4 && dist(y, z) == 3)       cout <<  major ;     else if (dist(x, z) == 3 && dist(z, y) == 4)       cout <<  minor ;     else if (dist(x, z) == 4 && dist(z, y) == 3)       cout <<  major ;     else if (dist(y, x) == 3 && dist(x, z) == 4)       cout <<  minor ;     else if (dist(y, x) == 4 && dist(x, z) == 3)       cout <<  major ;     else if (dist(y, z) == 3 && dist(z, x) == 4)       cout <<  minor ;     else if (dist(y, z) == 4 && dist(z, x) == 3)       cout <<  major ;     else if (dist(z, x) == 3 && dist(x, y) == 4)       cout <<  minor ;     else if (dist(z, x) == 4 && dist(x, y) == 3)       cout <<  major ;     else if (dist(z, y) == 3 && dist(y, x) == 4)       cout <<  minor ;     else if (dist(z, y) == 4 && dist(y, x) == 3)       cout <<  major ;     else       cout <<  strange ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long x, y, n, m, t, q, a, b, count = 0;     cin >> n;     long long arr[n];     for (x = 0; x < n; x++) cin >> arr[x];     long long cop[n];     for (x = 0; x < n; x++) cop[x] = arr[x];     sort(cop, cop + n);     vector<long long> v;     for (x = 0; x < n; x++)       if (arr[x] != cop[x]) count++, v.push_back(x);     if (count <= 2)       cout <<  YES ;     else       cout <<  NO ;   }