malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int piles = 1, heavy = 0, num;   int a[110], n;   void solve(int x) {     if (num == 0) {       return;     }     if (heavy <= a[x]) {       a[x] = -1;       heavy++;       num--;       solve(x + 1);     } else if (x < n) {       solve(x + 1);     } else {       for (int i = 1; i <= n; i++) {         if (a[i] != -1) {           a[i] = -1;           num--;           heavy = 1;           piles++;           break;         }       }       solve(1);     }   }   int main() {     cin >> n;     num = n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= i; j++) {         if (a[i] < a[j]) {           swap(a[i], a[j]);         }       }     }     solve(1);     cout << piles;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, nxt[100010], pre[100010];   pair<int, int> b[100010];   struct Frog {     int p, a, id;   } a[100010];   set<pair<int, int> > s;   inline bool operator<(Frog a, Frog b) { return a.p < b.p; }   inline int cal(int i, int j) {     if (i == j) return 0x7fffffff;     int p1 = a[i].p, p2 = a[j].p;     if (i > j) (p2 += a[j].a) %= m;     int d = (p2 - p1 + m) % m, step = (a[i].a - a[j].a);     if (d <= a[i].a) return 1;     if (a[j].a >= a[i].a) return 0x7fffffff;     return (d - a[j].a + step - 1) / step;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++)       scanf( %d%d , &a[i].p, &a[i].a), a[i].p--, b[i] = make_pair(a[i].p, i);     sort(b, b + n);     for (int i = 0; i < n; i++) {       nxt[b[i].second] = b[(i + 1) % n].second;       pre[b[(i + 1) % n].second] = b[i].second;     }     for (int i = 0; i < n; i++) s.insert(make_pair(cal(i, nxt[i]), i));     while (!s.empty()) {       set<pair<int, int> >::iterator it = s.begin();       int i = it->second;       if (it->first == 0x7fffffff) break;       s.erase(it);       s.erase(make_pair(cal(nxt[i], nxt[nxt[i]]), nxt[i]));       s.erase(make_pair(cal(pre[i], i), pre[i]));       a[i].p += cal(i, nxt[i]);       a[i].a--;       nxt[i] = nxt[nxt[i]];       pre[nxt[i]] = i;       s.insert(make_pair(cal(pre[i], i), pre[i]));       s.insert(make_pair(cal(i, nxt[i]), i));     }     printf( %d n , s.size());     for (set<pair<int, int> >::iterator it = s.begin(); it != s.end(); it++)       printf( %d  , it->second + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b, c;     map<char, char> mp;     mp.clear();     int s = 0;     cin >> a;     cin >> b;     cin >> c;     s = c.size();     for (int i = 0; i < 26; i++) {       mp[a[i]] = b[i];     }     for (int i = 0; i < s; i++) {       if (c[i] < 97 && c[i] >= 65) {         c[i] += 32;         cout << char(mp[c[i]] - 32);       } else if (c[i] >= 97)         cout << mp[c[i]];       else         cout << c[i];     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 5;   const long long mod = 1e9 + 7;   const long double PI = acos(-1);   long long n, k;   pair<long long, long long> a[N];   long long ans[N];   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) {       scanf( %lld , &a[i].first);       a[i].second = i;     }     set<int> st;     for (int i = k + 1; i <= k + n; i++) {       st.insert(i);     }     sort(a, a + n);     reverse(a, a + n);     long long out = 0;     for (int i = 0; i < n; i++) {       auto it = st.lower_bound(a[i].second + 1);       out += ((*it - (a[i].second + 1)) * 1ll * a[i].first);       ans[a[i].second] = *it;       st.erase(it);     }     printf( %lld n , out);     for (int i = 0; i < n; i++)       printf( %lld%c , ans[i], (i + 1 == n ?   n  :    ));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int occ[26];   int main() {     string s, p;     cin >> s >> p;     int err = 0;     if (s.size() < p.size()) {       cout << 0 << endl;       return 0;     }     for (int i = 0; i < p.size(); i++) {       occ[p[i] -  a ]++;     }     for (int i = 0; i < p.size(); i++) {       if (s[i] !=  ? ) {         occ[s[i] -  a ]--;         if (occ[s[i] -  a ] == -1) err++;       }     }     int sol = 0;     for (int i = 0; i <= s.size() - p.size(); i++) {       if (err == 0) sol++;       if (i + p.size() == s.size()) break;       if (s[i] !=  ? ) {         occ[s[i] -  a ]++;         if (occ[s[i] -  a ] == 0) err--;       }       if (s[i + p.size()] !=  ? ) {         occ[s[i + p.size()] -  a ]--;         if (occ[s[i + p.size()] -  a ] == -1) err++;       }     }     cout << sol << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1005;   int g[maxn][maxn];   int vis[maxn][maxn];   int cnt[maxn][maxn];   struct node {     int x, y;   } que[maxn * maxn];   int dx[10] = {0, 1, 0, -1, 0};   int dy[10] = {0, 0, 1, 0, -1};   map<char, int> p;   void init() {     p[ U ] = 2;     p[ D ] = 4;     p[ L ] = 3;     p[ R ] = 1;   }   void add(int x1, int y1, int x2, int y2) {     int pp = 0;     if (x1 == x2) {       if (y1 < y2)         pp = 2;       else         pp = 4;     } else {       if (x1 < x2)         pp = 1;       else         pp = 3;     }     g[x2][y2] = pp;     while (x1 != x2 || y1 != y2) {       g[x1][y1] = pp;       x1 += dx[pp];       y1 += dy[pp];     }   }   int main() {     init();     int n, m;     scanf( %d%d , &m, &n);     int x1, y1, x2, y2;     while (m--) {       scanf( %d%d%d%d , &x1, &y1, &x2, &y2);       add(x1, y1, x2, y2);     }     long long t;     char c;     int Q, x, y, vx, vy;     scanf( %d , &Q);     for (int q = 1; q <= Q; q++) {       scanf( %d %d %c %lld , &x, &y, &c, &t);       vx = dx[p[c]];       vy = dy[p[c]];       long long t0 = 0;       while (x >= 0 && x <= n && y >= 0 && y <= n && t > 0) {         if (g[x][y]) {           vx = dx[g[x][y]];           vy = dy[g[x][y]];         }         if (g[x][y] && vis[x][y] == q) {           long long t1 = cnt[x][y];           long long mod = t0 - t1;           t %= mod;           x = que[t1 + t].x;           y = que[t1 + t].y;           break;         }         vis[x][y] = q;         cnt[x][y] = t0;         que[t0].x = x;         que[t0++].y = y;         x += vx;         y += vy;         t--;       }       if (x < 0) x = 0;       if (x > n) x = n;       if (y < 0) y = 0;       if (y > n) y = n;       printf( %d %d n , x, y);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, int> mark;   int32_t main() {     int n;     scanf( %d , &n);     set<long long> s;     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       mark[x]++;       s.insert(x);     }     int p = 0;     long long MX = 0;     while (s.size()) {       long long u = *s.begin();       ((MX) = max((MX), (u)));       mark[u + 1] += mark[u] / 2;       if (mark[u + 1]) s.insert(u + 1);       if (mark[u] % 2) p--;       s.erase(s.begin());     }     return cout << MX + p + 1 << endl, 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int c[5005];   int r[5005];   int p[5005];   int main() {     memset(p, -1, sizeof p);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> c[i];       if (p[c[i]] == -1) {         p[c[i]] = i;       }     }     for (int i = 0; i < n; ++i) {       int o[5005];       memset(o, 0, sizeof o);       o[c[i]] = 1;       r[c[i]] += 1;       int mO = c[i];       for (int j = i + 1; j < n; ++j) {         o[c[j]] += 1;         if (o[c[j]] > o[mO] || (o[c[j]] == o[mO] && c[j] < mO)) {           mO = c[j];         }         r[mO] += 1;       }     }     for (int i = 1; i <= n; ++i) cout << r[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int sum = 0, pos = 0;     string s;     cin >> s;     for (int i = 0; i < s.length(); i++)       sum += min(abs(pos - (s[i] -  a )), 26 - abs(pos - (s[i] -  a ))),           pos = s[i] -  a ;     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[30], col[100100] = {};   int main() {     string s;     cin >> s;     for (int i = 0; i < 26; i++) a[i] = -1;     for (int i = 0; i < s.size(); i++) a[s[i] -  a ] = i;     int p = 25;     for (int i = 0;;) {       while (p >= 0 && a[p] < i) p--;       if (p < 0) break;       int col = 0;       while (i <= a[p]) {         if (s[i] -  a  == p) col++;         i++;       }       for (int j = 0; j < col; j++) cout << s[a[p]];       p--;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(false);     int n, c = 0, fl, i, a, b;     int deg[100005] = {0};     vector<int> v;     cin >> n;     for (i = 0; i < n - 1; i++) {       cin >> a >> b;       deg[a]++;       deg[b]++;     }     for (i = 1; i < n + 1; i++) {       if (deg[i] > 2) {         c++;         fl = i;       }       if (deg[i] == 1) {         v.push_back(i);       }     }     if (c > 1) {       cout <<  No  << endl;       return 0;     }     cout <<  Yes  << endl;     if (n == 2) {       cout << 1 << endl;       cout << 1 <<     << 2 << endl;     } else {       if (c == 0) {         cout << 1 << endl;         cout << v[0] <<     << v[1] << endl;       } else {         cout << v.size() << endl;         for (i = 0; i < v.size(); i++) {           cout << v[i] <<     << fl << endl;         }       }     }   }
#include <bits/stdc++.h>   const long long INF = 1e18;   const long long N = 2e5 + 50;   const long long MOD = 1e9 + 7;   using namespace std;   vector<long long> prime, graph[N];   long long n, k, a[N], m, z;   long long POWER(long long base, long long expo) {     long long ret = 1;     while (expo) {       if (expo & 1) ret = ret * base;       expo >>= 1;       base = base * base;     }     return ret;   }   void SOE(long long n) {     bool isPrime[n + 1];     memset(isPrime, true, sizeof(isPrime));     for (long long p = 2; p <= n; p++) {       if (isPrime[p]) {         for (long long i = p * p; i <= n; i += p) isPrime[i] = false;       }     }     for (long long i = 2; i <= n; i++) {       if (isPrime[i]) prime.push_back(i);     }   }   int main() {     long long test_case = 1;     cin >> test_case;     while (test_case--) {       cin >> n >> k >> z;       for (long long i = 0; i < n; i++) cin >> a[i];       vector<long long> v;       long long ans = 0, m = -1;       for (long long i = 0; i < n; i++) {         if (m < k) {           ans += a[i];           m++;         }       }       for (long long i = 1; i <= k; i++) {         for (long long c = 0; c <= z; c++) {           long long l = k, sum = 0, j = i, times = 0;           while (j < l && times < c) {             if (j == i) {               j--;               sum += a[j];               sum -= a[l];               l--;               times++;             }             if (j < l) {               j++;               sum += a[j];               sum -= a[l];               l--;             }           }           v.push_back(sum);         }       }       sort(v.begin(), v.end());       long long s = 0;       if (v.size() > 0) {         s = v[v.size() - 1];       }       cout << max(ans, ans + s) << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int tcase, nc, np, o, connectable, done;     std::vector<long long int> O;     std::cin >> tcase;     for (int i = 0; i < tcase; i++) {       connectable = 1;       done = 1;       o = 0;       std::cin >> nc >> np;       while (nc > done) {         o++;         done += connectable;         if (done <= np)           connectable = done;         else if (done > np && done < nc) {           connectable = np;           if ((nc - done) % connectable != 0)             o += ((nc - done) / connectable) + 1;           else             o += ((nc - done) / connectable);           break;         }       }       O.push_back(o);     }     for (int i = 0; i < tcase; i++) {       std::cout << O[i] << std::endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 150005;   int n, m;   int a, b;   vector<int> g[N];   bool pos[N];   vector<int> dsu;   bool rez;   bool proveri() {     for (int u = 0; u < dsu.size(); u++)       if (g[dsu[u]].size() != dsu.size() - 1) return false;     return true;   }   void dfs(int cvor) {     pos[cvor] = true;     dsu.push_back(cvor);     for (int v = 0; v < g[cvor].size(); v++)       if (!pos[g[cvor][v]]) dfs(g[cvor][v]);   }   void DFS() {     for (int u = 1; u <= n && !rez; u++) {       if (!pos[u]) {         dsu.clear();         dfs(u);         if (!proveri()) rez = true;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     DFS();     if (rez == true)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int INP() {     int n, flag;     char c;     n = 0;     flag = 1;     c = getchar();     while (c < 33) {       c = getchar();     }     if (c ==  - ) {       flag = -1;       c = getchar();     }     while (c > 32) {       n = n * 10 + c -  0 ;       c = getchar();     }     n = n * flag;     return n;   }   int GCD(int a, int b) { return (a % b == 0 ? b : GCD(b, a % b)); }   int main() {     int n, i, idx, ans, stop;     string s, s1, mx;     vector<string> v;     cin >> s;     n = s.size();     mx =  0 ;     for (i = 0; i < n; i++) {       s1.push_back(s[i]);       if (s[i + 1] !=  0 ) {         v.push_back(s1);         if (s1.size() > mx.size()) {           mx = s1;           idx = v.size();         } else if (s1.size() == mx.size() && s1 > mx) {           mx = s1;           idx = v.size();         }         s1.clear();       }     }     s1.clear();     for (i = 0; i < idx; i++) {       if (s1.size() > v[i].size()) {         stop = min(stop, i - 1);       } else if (s1.size() == v[i].size() && s1 >= v[i]) {         stop = min(stop, i - 1);       }       if (s1.size() < v[i].size()) {         stop = INT_MAX;       } else if (s1.size() == v[i].size() && v[i] > s1) {         stop = INT_MAX;       }       s1 += v[i];       if (s1.size() > mx.size()) {         ans = v.size() - min(i, stop);         break;       } else if (s1.size() == mx.size() && s1 >= mx) {         ans = v.size() - min(i, stop);         break;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<pair<long long, long long>, long long> m;     vector<long long> p1, p2;     long long n, s, i, j, k, a, u, v, w, l, k1, k2;     cin >> n;     while (n--) {       cin >> a;       if (a == 1) {         cin >> u >> v >> w;         j = u;         k1 = 0, k2 = 0;         p1.push_back(j);         while (j != 1) {           j = j / 2;           p1.push_back(j);         }         j = v;         p2.push_back(j);         while (j != 1) {           j = j / 2;           p2.push_back(j);         }         for (i = 0; i < p1.size(); i++) {           int t = 1;           for (j = 0; j < p2.size(); j++) {             if (p1[i] == p2[j]) {               k1 = i;               k2 = j;               t = 0;               break;             }           }           if (t == 0) break;         }         for (i = 0; i < k1; i++) {           m[make_pair(p1[i], p1[i + 1])] += w;         }         for (i = 0; i < k2; i++) {           m[make_pair(p2[i], p2[i + 1])] += w;         }         p1.clear();         p2.clear();       } else {         s = 0;         cin >> u >> v;         j = u;         k1 = k2 = 0;         p1.push_back(j);         while (j != 1) {           j = j / 2;           p1.push_back(j);         }         j = v;         p2.push_back(j);         while (j != 1) {           j = j / 2;           p2.push_back(j);         }         for (i = 0; i < p1.size(); i++) {           int t = 1;           for (j = 0; j < p2.size(); j++) {             if (p1[i] == p2[j]) {               k1 = i;               k2 = j;               t = 0;               break;             }           }           if (t == 0) break;         }         for (i = 0; i < k1; i++) {           s += m[make_pair(p1[i], p1[i + 1])];         }         for (i = 0; i < k2; i++) {           s += m[make_pair(p2[i], p2[i + 1])];         }         p1.clear();         p2.clear();         cout << s << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     vector<long long> a(n + 1), b(n + 1);     for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];     long long k;     cin >> k;     long long x;     for (int i = 1; i <= n; i++)       if (k >= a[i] && k <= b[i]) {         x = i;         break;       }     cout << n - x + 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 100 * 30;   int main() {     string A, B;     cin >> A >> B;     vector<vector<int> > v(26, vector<int>(26, INF));     for (int i = 0; i < 26; ++i) v[i][i] = 0;     int N;     cin >> N;     while (N--) {       char a, b;       int cost;       cin >> a >> b >> cost;       int ia = a -  a , ib = b -  a ;       v[ia][ib] = min(v[ia][ib], cost);     }     for (int k = 0; k < 26; ++k)       for (int i = 0; i < 26; ++i)         for (int j = 0; j < 26; ++j) v[i][j] = min(v[i][j], v[i][k] + v[k][j]);     if (A.size() != B.size()) {       cout << -1 << endl;     } else {       unsigned ans = 0;       bool fail = false;       string res =   ;       for (int i = 0; i < A.size(); ++i) {         if (A[i] == B[i]) {           res += A[i];           continue;         }         int ia = A[i] -  a , ib = B[i] -  a ;         char to_ch = 0;         int cost = INF * 10;         for (int j = 0; j < 26; ++j) {           if (v[ia][j] < INF && v[ib][j] < INF) {             if (v[ia][j] + v[ib][j] < cost) {               cost = v[ia][j] + v[ib][j];               to_ch = j +  a ;             }           }         }         if (to_ch == 0) {           fail = true;           break;         }         ans += cost;         res += to_ch;       }       if (fail)         cout << -1 << endl;       else {         cout << ans << endl;         cout << res << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sti(const string &s) {     int x;     stringstream ss(s);     ss >> x;     return x;   }   string its(const int &x) {     string s;     stringstream ss(s);     ss << x;     s = ss.str();   }   void sscan(string &str) {     str =   ;     char str_c;     scanf( %c , &str_c);     while (!(str_c ==   n  || str_c ==    )) {       str += str_c;       scanf( %c , &str_c);     }   }   void sprint(const string &str) {     int length = str.length();     for (int i = 0; i < length; ++i) printf( %c , str[i]);   }   uint64_t fact(int x) {     if (x < 2) return 1;     return fact(x - 1) * x;   }   uint64_t C(int x, int y) {     uint64_t c = 1;     for (int i = 0; i < y; ++i) {       c *= x - i;       c /= i + 1;     }     return c;   }   int main() {     int n, m, t;     scanf( %d %d %d , &n, &m, &t);     uint64_t res = 0;     for (int i = 4; i <= n && i < t; ++i) {       if (t - i > m) continue;       res += C(n, i) * C(m, t - i);     }     printf( %I64u , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 7;   set<int, greater<int> > s;   int main() {     int q;     scanf( %d , &q);     while (q--) {       s.clear();       int n;       scanf( %d , &n);       for (int i = 1; i <= n; i++) {         int x;         scanf( %d , &x);         s.insert(x);       }       int x = *s.begin();       int ans = 0;       if (s.find(x / 2) != s.end() && s.find(x / 3) != s.end() &&           s.find(x / 5) != s.end())         if (x % 2 == 0 && x % 3 == 0 && x % 5 == 0)           ans = max(ans, x / 2 + x / 3 + x / 5);       int cnt = 0;       int sum = 0;       while (!s.empty() && cnt < 3) {         int now = *s.begin();         sum += now;         cnt++;         s.erase(now);         for (int i = 2; i <= sqrt(now) + 1; i++) {           if (now % i == 0) {             s.erase(i);             if (s.find(i) != s.end()) s.erase(i);             if (s.find(now / i) != s.end()) s.erase(now / i);           }         }       }       printf( %d n , max(ans, sum));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   bool h[100100][40], u[100100][40];   bool big(long long a, long long b) {     long long ans = 1;     for (long long i = 0; i < b; ++i) {       ans *= a;       if (ans >= n) return 1;     }     return 0;   }   bool win(long long a, long long b) {     if (b == 1 && a > 100100 - 10) return (n - a) % 2 == 0;     if (u[a][b]) return h[a][b];     u[a][b] = 1;     if (big(a, b)) return h[a][b] = 1;     if (!win(a + 1, b) || !win(a, b + 1)) return h[a][b] = 1;     return h[a][b] = 0;   }   bool miss(long long a, long long b) {     for (long long i = b; i < 40; ++i)       if (!win(a + 1, i)) {         if ((i - b) % 2 == 0)           cout <<  Masha ;         else           cout <<  Stas ;         return 0;       }     cout <<  Missing ;     return 1;   }   int main() {     long long a, b;     cin >> a >> b >> n;     if ((a > 1))       if (win(a, b))         cout <<  Masha ;       else         cout <<  Stas ;     if (a == 1) miss(a, b);     return 0;   }
#include <iostream>   #include <cstring>      using namespace std;      const int MAXN = 100 + 10;      int cnt[MAXN];      int main() {     int t;     cin >> t;     while (t--) {       int n, input, ans = 0;       cin >> n;       memset(cnt, 0, sizeof(cnt));       for (int i = 0; i < n; ++i) {         cin >> input;         ++cnt[input];         ans = max(ans, cnt[input]);       }       cout << ans << endl;     }     // system( pause );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e4;   int n, aa[N + 2], fib[N + 2], con[N + 2], m;   void compress() {     vector<int> v;     for (int i = 1; i <= n; i++) v.push_back(aa[i]);     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     map<int, int> mp;     for (int i = 0; i < v.size(); i++) {       mp[v[i]] = i + 1;       con[i + 1] = v[i] % m;     }     for (int i = 1; i <= n; i++) aa[i] = mp[aa[i]];   }   bool vs[N + 2];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> aa[i];     compress();     fib[1] = 1;     fib[2] = 1;     for (int i = 3; i <= 30000; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % m;     int q;     cin >> q;     while (q--) {       int l, r;       cin >> l >> r;       for (int i = l; i <= r; i++) vs[aa[i]] = 1;       long long ans = 0;       int cnt = 1;       for (int i = 1; i <= 30000; i++) {         if (vs[i]) {           ans += con[i] * fib[cnt++];           vs[i] = 0;         }       }       cout << ans % m <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int main() {     string s;     cin >> s;     int cnt0, cnt1, len = s.size();     string t(len,  0 );     cnt0 = cnt1 = 0;     for (int i = len - 1; i >= 0; --i) {       if (s[i] ==  0 )         ++cnt0;       else {         if (cnt0 != cnt1)           t[i] =  1 ;         else           ++cnt0;         ++cnt1;       }     }     cout << t <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool is(long long x) { return x != 1; }   int main() {     int t;     cin >> t;     while (t--) {       long long x, y;       cin >> x >> y;       long long z = x - y;       if (is(z))         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }