malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 4000010, maxm = 2010;   long long s[maxn], f[maxn], P[maxm], Q[maxm];   int a, b, c, p[maxm], vis[maxm], mu[maxm];   void inc(long long &a, long long b) {     a += b;     if (a > (1ll << 30)) a -= (1ll << 30);   }   int main() {     scanf( %d%d%d , &a, &b, &c);     mu[1] = 1;     for (int i = 2; i <= c; i++) {       if (!vis[i]) p[++p[0]] = i, mu[i] = -1;       for (int j = 1; j <= p[0] && i * p[j] <= c; j++) {         vis[i * p[j]] = 1;         if (i % p[j] == 0) {           mu[i * p[j]] = 0;           break;         } else           mu[i * p[j]] = -mu[i];       }     }     for (int i = 1; i <= a; i++)       for (int j = 1; j <= b; j++) f[i * j]++;     for (int i = 1; i <= a * b; i++)       for (int j = 1; j <= a * b / i; j++) inc(s[i], f[i * j]);     for (int i = 1; i <= c; i++)       for (int j = 1; j <= a * b / i; j++) inc(P[i], s[i * j]);     for (int i = 1; i <= c; i++)       for (int j = 1; j <= i; j++) inc(Q[i], i / j);     long long ans = 0;     for (int i = 1; i <= c; i++)       ans = (ans + mu[i] * P[i] * Q[c / i] % (1ll << 30)) % (1ll << 30);     printf( %I64d , (ans + (1ll << 30)) % (1ll << 30));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     while (a--) {       int b, c;       cin >> b >> c;       int arr1[b], arr2[c];       set<int> check;       for (int j = 0; j < b; j++) {         cin >> arr1[j];         check.insert(arr1[j]);       }       int x = -1;       for (int j = 0; j < c; j++) {         cin >> arr2[j];         if (check.count(arr2[j])) x = arr2[j];       }       if (x == -1)         cout <<  NO n ;       else {         cout <<  YES n ;         cout <<  1               <<     << x <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > g[110];   int seen[110][110];   int c[110];   int ans;   void dfs(int s, int end, int color) {     if (s == end && c[color] == 0) {       c[color] = 1;       ans++;       return;     }     for (int i = 0; i < (int)g[s].size(); i++) {       if ((color == 0 || color == g[s][i].second) &&           seen[s][g[s][i].first] == 0 && seen[g[s][i].first][s] == 0) {         seen[s][g[s][i].first] = 1;         seen[g[s][i].first][s] = 1;         dfs(g[s][i].first, end, g[s][i].second);         seen[s][g[s][i].first] = 0;         seen[g[s][i].first][s] = 0;       }     }   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     int temp1, temp2, temp3;     for (int i = 0; i < m; i++) {       scanf( %d %d %d , &temp1, &temp2, &temp3);       g[temp1].push_back(pair<int, int>(temp2, temp3));       g[temp2].push_back(pair<int, int>(temp1, temp3));     }     int q;     scanf( %d , &q);     for (int i = 0; i < q; i++) {       scanf( %d %d , &temp1, &temp2);       dfs(temp1, temp2, 0);       printf( %d n , ans);       ans = 0;       for (int i = 0; i < 110; i++)         for (int j = 0; j < 110; j++) seen[i][j] = 0;       for (int i = 0; i < 110; i++) c[i] = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n, t, m = 0;     cin >> n;     vector<int> s;     for (int i = 0; i < n; i++) {       cin >> t;       s.push_back(t);     }     sort(s.begin(), s.end());     while (true) {       t = -1;       for (int i = 0; i < n; i++) {         if (s[i] != -1 && s[i] >= t + 1) {           s[i] = -1;           t++;         }       }       if (t == -1) break;       m++;     }     cout << m << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[20][20], ans[20];   int n, m;   bool isValid() {     for (int i = 2; i <= n; i++) {       int c = 0;       for (int j = 1; j <= m; j++) c += (ans[j] != a[i][j]);       if (c > 1) return false;     }     return true;   }   void fun() {     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> (a[i] + 1);     for (int i = 1; i <= m; i++) ans[i] = a[1][i];     ans[m + 1] =   0 ;     if (isValid())       cout << (ans + 1) <<   n ;     else {       bool isGood = false;       for (int i = 1; i <= m && !isGood; i++) {         for (char c =  a ; c <=  z  && !isGood; c++) {           if (c != a[1][i]) {             ans[i] = c;             if (isValid()) {               cout << (ans + 1) <<   n ;               isGood = true;             }           }         }         ans[i] = a[1][i];       }       if (!isGood) cout <<  -1 n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       fun();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   int main() {     int n, x = 500;     scanf( %d , &n);     for (int i = 0; i < 26 and (n or !i); i++) {       while (x * (x - 1) / 2 > n) x--;       n -= x * (x - 1) / 2;       for (int j = 0; j < x; j++) printf( %c , char(i + 97));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100005];   int n, k, cnt[20];   bool a[20][20], mark[1 << 17], tmp[1 << 17];   inline void work(int x, int y) {     memset(tmp, 0, sizeof(tmp));     for (int i = 1, j, t; i <= n;) {       while (i <= n && s[i] -  a  != x) i++;       j = i + 1;       t = 0;       while (j <= n && s[j] -  a  != x && s[j] -  a  != y) {         t |= 1 << s[j] -  a ;         j++;       }       if (j > n) break;       if (s[j] -  a  == y) tmp[t] = 1;       if (s[j] -  a  == x)         i = j;       else         i = j + 1;     }     for (int i = 1; i < 1 << k; i++) {       if (!tmp[i]) continue;       mark[i] = 1;       for (int j = 0; j < k; j++)         if (j != x && j != y) tmp[i | 1 << j] = 1;     }   }   bool f[1 << 17];   int main() {     cin >> n >> k;     scanf( %s , s);     for (int i = 0; i < n; i++) cnt[s[i] -  a ]++;     for (int i = 0; i < k; i++)       for (int j = 0; j < k; j++) {         cin >> a[i][j];         if (!a[i][j]) work(i, j);       }     f[0] = 1;     for (int i = 0; i < 1 << k; i++) {       if (!f[i]) continue;       for (int j = 0; j < k; j++)         if (!mark[i | 1 << j]) f[i | 1 << j] = 1;     }     int ans = 0;     for (int i = 0; i < 1 << k; i++) {       if (!f[i]) continue;       int t = 0;       for (int j = 0; j < k; j++)         if (i & 1 << j) t += cnt[j];       ans = max(ans, t);     }     cout << n - ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   void add(int &a, int b) {     a += b;     if (a >= MOD) a -= MOD;   }   int n, K, C[1003][1003], fac[1003];   int dp[1003][1003][2][2], ans[1003];   int main() {     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++)         add(C[i][j], C[i - 1][j]), add(C[i][j], C[i - 1][j - 1]);     }     fac[0] = 1;     for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;     dp[0][0][1][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j <= i - 1; j++)         for (int k = 0; k < 2; k++)           for (int l = 0; l < 2; l++)             if (dp[i - 1][j][k][l] > 0) {               add(dp[i][j][l][0], dp[i - 1][j][k][l]);               if (!k) add(dp[i][j + 1][l][0], dp[i - 1][j][k][l]);               if (i < n) add(dp[i][j + 1][l][1], dp[i - 1][j][k][l]);             }     for (int i = 0; i <= n; i++) {       for (int j = 0; j < 2; j++)         for (int k = 0; k < 2; k++) add(ans[i], dp[n][i][j][k]);       ans[i] = 1ll * ans[i] * fac[n - i] % MOD;     }     int cur = -1;     for (int i = K + 1; i <= n; i++) {       add(ans[K], (1ll * cur * C[i][K] % MOD * ans[i] % MOD + MOD) % MOD);       cur *= -1;     }     printf( %d , ans[K]);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 10;   const long long inf = 1e15;   const int mod = 1e6;   void faster() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   const long long N = 3000 * 200;   int mark[N];   int main() {     faster();     int n;     cin >> n;     int t = 0;     vector<int> v[n];     for (int i = 1; i <= n * n; i++) {       v[(i + t) % n].push_back(i);       if (i % n == 0) t++;     }     for (int i = 0; i < n; i++) {       for (auto c : v[i]) cout << c <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 5;   const long long mod = 99999997;   long long a[maxn], k, n;   void dfs(long long l, long long r) {     if (l + 1 >= r || !k) return;     long long mid = (l + r) / 2;     k -= 2;     swap(a[mid - 1], a[mid]);     dfs(l, mid);     dfs(mid, r);   }   int main() {     cin >> n >> k;     if (k > 2 * n - 1 || k % 2 == 0) {       cout <<  -1  << endl;       return 0;     }     for (int i = 0; i < n; i++) {       a[i] = i + 1;     }     k--;     dfs(0ll, n);     for (int i = 0; i < n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void smax(T &x, T y) {     x = max((x), (y));   }   template <class T>   inline void smin(T &x, T y) {     x = min((x), (y));   }   inline void scanInt(int &x) {     register char c = getchar();     x = 0;     bool neg = false;     while (c < 48 || c > 57) {       if (c ==  - ) neg = true;       c = getchar();     }     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }     if (neg) x *= -1;   }   int n, m;   string origin;   string s;   bool place_char_start(int inx) {     if (inx >= 2) {       for (char i = s[inx] + 1; i <  a  + m; i++)         if (i != s[inx - 1] && i != s[inx - 2] && i != s[inx]) {           s[inx] = i;           return true;         }       return false;     } else if (inx == 1) {       for (char i = s[inx] + 1; i <  a  + m; i++)         if (i != s[inx - 1] && i != s[inx]) {           s[inx] = i;           return true;         }       return false;     } else if (inx == 0) {       s[0] = s[0] + 1;       if (s[0] >=  a  + m) return false;       return true;     }     return false;   }   bool place_char(int inx) {     if (inx >= 2) {       for (char i =  a ; i <  a  + m; i++)         if (i != s[inx - 1] && i != s[inx - 2]) {           s[inx] = i;           return true;         }       return false;     } else if (inx == 1) {       for (char i =  a ; i <  a  + m; i++)         if (i != s[inx - 1]) {           s[inx] = i;           return true;         }     } else if (inx == 0) {       s[0] =  a ;       return true;     }     return false;   }   int main(int argc, const char *argv[]) {     scanInt(n);     scanInt(m);     cin >> s;     origin = s;     for (int i = (int)s.size() - 1; i >= 0; i--) {       s = origin;       bool ok = true;       ok &= place_char_start(i);       for (int j = i + 1; ok && j < s.size(); j++) {         if (place_char(j) == false) ok = false;       }       if (ok) {         cout << s;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct event {     int x[3], id;     event() { x[0] = x[1] = x[2] = id = 0; }     event(int xx, int yy, int zz, int idd) {       x[0] = xx;       x[1] = yy;       x[2] = zz;       id = idd;     }   };   int vc = 0;   bool operator<(const event &a, const event &b) {     if (a.x[vc] == b.x[vc]) return a.id < b.id;     return a.x[vc] < b.x[vc];   }   int ans[100005], ans_id[100005];   event G[3][200005];   void cdq(int L, int R, int now) {     if (L >= R) return;     vc = now;     if (now == 2) {       int last = -1, last_id = -1;       for (int i = L; i <= R; ++i) {         if (G[now][i].id > 0) {           if (last_id != -1) {             int &tmp = ans[G[now][i].id];             if (tmp == -1 || tmp < last) {               tmp = last;               ans_id[G[now][i].id] = last_id;             }           }         } else {           last = G[now][i].x[2];           last_id = -G[now][i].id;         }       }       return;     }     int mid = (L + R) / 2, cnt = 0;     cdq(L, mid, now);     for (int i = L; i <= mid; ++i)       if (G[now][i].id < 0) G[now + 1][++cnt] = G[now][i];     for (int i = mid + 1; i <= R; ++i)       if (G[now][i].id > 0) G[now + 1][++cnt] = G[now][i];     vc = now + 1;     sort(G[now + 1] + 1, G[now + 1] + cnt + 1);     cdq(1, cnt, now + 1);     cdq(mid + 1, R, now);   }   int main() {     int n, m, i, j, k, l, cnt = 0;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; ++i) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       G[0][++cnt] = event(x, -y, -z, -i);     }     for (i = 1; i <= m; ++i) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       G[0][++cnt] = event(x, -y, -z, i);     }     memset(ans, -1, sizeof(ans));     memset(ans_id, -1, sizeof(ans));     vc = 0;     sort(G[0] + 1, G[0] + 1 + cnt);     cdq(1, cnt, 0);     for (i = 1; i <= m; ++i) printf( %d%c , ans_id[i],    n [i == m]);   }
#include <bits/stdc++.h>   using namespace std;   vector<multiset<int> > G;   vector<int> d;   void dfs(int u, vector<int> &ans) {     while (!G[u].empty()) {       int v = *G[u].begin();       G[u].erase(G[u].begin());       G[v].erase(G[v].find(u));       dfs(v, ans);     }     ans.push_back(u);   }   int main() {     int n, m;     cin >> n >> m;     G.resize(n);     d.resize(n, 0);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d %d , &u, &v);       u--;       v--;       G[u].insert(v);       G[v].insert(u);       d[u]++;       d[v]++;     }     vector<int> odd;     for (int i = 0; i < n; i++) {       if (d[i] & 1) odd.push_back(i);     }     int add = 0;     for (int i = 0; i < (int)odd.size() - 1; i += 2) {       int u = odd[i], v = odd[i + 1];       G[u].insert(v);       G[v].insert(u);       add++;     }     if (odd.size() & 1) {       int u = odd[odd.size() - 1];       G[u].insert(u);       G[u].insert(u);       add++;     }     if ((m + add) % 2) {       G[0].insert(0);       G[0].insert(0);       add++;     }     vector<int> ans;     dfs(0, ans);     cout << m + add << endl;     for (int i = 0; i < (int)ans.size() - 1; i++) {       if (i & 1)         printf( %d %d n , ans[i] + 1, ans[i + 1] + 1);       else         printf( %d %d n , ans[i + 1] + 1, ans[i] + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int arr[30] = {0};     unsigned long long sum = 0;     long long int a, b, n;     cin >> n;     for (int i = 0; i < n; i++) {       int j = 0;       cin >> a;       while (a != 0) {         b = a % 10;         arr[j] += b;         arr[j + 1] += b;         a /= 10;         j += 2;       }     }     for (unsigned long long int i = 0, ten = 1; i < 30; i++, ten = ten * 10) {       if (!arr[i]) continue;       arr[i] *= n;       unsigned long long x =           ((arr[i] % 998244353) * (ten % 998244353)) % 998244353;       sum = (sum + x) % 998244353;     }     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int main() {     int n;     cin >> n;     long long int x = 2;     double d;     long long int p;     for (long long int i = 1; i <= n; i++) {       long long int B = i * (i + 1) * (i + 1) - x / i;       cout << B <<   n ;       x = i * (i + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   string grid[8];   int get_weight(char c) {     switch (c) {       case  q :         return 9;       case  r :         return 5;       case  b :       case  n :         return 3;       case  p :         return 1;       default:         return 0;     }   }   int main() {     ios_base::sync_with_stdio(0);     for (int i = 0; i < 8; ++i) cin >> grid[i];     int black = 0, white = 0;     for (int i = 0; i < 8; ++i)       for (int j = 0; j < 8; ++j) {         bool play1 = isupper(grid[i][j]);         int score = get_weight(tolower(grid[i][j]));         if (play1)           black += score;         else           white += score;       }     if (black == white)       cout <<  Draw ;     else if (black > white)       cout <<  White ;     else       cout <<  Black ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   char s[21][100100];   int n, m, ans = 1e9, all, inv, a[100100], bit[1100000], w[1100000], f[1100000];   int power(int a, int k) {     int ret = 1;     while (k) {       if (k & 1) ret = 1ll * ret * a % mod;       a = 1ll * a * a % mod;       k >>= 1;     }     return ret;   }   void FWT(int *a, int t) {     int pre, cur = 0;     static int f[2][1100000];     for (int i = 0; i <= all; i++) f[0][i] = a[i];     for (int i = 0; i <= n - 1; i++) {       pre = cur, cur ^= 1;       for (int s = 0; s <= all; s++)         if (!(s >> i & 1)) {           int l = f[pre][s], r = f[pre][s | (1 << i)];           f[cur][s] = (l + r) % mod;           f[cur][s | (1 << i)] = (l + mod - r) % mod;         }     }     if (t)       for (int i = 0; i <= all; i++) f[cur][i] = 1ll * f[cur][i] * inv % mod;     for (int i = 0; i <= all; i++) a[i] = f[cur][i];   }   int main() {     scanf( %d%d , &n, &m);     all = (1 << n) - 1;     inv = power(power(2, mod - 2), n);     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n; j++) a[i] = (a[i] << 1) + s[j][i] -  0 ;     for (int i = 1; i <= all; i++) bit[i] = bit[i >> 1] + (i & 1);     for (int i = 1; i <= m; i++) f[a[i]]++;     for (int i = 0; i <= all; i++) w[i] = min(bit[i], n - bit[i]);     FWT(f, 0);     FWT(w, 0);     for (int i = 0; i <= all; i++) f[i] = 1ll * f[i] * w[i] % mod;     FWT(f, 1);     for (int i = 0; i <= all; i++) ans = min(ans, f[i]);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int lim = 1e5 + 5;   int main(int argc, char const *argv[]) {     int n;     cin >> n;     std::vector<int> v(n);     for (int i = 0; i < n; ++i) {       cin >> v[i];     }     int mn = INT_MAX, ind1, ind2;     for (int i = 0; i < n - 1; ++i) {       int dif = abs(v[i] - v[i + 1]);       if (mn > dif) {         mn = dif;         ind1 = i + 1;         ind2 = i + 2;       }     }     int dif = abs(v[0] - v[n - 1]);     if (mn > dif) {       mn = dif;       ind1 = 1;       ind2 = n;     }     cout << ind1 <<     << ind2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef long long ll;   #define endl   n    const int DIM = 1E5+7;   int A[DIM];   int cnt[2][DIM];   int solve() {       int n;       cin>>n;       for(int i = 1;i<=n;++i){           cin>>A[i];           ++cnt[i%2][A[i]];       }       sort(A+1,A+1+n);       int flag = 0;       for(int i = 1;i<=n;++i){           cnt[i%2][A[i]]--;       }       for(int i = 1;i<=n;++i){           if (cnt[0][A[i]] || cnt[1][A[i]])               flag = 1;           cnt[0][A[i]] = cnt[1][A[i]] = 0;       }       if (flag)           cout<< NO n ;       else cout<< YES n ;          return 1;   }   int main() {       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);          int t;       cin>>t;       while(t--)           assert(solve());   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   string s, t;   int lenX, lenY;   long long dp[5009][5009];   inline long long go(int x, int y) {     if (x < 0 || y < 0) return 0LL;     long long &ret = dp[x][y];     if (ret != -1) return ret;     ret = 0;     if (y > 0) ret = go(x, y - 1);     if (ret >= MOD) ret -= MOD;     if (s[x] == t[y]) {       ret++;       if (x > 0 && y > 0) ret = (ret + go(x - 1, y - 1)) % MOD;     }     return ret;   }   int main() {     memset(dp, -1, sizeof(dp));     cin >> s >> t;     lenX = (int)s.length();     lenY = (int)t.length();     long long ans = 0;     for (int i = 0; i < lenX; ++i) {       ans += go(i, lenY - 1);       if (ans >= MOD) ans -= MOD;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     const int MAXOPER = 1e5 + 123;     const int MAXN = 1e5 + 123;     vector<long long> V;     long long sz = 0;     static long long sz_after[MAXOPER];     static int oper_tip[MAXOPER];     static int oper_l[MAXOPER];     static int oper_c[MAXOPER];     static int oper_x[MAXOPER];     int n_oper;     scanf( %d , &n_oper);     for (int i_oper = 0; i_oper < (n_oper); ++i_oper) {       int tip;       scanf( %d , &tip);       oper_tip[i_oper] = tip;       if (tip == 1) {         int x;         scanf( %d , &x);         oper_x[i_oper] = x;         if ((int)V.size() < MAXN) V.push_back(x);         ++sz;       } else {         int l, c;         scanf( %d %d , &l, &c);         oper_l[i_oper] = l;         oper_c[i_oper] = c;         for (int i = 0; i < (c); ++i) {           if ((int)V.size() >= MAXN) break;           for (int j = 0; j < (l); ++j) {             if ((int)V.size() >= MAXN) break;             V.push_back(V[j]);           }         }         sz += l * c;       }       sz_after[i_oper] = sz;     }     int n_q;     scanf( %d , &n_q);     for (int i_q = 0; i_q < (n_q); ++i_q) {       long long idx;       cin >> idx;       --idx;       int o_idx = upper_bound(sz_after, sz_after + n_oper, idx) - sz_after;       long long sol;       if (oper_tip[o_idx] == 1)         sol = oper_x[o_idx];       else {         sol = V[(idx - sz_after[o_idx - 1]) % oper_l[o_idx]];       }       cout << sol;       if (i_q + 1 < n_q)         cout <<    ;       else         cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m, count = 0;       cin >> n >> m;       string arr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       for (int i = 0; i < (m - 1); i++) {         if (arr[n - 1][i] !=  R ) count++;       }       for (int i = 0; i < (n - 1); i++) {         if (arr[i][m - 1] !=  D ) count++;       }       cout << count << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int z[150005];   long long tir[150005];   int find(int a) {     if (a != z[a]) {       z[a] = find(z[a]);     }     return z[a];   }   void mix(int a, int b) { z[find(a)] = find(b); }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       z[i] = i;       tir[i] = 0;     }     for (int j = 0; j < m; j++) {       int a, b;       scanf( %d%d , &a, &b);       mix(a, b);     }     for (int i = 1; i <= n; i++) {       tir[find(i)]++;     }     long long sum = 0;     for (int i = 1; i <= n; i++) {       sum += ((tir[i] * (tir[i] - 1)) / 2);     }     if (sum == m)       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, t;     cin >> n >> t;     string s;     cin >> s;     while (t--) {       for (long long j = 1; j < n; j++) {         if (s[j - 1] ==  B  && s[j] ==  G ) {           swap(s[j - 1], s[j]);           j++;         }       }     }     cout << s << endl;     ;   }