malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int x1, y1, x2, y2;     int sum = 0;     for (int i = 0; i < n; ++i) {       cin >> x1 >> y1 >> x2 >> y2;       sum += (abs(x2 - x1) + 1) * (abs(y2 - y1) + 1);     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     bool good[n];     for (int i = 0; i < n; i++) good[i] = 1;     for (int i = 0; i < n; i++) {       int isGood = 1;       for (int j = 0; j < n; j++) {         int dum;         cin >> dum;         if (dum == 1 || dum == 3)           good[i] = 0;         else if (dum == 2)           good[j] = 0;       }     }     int ans = 0;     for (int i = 0; i < n; i++)       if (good[i]) ans++;     cout << ans << endl;     for (int i = 0; i < n; i++) {       if (good[i]) cout << i + 1 <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s, i, v = 0, a[1010];     cin >> n >> s;     for (i = 1; i <= n; i++) {       cin >> a[i];       v = v + a[i];     }     for (i = 1; i <= n; i++)       if ((v - a[i]) <= s) {         cout <<  YES ;         return 0;       }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005], b[100005];   int main() {     int n, m, i;     long long sum = 0;     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d , &a[i]);       sum += a[i];       if (a[i] + i > n + 1) {         printf( -1 );         return 0;       }     }     if (sum < n) {       printf( -1 );       return 0;     }     b[m + 1] = 100005;     for (i = m; i; i--) {       b[i] = min(n - a[i] + 1, b[i + 1] - 1);     }     b[1] = 1;     for (i = 2; i <= m; i++) {       if (b[i - 1] + a[i - 1] >= b[i]) {         break;       }       b[i] = b[i - 1] + a[i - 1];     }     for (i = 1; i <= m; i++) {       printf( %d  , b[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   vector<int> adj[(int)1e5 + 7];   int vis[(int)1e5 + 7];   int deg[(int)1e5 + 7];   int cnt[(int)1e5 + 7];   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     scanf( %d %d , &n, &k);     for (int i = 1; i <= n - 1; i++) {       int u, v;       scanf( %d %d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);       deg[v]++;       deg[u]++;     }     int lvl = 0;     queue<int> q;     for (int i = 1; i <= n; i++)       if (deg[i] == 1) q.push(i);     while (q.size()) {       set<int> kroots;       int sz = q.size();       while (sz--) {         int root = q.front();         q.pop();         vis[root] = 1;         for (auto neighbour : adj[root]) {           if (vis[neighbour]) {             continue;           }           deg[neighbour]--;           cnt[neighbour]++;           kroots.insert(neighbour);         }       }       for (auto val : kroots) {         if (vis[val] || deg[val] > 1 || cnt[val] < 3) {           puts( No );           return 0;         }         q.push(val);       }       if (kroots.size())         lvl++;       else         break;     }     if (lvl == k)       puts( Yes );     else       puts( No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t, n, m, a, b, c, q, k, d, x;     cin >> n >> m;     vector<vector<int>> mat(n + 1, vector<int>(m + 1)),         ans(n + 1, vector<int>(m + 1));     char ch;     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j < m + 1; j++) {         cin >> ch;         mat[i][j] = ch -  0 ;         ans[i][j] = ans[i - 1][j] + ans[i][j - 1] - ans[i - 1][j - 1] + mat[i][j];       }     }     a = 0;     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j < m + 1; j++) {         for (int i_ = i; i_ < n + 1; i_++) {           for (int j_ = j; j_ < m + 1; j_++) {             if (ans[i_][j_] - ans[i - 1][j_] - ans[i_][j - 1] +                     ans[i - 1][j - 1] ==                 0) {               a = max(a, 2 * (i_ - i + 1 + j_ - j + 1));             }           }         }       }     }     cout << a <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double EPS = 1e-9;   long long INF = 1000000000000000005ll;   double PI = acos(-1);   inline string IntToString(long long int a) {     char x[100];     sprintf(x,  %lld , a);     string s = x;     return s;   }   inline long long int StringToInt(string a) {     char x[100];     long long int res;     strcpy(x, a.c_str());     sscanf(x,  %lld , &res);     return res;   }   inline string uppercase(string s) {     int n = (int)s.size();     for (long long int i = 0; i < n; i++)       if (s[i] >=  a  && s[i] <=  z ) s[i] = s[i] -  a  +  A ;     return s;   }   inline string lowercase(string s) {     int n = (int)s.size();     for (long long int i = 0; i < n; i++)       if (s[i] >=  A  && s[i] <=  Z ) s[i] = s[i] -  A  +  a ;     return s;   }   bool sortcol(const vector<long long int>& v1, const vector<long long int>& v2) {     return v1[0] > v2[0];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int c[n];     string r[n];     string s[n];     for (long long int i = 0; i < n; i++) cin >> c[i];     for (long long int i = 0; i < n; i++) {       cin >> r[i];       s[i] = r[i];       reverse(r[i].begin(), r[i].end());     }     long long int dp[n + 1][2];     memset(dp, 0, sizeof(dp));     dp[0][1] = c[0];     for (long long int i = 1; i < n; i++) {       dp[i][0] = INF;       dp[i][1] = INF;       if (s[i] >= s[i - 1]) {         dp[i][0] = min(dp[i - 1][0], dp[i][0]);       }       if (s[i] >= r[i - 1]) {         dp[i][0] = min(dp[i - 1][1], dp[i][0]);       }       if (r[i] >= s[i - 1]) {         dp[i][1] = min(dp[i - 1][0] + c[i], dp[i][1]);       }       if (r[i] >= r[i - 1]) {         dp[i][1] = min(dp[i - 1][1] + c[i], dp[i][1]);       }     }     long long int mi = min(dp[n - 1][0], dp[n - 1][1]);     if (mi != INF)       cout << min(dp[n - 1][0], dp[n - 1][1]) <<   n ;     else       cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T Min(T x, T y) {     return x < y ? x : y;   }   template <class T>   inline T Max(T x, T y) {     return x > y ? x : y;   }   bool MOP1;   long long T, n, res;   long long head[(105)], nxt[(105)], to[(105)], line;   void add(long long x, long long y) {     nxt[++line] = head[x], to[line] = y, head[x] = line;   }   struct node {     string name;     long long lei, X, Y;     long long tot, mx;     long long sz, bo, sp;     long long x() {       if (lei == 2) return sz ? tot + bo * 2 + (sz - 1) * sp : 0;       if (lei == 3) return sz ? mx + bo * 2 : 0;     }     long long y() {       if (lei == 2) return sz ? mx + bo * 2 : 0;       if (lei == 3) return sz ? tot + bo * 2 + (sz - 1) * sp : 0;     }     void add(node now) {       sz++;       if (lei == 2) {         tot += now.X;         mx = Max(mx, now.Y);       } else if (lei == 3) {         tot += now.Y;         mx = Max(mx, now.X);       }     }     bool operator<(const node &a) const { return name < a.name; }   } A[(105)];   long long read(string k) {     long long res = 0;     for (long long i = 0; i < k.size(); i++)       res = (res << 1) + (res << 3) + (k[i] ^ 48);     return res;   }   map<string, long long> mp;   string str;   long long a, b;   bool mark[(105)];   void dfs(long long x) {     mark[x] = 1;     for (long long i = head[x]; i; i = nxt[i]) {       long long y = to[i];       if (!mark[y]) dfs(y), mark[y] = 1;       A[x].add(A[y]);     }     if (A[x].lei != 1) {       A[x].X = A[x].x();       A[x].Y = A[x].y();     }     return;   }   bool MOP2;   signed main() {     scanf( %d , &T);     while (T--) {       cin >> str;       if (str[0] ==  W ) {         getchar();         getline(cin, str,  ( );         mp[str] = ++n;         A[n].lei = 1;         A[n].name = str;         scanf( %d,%d) , &A[n].X, &A[n].Y);       } else if (str[0] ==  H ) {         cin >> str;         mp[str] = ++n;         A[n].name = str;         A[n].lei = 2;       } else if (str[0] ==  V ) {         cin >> str;         mp[str] = ++n;         A[n].name = str;         A[n].lei = 3;       } else {         res = str.find( . );         a = mp[str.substr(0, res)];         if (str[res + 1] ==  s ) {           long long now = str.find( ( ) + 1;           long long tmp = read(str.substr(now, str.size() - now - 1));           if (str[res + 5] ==  b ) {             A[a].bo = tmp;           } else if (str[res + 5] ==  s ) {             A[a].sp = tmp;           }         } else {           b = mp[str.substr(res + 6, str.size() - res - 7)];           add(a, b);         }       }     }     for (long long i = 1; i <= n; i++)       if (!mark[i]) dfs(i);     sort(A + 1, A + 1 + n);     for (long long i = 1; i <= n; i++)       cout << A[i].name <<     << A[i].X <<     << A[i].Y << endl;     return 0;   }
#include <bits/stdc++.h>   const int mx = 110;   int a[mx];   bool ok(char ch) {     if (ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u  ||         ch ==  y )       return true;     return false;   }   int main() {     int n;     bool flag = 1;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     getchar();     for (int i = 0; i < n; i++) {       int num = 0;       char c;       while ((c = getchar()) !=   n )         if (ok(c)) num++;       if (num != a[i]) flag = 0;     }     printf(flag ?  YES n  :  NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 2, maxm = 1e7 + 5;   struct node {     int bg, ed, id;   } a[maxn];   int n, ans[maxn];   bool vis[maxm];   bool cmp(node a, node b) { return a.ed < b.ed; }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &a[i].bg, &a[i].ed);       a[i].id = i;     }     sort(a, a + n, cmp);     for (int i = 0; i < n; i++) {       int y = a[i].bg;       while (vis[y]) y++;       vis[y] = true;       ans[a[i].id] = y;     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int N = 1e6 + 10;   const int mod = 1e9 + 7;   int root;   vector<vector<int> > g;   vector<int> ans;   int sub[N], t[N];   void dfs0(int v, int p) {     sub[v] = t[v];     for (auto u : g[v]) {       if (u != p) {         dfs0(u, v);         sub[v] += sub[u];       }     }     return;   }   int dfs1(int v, int p) {     int ret = -1, temp;     if ((v != root) && 3 * sub[v] == sub[root]) {       ret = v;     }     vector<int> ans;     for (auto u : g[v]) {       if (u != p) {         temp = dfs1(u, v);         if (temp != -1) {           if (ret == -1) ret = temp;           if (sub[v] == 2 * sub[temp] && (sub[root] - sub[v] == sub[temp]) &&               (v != root)) {             cout << min(v, temp) <<     << max(v, temp) <<   n ;             exit(0);           }           ans.push_back(temp);           if (ans.size() >= 2) {             cout << min(ans[0], ans[1]) <<     << max(ans[0], ans[1]) <<   n ;             exit(0);           }         }       }     }     return ret;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     g.resize(n + 2);     int p;     for (int i = 1; i <= n; i++) {       cin >> p >> t[i];       if (p != 0) {         g[i].push_back(p);         g[p].push_back(i);       } else {         root = i;       }     }     dfs0(root, -1);     dfs1(root, -1);     if ((int)ans.size() < 2) {       cout << -1 <<   n ;     } else {       cout << min(ans[0], ans[1]) <<     << max(ans[0], ans[1]) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> n;       if (n <= 2) {         cout << 0 << endl;         continue;       } else {         int x;         x = n / 2;         if (n % 2 == 0) x--;         cout << x << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int a[n + 1];     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     int ans = 0;     for (int i = 1; i <= k; i++) ans += a[i];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[60][20010];   int S[60][20010];   int n, m, k;   int sum(int i, int l, int r) {     if (l > r) return 0;     return S[i][r] - S[i][l - 1];   }   int L[20010], R[20010];   int pre[20010], suf[20010];   int ST[2][200010];   void init(int tree[], int A[], int node, int li, int ls) {     if (li == ls) {       tree[node] = A[li];     } else {       int mid = (li + ls) / 2;       init(tree, A, 2 * node, li, mid);       init(tree, A, 2 * node + 1, mid + 1, ls);       tree[node] = max(tree[2 * node], tree[2 * node + 1]);     }   }   int query(int tree[], int node, int li, int ls, int i, int j) {     if (i > ls || j < li) return -0x3f3f3f3f;     if (li >= i && ls <= j) return tree[node];     int mid = (li + ls) / 2;     int left = query(tree, 2 * node, li, mid, i, j);     int right = query(tree, 2 * node + 1, mid + 1, ls, i, j);     return max(left, right);   }   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         scanf( %d , &S[i][j]);         S[i][j] += S[i][j - 1];       }     }     int ans = 0;     for (int i = n; i > 0; i--) {       for (int j = 1; j <= m; j++) {         dp[i][j] = 0;         int l = max(1, j - k + 1), r = min(m, j + k - 1);         if (l > 1) {           dp[i][j] = pre[l - 1] + sum(i + 1, j, r);         }         if (r < m) {           dp[i][j] = max(dp[i][j], suf[r + 1] + sum(i + 1, j, r));         }         dp[i][j] = max(dp[i][j], query(ST[0], 1, 1, m, l, j) + S[i + 1][r]);         dp[i][j] =             max(dp[i][j], query(ST[1], 1, 1, m, j + 1, r) - S[i + 1][j - 1]);         dp[i][j] += sum(i, j, r);         ans = max(ans, dp[i][j]);       }       for (int j = 1; j <= m; j++) {         pre[j] = dp[i][j];         suf[j] = dp[i][j];       }       for (int j = 2; j <= m; j++) {         pre[j] = max(pre[j], pre[j - 1]);         suf[m - j + 1] = max(suf[m - j + 1], suf[m - j + 2]);       }       for (int j = 1; j <= m; j++) {         L[j] = dp[i][j] - S[i][min(m, j + k - 1)];         R[j] = dp[i][j] + S[i][j - 1];       }       init(ST[0], L, 1, 1, m);       init(ST[1], R, 1, 1, m);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> ans;   void solve(long long n) {     long long step = 0;     while (n != 1) {       if (n % 2 == 0) {         if (n % 6 != 0) {           ans.push_back(-1);           return;         }         n /= 6;         if (n == 0) {           ans.push_back(-1);           return;         }       } else {         n *= 2;         if (n % 6 != 0) {           ans.push_back(-1);           return;         }       }       ++step;     }     ans.push_back(step);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       long long n;       cin >> n;       solve(n);     }     for (int i = (0); i < (ans.size()); ++i) cout << ans[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, nums[2201], ans = 0;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> nums[i];     }     sort(nums, nums + n);     for (int i = 0; i < k; i++) {       ans += nums[i];     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 9;   const int inf = 1e9 + 9;   const long long mod = 1e9 + 7;   const int N = 4e5 + 9;   int n, u, v, ans[N], sub[N], mx[N], centroid;   vector<int> gr[N], c[N];   int dfs(int v, int f) {     sub[v] = 1;     for (int i = 0; i < gr[v].size(); i++) {       if (gr[v][i] == f) continue;       int t = dfs(gr[v][i], v);       sub[v] += t;       mx[v] = max(mx[v], t);       c[v].push_back(t);     }     if ((n - sub[v]) <= n / 2 and mx[v] <= n / 2) {       ans[v] = 1;       centroid = v;     }     return sub[v];   }   void dfs2(int v, int f, int cur, int root) {     if (v != centroid and ans[v] == 0) {       int t = c[centroid].size() - 1;       if (sub[root] == c[centroid][t]) t--;       if (t >= 0 and n - sub[v] - c[centroid][t] <= n / 2)         ans[v] = 1;       else {         if (cur - sub[v] <= n / 2)           ans[v] = 1;         else           ans[v] = 0;       }     }     if (n - sub[v] <= n / 2) cur = sub[v];     for (int i = 0; i < gr[v].size(); i++) {       if (gr[v][i] == f) continue;       if (v == centroid) root = gr[v][i];       dfs2(gr[v][i], v, cur, root);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d %d , &u, &v);       gr[u].push_back(v);       gr[v].push_back(u);     }     dfs(1, 0);     memset(mx, 0, sizeof mx);     for (int i = 1; i <= n; i++) c[i].clear();     dfs(centroid, 0);     for (int i = 1; i <= n; i++) sort(c[i].begin(), c[i].end());     dfs2(centroid, 0, 0, 0);     for (int i = 1; i <= n; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int x, int y) { return (y == 0 ? x : gcd(y, x % y)); }   const int N = (int)1e6 + 100;   int a[30];   int n;   int m = 0;   char s[N];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < n; i++) m += a[i];     if (n == 1) {       printf( %d n , m);       for (int i = 0; i < m; i++) s[i] =  a ;       s[m] = (char)0;       printf( %s n , s);       return 0;     }     int cntOdd = 0;     for (int i = 0; i < n; i++)       if (a[i] & 1) cntOdd++;     if (cntOdd > 1) {       printf( 0 n );       int idx = 0;       for (int i = 0; i < n; i++)         for (int j = 0; j < a[i]; j++) s[idx++] = (char)( a  + i);       s[m] = (char)0;       printf( %s n , s);       return 0;     }     if (cntOdd == 1) {       int g = 0;       for (int i = 0; i < n; i++) {         if (a[i] & 1)           g = gcd(g, a[i]);         else           g = gcd(g, a[i] / 2);       }       printf( %d n , g);       int idx = 0;       for (int i = 0; i < n; i++) {         if (a[i] & 1) continue;         for (int j = 0; j < a[i] / 2 / g; j++) s[idx++] = (char)( a  + i);       }       for (int i = 0; i < n; i++) {         if ((a[i] & 1) == 0) continue;         for (int j = 0; j < a[i] / g; j++) s[idx++] = (char)( a  + i);       }       for (int i = n - 1; i >= 0; i--) {         if (a[i] & 1) continue;         for (int j = 0; j < a[i] / 2 / g; j++) s[idx++] = (char)( a  + i);       }       int p = idx;       for (int i = p; i < m; i++) s[i] = s[i - p];       s[m] = (char)0;       printf( %s n , s);       return 0;     }     int g = 0;     for (int i = 0; i < n; i++) g = gcd(g, a[i] / 2);     printf( %d n , 2 * g);     int idx = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < a[i] / 2 / g; j++) s[idx++] = (char)( a  + i);     for (int i = n - 1; i >= 0; i--)       for (int j = 0; j < a[i] / 2 / g; j++) s[idx++] = (char)( a  + i);     int p = idx;     for (int i = p; i < m; i++) s[i] = s[i - p];     s[m] = (char)0;     printf( %s n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5;   int d[maxn];   int w[maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     string s;     cin >> s;     for (int i = 0; i < n; ++i) {       cin >> d[i];     }     int cur = 0;     while (cur >= 0 && cur < n && !w[cur]) {       w[cur] = 1;       cur = cur + (s[cur] ==  <  ? -1 : 1) * d[cur];     }     if (cur < 0 || cur >= n) {       cout <<  FINITE n ;     } else {       cout <<  INFINITE n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 22, max_q = 11111, mod = 1000000007;   struct matrix {     vector<vector<int> > v;     matrix() {}     matrix(int n, int m) { v.resize(n, vector<int>(m, 0)); }     matrix operator*(const matrix &m) const {       matrix res(v.size(), m.v[0].size());       for (int i = 0; i < res.v.size(); ++i) {         for (int j = 0; j < res.v[i].size(); ++j) {           for (int k = 0; k < v[i].size(); ++k) {             res.v[i][j] += (1LL * v[i][k] * m.v[k][j]) % mod;             res.v[i][j] %= mod;           }         }       }       return res;     }   };   matrix power(matrix a, int b) {     if (b == 0) {       matrix res(a.v.size(), a.v.size());       for (int i = 0; i < res.v.size(); ++i) {         res.v[i][i] = 1;       }       return res;     }     if (b % 2 == 0) {       return power(a * a, b / 2);     }     return a * power(a, b - 1);   }   const int dx[] = {-1, 1, 0, 0, 0};   const int dy[] = {0, 0, -1, 1, 0};   int n, m, q, tp[max_q], x[max_q], y[max_q], t[max_q], f[max_q], a[max_n][max_n];   matrix dp, p;   bool is_in(int x, int y) { return 0 <= x && 0 <= y && x < n && y < m; }   void get_p() {     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         for (int k = 0; k < 5; ++k) {           int x = i + dx[k];           int y = j + dy[k];           if (is_in(x, y)) {             p.v[i * m + j][x * m + y] = 0;             if (a[x][y] == 0) {               p.v[i * m + j][x * m + y] = 1;             }           }         }       }     }   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i < q; ++i) {       scanf( %d%d%d%d , &tp[i], &x[i], &y[i], &t[i]);       --x[i];       --y[i];       if (tp[i] == 3) {         ++t[i];       }     }     dp = matrix(1, n * m);     p = matrix(n * m, n * m);     get_p();     dp.v[0][0] = 1;     int nt = 1;     for (int i = 0; i < q; ++i) {       if (t[i] != nt) {         dp = dp * power(p, t[i] - nt - 1);       }       while (i + 1 < q && t[i] == t[i + 1]) {         if (tp[i] == 2) {           a[x[i]][y[i]] = 1;         }         if (tp[i] == 3) {           a[x[i]][y[i]] = 0;         }         ++i;       }       if (tp[i] == 2) {         a[x[i]][y[i]] = 1;       }       if (tp[i] == 3) {         a[x[i]][y[i]] = 0;       }       get_p();       if (t[i] != nt) {         dp = dp * p;       }       nt = t[i];       if (tp[i] == 1) {         printf( %d n , dp.v[0][x[i] * m + y[i]]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     string ans =  NO ;     for (int i = 0; i < n - 1; i++) {       if (a[i] <= a[i + 1]) ans =  YES ;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       solve();     }   }