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);     int n, d;     cin >> n >> d;     string s;     int cnt, last = 0;     int ans = 0;     for (int i = 0; i < d; i++) {       cin >> s;       cnt = 0;       for (int j = 0; j < n; j++) cnt += (s[j] -  0 );       if (cnt == n) {         ans = max(ans, i - last);         last = i + 1;       }     }     ans = max(ans, d - last);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   template <typename element_type>   std::vector<element_type> read_vector(int size);   using namespace std;   int main() {     int particles;     string direction;     while (cin >> particles >> direction) {       vector<int> start = read_vector<int>(particles);       int best = -1;       for (int i = 1; i < particles; i++)         if (direction[i - 1] ==  R  && direction[i] ==  L )           if (best == -1 || (start[i] - start[i - 1]) / 2 < best)             best = (start[i] - start[i - 1]) / 2;       cout << best <<   n ;     }   }   template <typename element_type>   std::vector<element_type> read_vector(int size) {     std::vector<element_type> ret(size);     for (int i = 0; i < size; i++) std::cin >> ret[i];     return ret;   }
#include <bits/stdc++.h>   using namespace std;   int mp[1000007];   int dp[1010][10010];   int pre[1010][10010];   long long ans[1010][10010];   int out[1010][10010];   long long a[1010];   long long v[10010];   int cnt;   int add(long long k) {     if (!mp[k % 1000007]) {       v[++cnt] = k;       mp[k % 1000007] = cnt;     }     return mp[k % 1000007];   }   long long gcd(long long x, long long y) {     if (x % y == 0)       return y;     else       return gcd(y, x % y);   }   void output(int x, int y) {     printf( %d  , out[y][x]);     if (pre[y][x] == 1) return;     output(pre[y][x], out[y][x] - 1);   }   int main() {     int n;     long long k;     scanf( %d%lld , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     if (k == 1) {       long long p = a[1];       int x = 1;       for (int i = 1; i <= n; i++) {         if (p > a[i]) {           p = a[i];           x = i;         }       }       printf( %d n%d n , 1, x);       return 0;     }     memset(dp, -1, sizeof(dp));     add(k);     dp[0][1] = 0;     for (int i = 1; i <= n; i++) {       int cnt1 = cnt;       for (int k = 1; k <= cnt1; k++) {         dp[i][k] = dp[i - 1][k];         ans[i][k] = ans[i - 1][k];         pre[i][k] = pre[i - 1][k];         out[i][k] = out[i - 1][k];       }       for (int k = 1; k <= cnt1; k++) {         long long g = gcd(a[i], v[k]);         int x = add(v[k] / g);         if (dp[i][x] == -1 || dp[i][x] > dp[i - 1][k] + 1) {           dp[i][x] = dp[i - 1][k] + 1;           pre[i][x] = k;           ans[i][x] = ans[i - 1][k] + a[i];           out[i][x] = i;         } else if (dp[i][x] == dp[i - 1][k] + 1 &&                    ans[i][x] > ans[i - 1][k] + a[i]) {           pre[i][x] = k;           ans[i][x] = ans[i - 1][k] + a[i];           out[i][x] = i;         }       }     }     if (mp[1] == 0) {       printf( -1 n );     } else {       printf( %d n , dp[n][mp[1]]);       output(mp[1], n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a, b, i, j, t, p = 0, q = 0;     int x[200001];     cin >> n >> m;     for (i = 1; i <= n; ++i) {       cin >> t;       if (t == -1)         p++;       else         q++;     }     for (i = 0; i < m; ++i) {       cin >> a >> b;       if ((b - a + 1) % 2 == 0 && (b - a + 1) / 2 <= p && (b - a + 1) / 2 <= q)         cout << 1 << endl;       else         cout << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2 * acos(0);   int n;   char buf[10];   set<int> lhs;   set<int> rhs;   long long ret;   vector<int> unknown;   void update(int idx) {     if (!rhs.empty() && idx >= *rhs.begin()) {       rhs.insert(idx);       return;     }     if (!lhs.empty() && idx <= *lhs.rbegin()) {       lhs.insert(idx);       return;     }     unknown.push_back(idx);   }   void query(int idx) {     if (!rhs.empty() && idx > *rhs.begin()) {       printf( 0 n );       exit(0);     }     if (!lhs.empty() && idx < *lhs.rbegin()) {       printf( 0 n );       exit(0);     }     if (rhs.count(idx)) {       rhs.erase(idx);     } else if (lhs.count(idx)) {       lhs.erase(idx);     } else {       ret *= 2;       ret %= 1000000007;     }     for (int out : unknown) {       if (out > idx) {         rhs.insert(out);       } else if (out < idx) {         lhs.insert(out);       }     }     unknown.clear();   }   int main() {     scanf( %d n , &n);     ret = 1;     while (n--) {       int idx;       scanf( %s%d n , buf, &idx);       if (strlen(buf) == 3) {         update(idx);       } else {         query(idx);       }     }     long long scale = 1;     for (int out : unknown) {       if (!rhs.empty() && out > *rhs.begin()) continue;       if (!lhs.empty() && out < *lhs.rbegin()) continue;       scale++;     }     printf( %lld n , (ret * scale) % 1000000007);   }
#include <bits/stdc++.h>   template <typename T>   inline void read(T &x) {     x = 0;     register char ch;     register bool fl = 0;     while (ch = getchar(), ch < 48 || 57 < ch) fl ^= ch ==  - ;     x = (ch & 15);     while (ch = getchar(), 47 < ch && ch < 58)       x = (x << 1) + (x << 3) + (ch & 15);     if (fl) x = -x;   }   template <typename T>   inline void readc(T &x) {     while (x = getchar(), !islower(x) && !isupper(x))       ;   }   template <typename T>   inline void print(T x, char c =    ) {     static int buf[40];     if (x == 0) {       putchar( 0 );       putchar(c);       return;     }     if (x < 0) putchar( - ), x = -x;     for (buf[0] = 0; x; x /= 10) buf[++buf[0]] = x % 10 + 48;     while (buf[0]) putchar((char)buf[buf[0]--]);     putchar(c);   }   const int maxn = 100010;   int n, m, x, ans;   int c[maxn], f[maxn][20], cnt[maxn], dp[maxn];   long long s, a[maxn], g[maxn][20], sum[maxn];   int tot = 2, hed[maxn], to[maxn << 1], nxt[maxn << 1];   inline void add_edge(int u, int v) {     nxt[tot] = hed[u], to[tot] = v, hed[u] = tot++;     nxt[tot] = hed[v], to[tot] = u, hed[v] = tot++;   }   void dfs1(int u) {     for (int i = hed[u], v = to[i]; i; i = nxt[i], v = to[i])       if (v ^ f[u][0]) {         f[v][0] = u;         g[v][0] = a[u];         dfs1(v);       }   }   int dfs2(int u) {     int max = 0;     for (int i = hed[u], v = to[i]; i; i = nxt[i], v = to[i])       if (v ^ f[u][0]) {         max = std::max(max, dfs2(v));       }     if (!max) {       ans++;       max = dp[u];     }     return max - 1;   }   int main() {     read(n), read(m), read(s);     for (int i = 1; i <= n; i++) {       read(a[i]);       if (a[i] > s) {         puts( -1 );         return 0;       }     }     for (int i = 2; i <= n; i++) {       read(x);       add_edge(x, i);     }     dfs1(1);     for (int i = 1; i < 20; i++)       for (int j = 1; j <= n; j++) {         f[j][i] = f[f[j][i - 1]][i - 1];         g[j][i] = g[f[j][i - 1]][i - 1] + g[j][i - 1];       }     for (int k = 1, u = k; k <= n; k++, u = k) {       int stp = 1, sum = a[u];       for (int i = 19; i >= 0; i--)         if ((stp + (1 << i)) <= m && (sum + g[u][i]) <= s && f[u][i]) {           stp += 1 << i;           sum += g[u][i];           u = f[u][i];         }       dp[k] = stp;     }     dfs2(1);     print(ans,   n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool light[123456];   vector<int> v[123456];   bool visited[123456];   int connected[123456];   int main() {     int n;     cin >> n;     string s, t;     vector<string> rat, man, woman, child, capt;     for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));          i += 1 - 2 * ((0) > (n))) {       cin >> s >> t;       if (t ==  rat )         rat.push_back(s);       else if (t ==  captain )         capt.push_back(s);       else if (t ==  woman  || t ==  child )         woman.push_back(s);       else if (t ==  man )         man.push_back(s);     }     for (__typeof(rat.size()) i = (0) - ((0) > (rat.size()));          i != (rat.size()) - ((0) > (rat.size()));          i += 1 - 2 * ((0) > (rat.size())))       cout << rat[i] << endl;     for (__typeof(woman.size()) i = (0) - ((0) > (woman.size()));          i != (woman.size()) - ((0) > (woman.size()));          i += 1 - 2 * ((0) > (woman.size())))       cout << woman[i] << endl;     for (__typeof(man.size()) i = (0) - ((0) > (man.size()));          i != (man.size()) - ((0) > (man.size()));          i += 1 - 2 * ((0) > (man.size())))       cout << man[i] << endl;     cout << capt[0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       if (arr[0] < arr[n - 1]) {         cout <<  YES  << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int B = 172, N = 44005;   using ll = long long;   using Bit = bitset<B>;   unordered_map<Bit, int> mp;   Bit aa, a[N];   bool vis[20][N];   int cnt = 1, nxt[N][10];   ll dp[20][10][N];   int b[20];   ll solve(ll n, int kk) {     if (!n) return 1;     int m = 0, pos = 1;     while (n) b[m++] = n % 10, n /= 10;     ll ret = 0;     for (int i = m - 1; i >= 0; --i) {       for (int j = 0; j < b[i] + !i; j++) ret += dp[i][kk][nxt[pos][j]];       pos = nxt[pos][b[i]];     }     return ret;   }   int main() {     ios::sync_with_stdio(false);     aa[0] = 1;     a[mp[aa] = 1] = aa;     vis[0][1] = 1;     for (int i = 1; i < 20; i++)       for (int p = 1; p <= cnt; p++)         if (vis[i - 1][p])           for (int j = 0; j < 10; j++) {             if (!nxt[p][j]) {               if (!j)                 nxt[p][j] = p;               else {                 aa.reset();                 for (int k = j; k < B; k++)                   if (a[p][k]) aa[k - j] = 1;                 for (int k = 0; k < B - j; k++)                   if (a[p][k]) aa[k + j] = 1;                 for (int k = 1; k < j; k++)                   if (a[p][k]) aa[j - k] = 1;                 if (mp.count(aa))                   nxt[p][j] = mp[aa];                 else                   a[nxt[p][j] = mp[aa] = ++cnt] = aa;               }             }             vis[i][nxt[p][j]] = 1;           }     for (int j = 1; j <= cnt; j++) {       int k = 0;       while (k < 10)         if (!a[j][k])           ++k;         else           break;       while (k < 10) dp[0][k++][j] = 1;     }     for (int j = 1; j < 19; j++)       for (int k = 1; k <= cnt; k++)         if (vis[19 - j][k])           for (int i = 0; i < 10; i++)             for (int l = 0; l < 10; l++) dp[j][l][k] += dp[j - 1][l][nxt[k][i]];     int T;     cin >> T;     while (T--) {       ll l, r;       cin >> l >> r;       int kk;       cin >> kk;       cout << solve(r, kk) - solve(l - 1, kk) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> nextInt(const string &s, int ind) {     int ret = 0;     while (ind < s.length() && s[ind] >=  0  && s[ind] <=  9 ) {       ret = ret * 10 + ((int)s[ind] - 48);       ind++;     }     return make_pair(ret, ind);   }   int main() {     int counti = 0;     int n;     int w[1024];     vector<vector<int> > input;     for (int i = 0; i < 1024; i++) {       w[i] = 0;     }     cin >> n;     counti = n;     input.resize(n + 10);     for (int i = 1; i <= n; i++) {       input[i].push_back(-1);       string in;       cin >> in;       if (nextInt(in, 0).first == n - 1) {         w[i] = 1;       } else {         int ind = 0;         while (in[ind]) {           if (in[ind] >=  0  && in[ind] <=  9 ) {             pair<int, int> ret = nextInt(in, ind);             ind = ret.second;             input[i].push_back(ret.first);           } else if (in[ind] ==  - ) {             input[i].push_back(-1);             ind++;             counti++;           } else             ind++;         }       }     }     int weight = 1;     vector<pair<int, int> > ans;     while (weight < n) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j < input[i].size(); j++)           if (input[i][j - 1] == -1 && input[i][j] == weight)             for (j = j + 1; j < input[i].size() && input[i][j] != -1; j++)               if (w[input[i][j]] == weight) {                 ans.push_back(make_pair(i, input[i][j]));                 if (w[i] == 0)                   w[i] = weight + 1;                 else                   w[i] += weight;               }       }       weight++;     }     if (n == 2) {       cout <<  1  << endl;       cout <<  1 2 ;       return 0;     }     if (ans.size() != n - 1 || counti != (n - 1) * 2) {       cout << -1;       return 0;     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vis[15];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int a[3];       memset(vis, 0, sizeof(vis));       for (int i = 0; i < 3; i++) cin >> a[i];       int ans = 0;       for (int i = 0; i < 3; i++) {         if (a[i] - 1 >= 0) {           a[i]--;           ans++;         }         vis[a[i]]++;       }       if (vis[0] == 1 || vis[1] == 3)         printf( %d n , ans + 1);       else if (vis[0] == 2 || vis[0] == 3)         printf( %d n , ans);       else if (vis[1] == 1 || vis[1] == 2)         printf( %d n , ans + 2);       else if (vis[2])         printf( %d n , ans + 3);       else         printf( %d n , ans + 4);     }   }
#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...);   }   vector<pair<int, string> > ar[10005];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       int a, b;       string s;       cin >> s >> a >> b;       ar[a].push_back({-b, s});     }     for (int i = 1; i <= m; i++) {       sort(ar[i].begin(), ar[i].end());       if ((int)(ar[i].size()) == 2)         cout << ar[i][0].second <<     << ar[i][1].second <<   n ;       else if (ar[i][1].first != ar[i][2].first)         cout << ar[i][0].second <<     << ar[i][1].second <<   n ;       else         cout <<  ? n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[5000];   int main() {     int t;     cin >> t;     while (t--) {       long long a, b, c, d;       cin >> a >> b >> c >> d;       long long p1 = b * c, p2 = (a - c - 1) * b, p3 = a * d,                 p4 = a * (b - d - 1);       cout << max(max(p1, p2), max(p3, p4)) << endl;     }   }
#include <bits/stdc++.h>   const int maxn = 3e5 + 7;   int ch[maxn << 5][2], max[maxn << 5], n, q, k, l[maxn], r[maxn], id[maxn],       rk[maxn], a, b, x, y, tl, rt[maxn];   int cmp(int x, int y) { return r[x] < r[y]; }   int insert(int rt, int L, int R, int p, int v) {     int nrt = ++tl;     ch[nrt][0] = ch[rt][0];     ch[nrt][1] = ch[rt][1];     max[nrt] = max[rt];     if (L == R) {       max[nrt] = std::max(max[nrt], v);       return nrt;     }     int mid = (L + R) >> 1;     if (p <= mid)       ch[nrt][0] = insert(ch[rt][0], L, mid, p, v);     else       ch[nrt][1] = insert(ch[rt][1], mid + 1, R, p, v);     max[nrt] = std::min(max[ch[nrt][0]], max[ch[nrt][1]]);     return nrt;   }   int query(int rt, int l, int r, int L, int R) {     if (l > R || r < L) return 1e9;     if (l <= L && R <= r) return max[rt];     return std::min(query(ch[rt][0], l, r, L, (L + R) >> 1),                     query(ch[rt][1], l, r, ((L + R) >> 1) + 1, R));   }   int main() {     scanf( %d%d%d , &n, &q, &k);     for (int i = 1; i <= k; ++i) {       scanf( %d%d%d , &l[i], &r[i], &id[i]);       rk[i] = i;     }     std::sort(rk + 1, rk + k + 1, cmp);     for (int i = 1; i <= k; ++i) {       rt[i] = insert(rt[i - 1], 1, n, id[rk[i]], l[rk[i]]);     }     while (q--) {       scanf( %d%d%d%d , &a, &b, &x, &y);       int L = 0, R = k, p;       while (L <= R) {         int mid = (L + R) >> 1;         if (r[rk[mid]] <= y) {           p = mid;           L = mid + 1;         } else           R = mid - 1;       }       if (query(rt[p], a, b, 1, n) >= x)         puts( yes );       else         puts( no );       fflush(stdout);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans, cnt;   struct Node {     Node *Left = NULL, *Right = NULL;     int value, fix, sz = 1;     long long sum[5] = {};   };   typedef Node *PNode;   PNode root = NULL;   inline int gts(PNode &cur) {     if (cur == NULL) return 0;     return cur->sz;   }   Node nodes[111111];   inline void Init(PNode &cur) {     if (cur) {       cur->sz = gts(cur->Left) + gts(cur->Right) + 1;       int t = 0;       if (cur->Left) {         for (int i = 0; i < 5; ++i) cur->sum[i] = cur->Left->sum[i];         t = cur->Left->sz % 5;       } else {         for (int i = 0; i < 5; ++i) cur->sum[i] = 0;       }       cur->sum[t] += cur->value;       t++;       t %= 5;       if (cur->Right) {         for (int i = 0; i < 5; ++i) {           int T = i + t;           T %= 5;           cur->sum[T] += cur->Right->sum[i];         }       }     }   }   inline void make(PNode a, PNode b, PNode &c) {     if (!b or !a) {       c = b ? b : a;       return;     }     if (a->fix > b->fix) {       make(a->Right, b, a->Right);       c = a;     } else {       make(a, b->Left, b->Left);       c = b;     }     Init(c);   }   inline void split(PNode t, PNode &a, PNode &b, int f) {     if (!t) {       a = b = NULL;       return;     }     if (f < t->value) {       split(t->Left, a, t->Left, f);       b = t;     } else {       split(t->Right, t->Right, b, f);       a = t;     }     Init(t);   }   inline void Insert(int val) {     PNode a, b, c;     split(root, a, c, val);     nodes[cnt].value = val;     nodes[cnt].fix = rand();     b = nodes + cnt++;     Init(b);     make(a, b, root);     make(root, c, root);   }   inline void Delete(PNode &cur, int val) {     if (cur->value == val) {       make(cur->Left, cur->Right, cur);     } else if (val < cur->value) {       Delete(cur->Left, val);     } else       Delete(cur->Right, val);     Init(cur);   }   inline int Find_Min(PNode cur) {     while (cur->Left) cur = cur->Left;     return cur->value;   }   inline int Find_Max(PNode cur) {     while (cur->Right) cur = cur->Right;     return cur->value;   }   int main() {     ios_base::sync_with_stdio(false);     int n, x, y, i, count = 0;     string s;     cin >> n;     for (i = 0; i < n; ++i) {       cin >> s;       if (s ==  add ) {         cin >> x;         count++;         Insert(x);       } else if (s ==  del ) {         cin >> x;         count--;         Delete(root, x);       } else {         if (!count)           printf( %d n , 0);         else           printf( %I64d n , root->sum[2]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int a[200005], b[200005], c[200005];   class Myfirst {    private:     string *name;     long long int *age;       public:     long long int gcd(long long int a, long long int b) {       if (b == 0) return a;       a %= b;       return gcd(b, a);     }     long long int exte_gcd(long long int a, long long int b, long long int &x,                            long long int &y) {       if (b == 0) {         x = 1;         y = 0;         return a;       }       long long int x1, y1;       long long int d = exte_gcd(b, a % b, x1, y1);       x = y1;       y = x1 - y1 * (a / b);       return d;     }     long long int powe(long long int d, long long int s) {       if (s == 1)         return d;       else if (s == 0)         return 1;       else {         long long int u, v = d;         for (u = 1; u < s; u++) d = d * v;         return d;       }     }     long long int count_divisors(long long int b) {       long long int i, count = 0, n = 1;       for (i = 2; i * i <= b; i++) {         count = 0;         if (b % i == 0) {           while (b % i == 0) {             b = b / i;             count++;           }           n = n * (count + 1);         }       }       if (b > 1) n = 2 * n;       return n;     }     long long int bigmod(long long int a, long long int b, long long int mod) {       if (b == 0) return 1;       long long int x = bigmod(a, b / 2, mod);       x = (x * x) % mod;       if (b % 2) x = (x * a) % mod;       return x;     }     long long int phi(long long int n) {       double result = n;       for (long long int p = 2; p * p <= n; ++p) {         if (n % p == 0) {           while (n % p == 0) n /= p;           result *= (1.0 - (1.0 / (double)p));         }       }       if (n > 1) result *= (1.0 - (1.0 / (double)n));       return (long long int)result;     }     void solve() {       long long int t;       t = 1;       while (t--) {         long long int n, m, k, i, j, A, B;         cin >> n;         for (i = 1; i <= n; i++) cin >> a[i];         cin >> m;         for (i = 1; i <= m; i++) cin >> b[i];         cin >> k;         for (i = 1; i <= k; i++) cin >> c[i];         cin >> A >> B;         sort(a + 1, a + n + 1);         sort(b + 1, b + m + 1);         sort(c + 1, c + k + 1);         double ans;         ans = ((c[1] * 1.0) / b[m]) * ((A * 1.0) / B);         ans += 1.0;         ans = sqrt(1.0 / ans);         cout << setprecision(10);         cout << ans * a[n];       }     }   };   int main() {     Myfirst *prg = new Myfirst();     prg->solve();   }
#include <bits/stdc++.h>   int main() {     int n, i, m;     char a[205];     scanf( %s , a);     n = strlen(a);     for (i = 0; i < n; i++) {       if (a[i] ==  W ) {         if (a[i + 1] ==  U ) {           if (a[i + 2] ==  B ) {             a[i] =    ;             a[i + 1] =    ;             a[i + 2] =    ;           }         }       }       printf( %c , a[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> s;   map<string, bool> was;   int main() {     int n;     cin >> n;     s.resize(n);     for (int i = 0; i < n; i++) {       cin >> s[i];     }     for (int i = n - 1; i >= 0; i--) {       if (!was[s[i]]) {         cout << s[i] <<   n ;         was[s[i]] = true;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       vector<vector<ll>> a(n + 1, vector<ll>(m + 1));       for (int i = 1; i <= n; ++i) {         for (int j = 1; j <= m; ++j) {           cin >> a[i][j];         }       }       const ll I = 1e18;       ll b = I;       for (int i = 1; i <= n; ++i) {         for (int j = 1; j <= m; ++j) {           vector<vector<ll>> c(n + 1, vector<ll>(m + 1, I));           c[0][1] = c[1][0] = 0;           for (int g = 1; g <= n; ++g) {             for (int h = 1; h <= m; ++h) {               ll y = a[g][h] - (a[i][j] - (i - g) - (j - h));               if (y >= 0) {                 c[g][h] = min(c[g - 1][h] + y, c[g][h - 1] + y);               }             }           }           b = min(b, c[n][m]);         }       }       cout << b << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++)       if (a[i] % 2 == 0) a[i]--;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, a1, a2, b1, b2, max1, max2;     cin >> t;     while (t > 0) {       cin >> a1 >> b1;       cin >> a2 >> b2;       max1 = max(a1, b1);       max2 = max(a2, b2);       if (max1 == max2) {         int min1, min2;         min1 = min(a1, b1);         min2 = min(a2, b2);         if ((min1 + min2) == max1) {           cout <<  Yes  << endl;         } else {           cout <<  No  << endl;         }       } else {         cout <<  No  << endl;       }       t--;     }     return 0;   }