malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long h, w, n;   pair<long long, long long> a[2005];   long long fact[200005];   long long ifact[200005];   long long dp[2005];   long long exp(long long a, long long b) {     if (b == 0) return 1;     if (b == 1) return a;     if (b % 2 == 0) {       long long r = exp(a, b / 2);       return (r * r) % 1000000007;     }     long long r = exp(a, b - 1);     return (r * a) % 1000000007;   }   long long C(long long n, long long k) {     return (((fact[n] * ifact[k]) % 1000000007) * ifact[n - k]) % 1000000007;   }   int main() {     scanf( %lld %lld %lld , &h, &w, &n);     for (long long i = 0; i < n; i++) {       scanf( %lld %lld , &a[i].first, &a[i].second);       a[i].first--;       a[i].second--;     }     sort(a, a + n);     a[n++] = make_pair(h - 1, w - 1);     fact[0] = 1;     ifact[0] = 1;     for (long long i = 1; i <= max(w, h) * 2; i++) {       fact[i] = (fact[i - 1] * i) % 1000000007;       ifact[i] = exp(fact[i], 1000000007 - 2);     }     for (long long i = 0; i < n; i++) {       long long num = C(a[i].first + a[i].second, a[i].first);       for (long long j = 0; j < i; j++) {         if (a[j].first <= a[i].first && a[j].second <= a[i].second) {           int sub =               (dp[j] * C((a[i].first - a[j].first) + (a[i].second - a[j].second),                          a[i].first - a[j].first)) %               1000000007;           num = (num - sub + 1000000007) % 1000000007;         }       }       dp[i] = num;     }     cout << dp[n - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 2;   int lis[N], where[N], length[N], link[N], a[N], b[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     a[n] = INT_MAX;     int m;     cin >> m;     for (int i = 0; i < m; ++i) {       cin >> b[i];     }     sort(b, b + m);     fill(lis, lis + n + 2, INT_MAX);     fill(where, where + n + 2, -1);     lis[0] = 0;     for (int i = 0; i <= n; ++i) {       if (a[i] == -1) {         int fill = m - 1;         for (int index = n + 1; index > 0; --index) {           while (fill > 0 && b[fill - 1] > lis[index - 1]) {             --fill;           }           if (b[fill] > lis[index - 1] && b[fill] <= lis[index]) {             lis[index] = b[fill], where[index] = i;           }         }         link[i] = i - 1;         while (link[i] >= 0 && a[link[i]] != -1) {           --link[i];         }         length[i] = -1;       } else {         int index = lower_bound(lis, lis + n + 2, a[i]) - lis;         lis[index] = a[i], where[index] = i;         link[i] = where[index - 1];         length[i] = index;       }     }     int index = n, prv = -1;     while (index != -1) {       if (a[index] == -1) {         length[index] = length[prv] - 1;         int fill = m - 1;         while (b[fill] >= a[prv]) {           --fill;         }         a[index] = b[fill];         b[fill] = INT_MAX;         prv = index;         if (length[index] == 1) {           index = -1;         } else {           for (int i = 0; i < index; ++i) {             if (a[i] < a[index] && length[i] + 1 == length[index]) {               index = i;               break;             }           }           if (index == prv) {             index = link[index];           }         }       } else {         prv = index, index = link[index];       }     }     int ptr = 0;     for (int i = 0; i < n; ++i) {       if (a[i] == -1) {         while (b[ptr] == INT_MAX) {           ++ptr;         }         a[i] = b[ptr++];       }       cout << a[i] <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100101;   int pre[maxn], ind[maxn], cnt[maxn], f[maxn];   vector<int> g[maxn], q;   int main() {     int n;     cin >> n;     for (int i = 2; i <= n; ++i) {       int l, r;       scanf( %d%d , &l, &r);       g[l].push_back(r);       g[r].push_back(l);       ind[l]++;       ind[r]++;     }     q.push_back(1);     for (int i = 0; i < q.size(); ++i) {       int now = q[i];       for (int j = 0; j < g[now].size(); ++j)         if (g[now][j] != pre[now]) {           pre[g[now][j]] = now;           q.push_back(g[now][j]);         }     }     bool flag = 1;     for (int i = (int)q.size() - 1; i >= 0; --i) {       int now = q[i];       int k = cnt[now] + (ind[now] > 3);       if (k) f[pre[now]]++;       if (ind[now] > 2) cnt[now]++;       cnt[pre[now]] += cnt[now];     }     int sum = cnt[1];     for (int i = 0; i < q.size(); ++i) {       int now = q[i];       for (int j = 0; j < g[now].size(); ++j)         if (g[now][j] != pre[now]) {           int k = sum - cnt[g[now][j]] - (ind[now] > 2) + (ind[now] > 3);           if (k) f[g[now][j]]++;         }     }     for (int i = 1; i <= n; ++i)       if (f[i] > 2) flag = 0;     if (flag)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int next, to;   } a[400001];   int st[200001], vis[200001], fa[200001], last, cnt = 0, ans = 0, huan;   int roo[200001], roo2[200001];   void add(int x, int y) {     a[++cnt].to = y;     a[cnt].next = st[x];     st[x] = cnt;   }   void dfs(int x, int last) {     int i;     if (vis[x]) {       if (huan == 0) {         huan = 1;         roo[++roo[0]] = x;         roo2[roo[0]] = 1;       }       return;     }     vis[x] = 1;     for (i = st[x]; i; i = a[i].next)       if (a[i].to != last) dfs(a[i].to, x);   }   int main() {     int n, i, j;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &fa[i]);       if (fa[i] == i) continue;       add(fa[i], i);       add(i, fa[i]);     }     for (i = 1; i <= n; i++) {       huan = 0;       if (vis[i] == 0) {         dfs(i, 0);         if (huan == 0) {           for (j = i; fa[j] != j; j = fa[j])             ;           roo[++roo[0]] = j;         }       }     }     for (i = 1; i <= roo[0]; i++)       if (roo2[i] == 0) break;     if (i <= roo[0]) {       ans = roo[0] - 1;       for (j = 1; j <= roo[0]; j++) fa[roo[j]] = roo[i];     } else {       ans = roo[0];       for (j = 1; j <= roo[0]; j++) fa[roo[j]] = roo[1];     }     printf( %d n , ans);     for (i = 1; i <= n; i++) printf( %d  , fa[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, x;     string d;     int t, m = 0;     cin >> n >> x;     for (int i = 0; i < n; i++) {       cin >> d >> t;       if (d[0] ==  + ) x += t;       if (d[0] ==  - ) {         if (x >= t)           x -= t;         else           m++;       }     }     cout << x <<     << m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, pl;   string s;   int main() {     std::ios::sync_with_stdio(false);     cin >> t;     for (int qqw = 1; qqw <= t; qqw++) {       cin >> n;       cin >> s;       pl = -1;       for (int i = 1; i <= n; i++)         if (s[i - 1] ==  0 ) pl = i;       if (pl > 0) {         if (n % 2 == 0) {           if (pl <= n / 2) {             cout << pl <<     << n <<     << pl + 1 <<     << n <<   n ;             continue;           }           cout << 1 <<     << pl <<     << 1 <<     << pl - 1 <<   n ;         } else {           if (pl <= n / 2) {             cout << pl <<     << n <<     << pl + 1 <<     << n <<   n ;             continue;           }           cout << 1 <<     << pl <<     << 1 <<     << pl - 1 <<   n ;         }       } else {         cout << 1 <<     << n - 1 <<     << 2 <<     << n <<   n ;         continue;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct linearbasis {     long long base[64], flag, cnt;     bool add(long long x) {       for (int i = 62; ~i; i--) {         if (x >> i & 1) {           if (!base[i]) {             base[i] = x;             return false;           }           x ^= base[i];         }       }       flag = 1;       return true;     }     long long query_max(long long ans = 0) {       for (int i = 62; ~i; i--) {         if ((ans ^ base[i]) > ans) {           ans ^= base[i];         }       }       return ans;     }     long long query_min() {       for (int i = 0; i <= 62; i++) {         if (base[i]) {           return base[i];         }       }     }     void rebuild() {       cnt = 0;       for (int i = 62; i >= 0; i--) {         for (int j = i - 1; j >= 0; j--) {           if (base[i] >> j & 1) {             base[i] ^= base[j];           }         }       }       for (int i = 0; i <= 62; i++) {         if (base[i]) {           long long temp = base[i];           base[i] = 0;           base[cnt++] = temp;         }       }     }     long long query_k(long long k) {       k -= flag;       if (k == 0) return 0;       if (k >= 1ll << cnt) return -1;       long long ans = 0;       for (int i = 62; ~i; i--) {         if (k >> i & 1) {           ans ^= base[i];         }       }       return ans;     }     void init() { memset(base, 0, sizeof base), flag = cnt = 0; }   } a;   int prime[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29,                  31, 37, 41, 43, 47, 53, 59, 61, 67};   const int mod = 1e9 + 7;   int main() {     int n, ans = 0;     cin >> n;     for (int i = 1; i <= n; i++) {       int x, value = 0;       cin >> x;       for (int j = 0; j < 19; j++) {         int cnt = 0;         while (x % prime[j] == 0) {           cnt++;           x /= prime[j];         }         if (cnt & 1) {           value |= 1 << j;         }       }       if (a.add(value)) {         ans++;       }     }     long long res = 1;     for (int i = 1; i <= ans; i++) {       res = res * 2 % mod;     }     printf( %lld n , res - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());   constexpr int MAXN = 1e9 + 7;   constexpr int INF = 0x3f3f3f3f;   constexpr long long INFLL = 0x3f3f3f3f3f3f3f3f;   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     std::cout.tie(nullptr);     int a, b;     cin >> a >> b;     if (a == b) {       cout << a <<     << 0 <<   n ;     } else {       int ans = min(a, b);       a -= ans;       b -= ans;       int left = max(a, b);       int ans2 = left / 2;       cout << ans <<     << ans2 <<   n ;     }   }
// precompute lookup table for each digit?       #include <iostream>   #include <unordered_map>   #include <utility>   #include <algorithm>   using namespace std;      #define MP make_pair<int, int>      int main()   {       unordered_map<int, int> lookup[10];       lookup[1].insert(MP(0, 1));       lookup[2].insert(MP(0, 2));       lookup[2].insert(MP(1, 21));       lookup[3].insert(MP(0, 3));       lookup[3].insert(MP(1, 13));       lookup[3].insert(MP(2, 23));       lookup[4].insert(MP(0, 4));       lookup[4].insert(MP(2, 14));       lookup[4].insert(MP(1, 41));       lookup[4].insert(MP(3, 43));       lookup[5].insert(MP(0, 5));       lookup[5].insert(MP(1, 51));       lookup[5].insert(MP(2, 52));       lookup[5].insert(MP(3, 53));       lookup[5].insert(MP(4, 54));       lookup[6].insert(MP(0, 6));       lookup[6].insert(MP(4, 16));       lookup[6].insert(MP(2, 26));       lookup[6].insert(MP(1, 61));       lookup[6].insert(MP(3, 63));       lookup[6].insert(MP(5, 65));       lookup[7].insert(MP(0, 7));       lookup[7].insert(MP(3, 17));       lookup[7].insert(MP(6, 27));       lookup[7].insert(MP(2, 37));       lookup[7].insert(MP(5, 47));       lookup[7].insert(MP(1, 57));       lookup[7].insert(MP(4, 67));       lookup[8].insert(MP(0, 8));       lookup[8].insert(MP(2, 18));       lookup[8].insert(MP(4, 28));       lookup[8].insert(MP(6, 38));       lookup[8].insert(MP(1, 81));       lookup[8].insert(MP(3, 83));       lookup[8].insert(MP(5, 85));       lookup[8].insert(MP(7, 87));       lookup[9].insert(MP(0, 9));       lookup[9].insert(MP(1, 19));       lookup[9].insert(MP(2, 29));       lookup[9].insert(MP(3, 39));       lookup[9].insert(MP(4, 49));       lookup[9].insert(MP(5, 59));       lookup[9].insert(MP(6, 69));       lookup[9].insert(MP(7, 79));       lookup[9].insert(MP(8, 89));       int t; cin >> t;       while (t--) {           int q, d; cin >> q >> d;           for (int i = 0; i < q; ++i) {               int x; cin >> x;               int mod = x % d;               if (lookup[d].at(mod) <= x) cout <<  YES  << endl;               else cout <<  NO  << endl;           }       }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 50;   const int mod = 1e9 + 7;   const int inf = (1 << 30);   vector<int> v[maxn][5], tpl;   int ted[maxn], com[maxn], tmp = 1;   bool visited[maxn];   bool dfs(int u, int d) {     visited[u] = 1;     bool rz = (ted[com[u]] == 1);     if (d == 1) {       com[u] = tmp;       ted[tmp]++;     }     for (auto w : v[u][d]) {       if (!visited[w]) {         rz &= dfs(w, d);       }     }     if (d == 0) tpl.push_back(u);     return rz;   }   bool dfs1(int u) {     visited[u] = 1;     bool rz = (ted[com[u]] == 1);     for (auto w : v[u][0])       if (!visited[w]) rz &= dfs1(w);     for (auto w : v[u][1])       if (!visited[w]) rz &= dfs1(w);     return rz;   }   int main() {     ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int a, b;       cin >> a >> b;       v[a][0].push_back(b);       v[b][1].push_back(a);     }     for (int i = 1; i <= n; i++)       if (!visited[i]) dfs(i, 0);     memset(visited, 0, sizeof visited);     for (int i = n - 1; i >= 0; i--) {       int u = tpl[i];       if (!visited[u]) {         dfs(u, 1);         tmp++;       }     }     memset(visited, 0, sizeof visited);     long long ans = n;     for (int i = 1; i <= n; i++) {       if (!visited[i]) {         bool k = dfs1(i);         ans -= k;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long am[20];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<long long> a(n);     for (int i = 0, ThxDem = n; i < ThxDem; ++i) {       cin >> a[i];       for (int j = 0, ThxDem = 20; j < ThxDem; ++j)         if (a[i] & (1 << j)) am[j]++;       a[i] = 0;     }     for (int i = 0, ThxDem = n; i < ThxDem; ++i) {       for (int j = 0, ThxDem = 20; j < ThxDem; ++j)         if (am[j]) a[i] |= 1 << j, am[j]--;     }     long long ans = 0;     for (int i = 0, ThxDem = n; i < ThxDem; ++i) ans += a[i] * a[i];     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:400000000 )   int n, r;   string ans;   pair<int, int> f(int a, int b) {     if (a == 1 && b == 0) return pair<int, int>(0, 0);     if (a > 1 && b == 0) return pair<int, int>(1000000007LL, 1000000007LL);     if (a == 1 && b == 1) return pair<int, int>(1, 0);     if (a > 1 && b == 1) return pair<int, int>(2, a - 2);     pair<int, int> p = f(b, a % b);     return pair<int, int>(p.first + 1, p.second + a / b - 1);   }   void g(int a, int b) {     if (a == 1 && b == 0) return;     if (a == 1 && b == 1) {       ans +=  T ;       return;     }     if (a > 1 && b == 1) {       ans +=  TB ;       for (int i = 0; i < a - 2; i++) ans +=  B ;       return;     }     g(b, a % b);     if (ans[ans.size() - 1] ==  T ) {       ans +=  B ;       for (int i = 0; i < a / b - 1; i++) ans +=  B ;     } else {       ans +=  T ;       for (int i = 0; i < a / b - 1; i++) ans +=  T ;     }   }   int main() {     cin >> n >> r;     int mi = 1000000007LL, best = -1;     for (int i = 1; i < r + 1; i++) {       if (r > 1 && r == i) continue;       pair<int, int> p = f(r, i);       if (p.first + p.second == n && p.second < mi) mi = p.second, best = i;     }     if (best == -1)       cout <<  IMPOSSIBLE ;     else {       g(r, best);       cout << mi << endl << ans;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int U[5005], V[5005];   struct emm {     int a, b, x;   } a[5005];   bool cmp(emm x, emm y) { return x.x < y.x; }   struct Edge {     int v;     Edge *next;   } pool[5005 << 1], *h[5005];   int fa[5005], dep[5005], ans[5005];   int tot;   void addEdge(int u, int v) {     Edge *p = &pool[tot++];     p->v = v;     p->next = h[u];     h[u] = p;   }   void dfs(int u) {     for (Edge *p = h[u]; p; p = p->next) {       int v = p->v;       if (v == fa[u]) continue;       dep[v] = dep[u] + 1;       fa[v] = u;       dfs(v);     }   }   int LCA(int u, int v) {     if (dep[u] < dep[v]) swap(u, v);     while (dep[u] > dep[v]) {       u = fa[u];     }     if (u == v) return u;     while (fa[u] != fa[v]) {       u = fa[u];       v = fa[v];     }     return fa[u];   }   void update(int u, int v, int x) {     if (u == v) return;     while (u != v) {       ans[u] = x;       u = fa[u];     }   }   int check(int u, int v) {     int res = 0x3f3f3f3f;     if (u == v) return res;     while (u != v) {       res = min(res, ans[u]);       u = fa[u];     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &U[i], &V[i]);       addEdge(U[i], V[i]);       addEdge(V[i], U[i]);     }     dep[1] = 1;     dfs(1);     scanf( %d , &m);     for (int i = 1; i <= m; i++) scanf( %d%d%d , &a[i].a, &a[i].b, &a[i].x);     sort(a + 1, a + m + 1, cmp);     for (int i = 1; i <= m; i++) {       int t = LCA(a[i].a, a[i].b);       update(a[i].a, t, a[i].x);       update(a[i].b, t, a[i].x);     }     for (int i = 1; i <= m; i++) {       int t = LCA(a[i].a, a[i].b);       if (min(check(a[i].a, t), check(a[i].b, t)) != a[i].x) {         printf( -1 n );         return 0;       }     }     for (int i = 1; i < n; i++) {       if (dep[U[i]] < dep[V[i]]) swap(U[i], V[i]);       printf( %d  , max(ans[U[i]], 1));     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[1010];     cin >> a;     int l = strlen(a), dot;     for (int i = 0; i < l; i++) {       if (a[i] ==  . ) {         dot = i;       }     }     if (a[dot - 1] ==  9 ) {       cout <<  GOTO Vasilisa.  << endl;     } else {       if (a[dot + 1] >=  5 ) {         a[dot - 1]++;       }       for (int i = 0; i <= dot - 2; i++) {         cout << a[i];       }       cout << a[dot - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 11;   int use[N], a[N], b[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       use[a[i]] = 1;     }     for (int j = 1; j <= n; j++) {       cin >> b[j];       use[b[j]] = 1;     }     int kol = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         int d = a[i] ^ b[j];         if (d <= 2000000 && use[d] == 1) kol++;       }     if (kol % 2 == 0)       cout <<  Karen  << endl;     else       cout <<  Koyomi  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, r, s;   long long F[10005] = {1}, I[10005];   long long inv(long long a) {     long long ans = 1;     for (int k = 998244353 - 2; k; k >>= 1) {       if (k & 1) ans = (ans * a) % 998244353;       a = a * a % 998244353;     }     return ans;   }   long long C(int n, int m) {     return n < m ? 0 : F[n] * I[m] % 998244353 * I[n - m] % 998244353;   }   long long calc(int s, int n, int r) {     if (!n) return !s && r >= 0;     long long ans = 0;     for (int i = 0; i <= n; ++i) {       long long t = C(s - r * i + n - 1, n - 1) * C(n, i) % 998244353;       if (i & 1)         ans = (ans + 998244353 - t) % 998244353;       else         ans = (ans + t) % 998244353;     }     return ans;   }   int main() {     scanf( %d%d%d , &n, &s, &r);     for (int i = 1; i < 10005; ++i) F[i] = F[i - 1] * i % 998244353;     I[10005 - 1] = inv(F[10005 - 1]);     for (int i = 10005 - 1; i; --i) I[i - 1] = I[i] * i % 998244353;     long long ans = 0;     for (int i = max((s + n - 1) / n, r); i <= s; ++i)       for (int c = 1; c <= n && c * i <= s; ++c) {         ans = (ans +                calc(s - c * i, n - c, i) * C(n - 1, c - 1) % 998244353 * inv(c)) %               998244353;       }     ans = ans * inv(C(s - r + n - 1, n - 1)) % 998244353;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1234567;   const double PI = acos(-1.0), EPS = 1e-9;   long long N, arr[MX];   long long gcd(long long a, long long b) {     while (a > 0 && b > 0) {       if (a > b)         a %= b;       else         b %= a;     }     return a + b;   }   int main() {     cin >> N;     long long g = 0;     for (int i = 0; i < N; i++) cin >> arr[i];     for (int i = 0; i < N; i++) {       g = gcd(g, arr[i]);     }     if (g != 1) {       cout <<  YES n ;       cout << 0 <<   n ;       return 0;     }     int oper = 0;     for (int i = 0; i < N; i++) {       if (arr[i] % 2 && arr[i + 1] % 2) {         i++;         oper++;       } else if (arr[i] % 2 && arr[i + 1] % 2 == 0) {         i++;         oper += 2;       }     }     cout <<  YES n ;     cout << oper <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     scanf( %d%d%d , &a, &b, &c);     int ok = 0;     if (a == 1 || b == 1 || c == 1) ok = 1;     if (a == 3 && b == 3 && c == 3) ok = 1;     if (a == 2 && b == 2) ok = 1;     if (b == 2 && c == 2) ok = 1;     if (a == 2 && c == 2) ok = 1;     if (a == 2 && b == 4 && c == 4) ok = 1;     if (a == 4 && b == 2 && c == 4) ok = 1;     if (a == 4 && b == 4 && c == 2) ok = 1;     puts(ok ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       f = ch ==  -  ? -1 : 1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   const int N = 105;   int n, p[N], c[N];   int main() {     int T = read();     while (T--) {       n = read();       for (int i = 1; i <= n; i++) p[i] = read(), c[i] = read();       p[0] = 0;       c[0] = 0;       int fl = 1;       for (int i = 1; i <= n; i++) {         if (c[i] < c[i - 1] || p[i] < p[i - 1]) {           fl = 0;           break;         }         if (c[i] - c[i - 1] > p[i] - p[i - 1]) {           fl = 0;           break;         }       }       if (fl)         puts( YES );       else         puts( NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     char arr[100][100];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> arr[i][j];         if (arr[i][j] ==  - ) {           arr[i][j] =  - ;         } else {           if (i % 2 == 0 && j % 2 == 0) {             arr[i][j] =  B ;           } else if (i % 2 == 0 && j % 2 != 0) {             arr[i][j] =  W ;           } else if (i % 2 != 0 && j % 2 == 0) {             arr[i][j] =  W ;           } else if (i % 2 != 0 && j % 2 != 0) {             arr[i][j] =  B ;           }         }         cout << arr[i][j];       }       cout << endl;     }   }