malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int b) {     long long int x = (a) % 1000000007, y = 1;     while (b) {       if (b % 2 != 0) y = (y * x) % 1000000007;       x = (x * x) % 1000000007;       b /= 2;     }     return y;   }   long long cnt[200003] = {0}, l[200003] = {0}, r[200003] = {0};   int main() {     long long int m, i, x, temp, ans = 1, k;     scanf( %I64d , &m);     for (i = 0; i < m; i++) {       scanf( %I64d , &x);       cnt[x]++;     }     l[2] = cnt[2] + 1;     for (i = 3; i <= 200000; i++) {       if (cnt[i]) {         if (l[i - 1] == 0)           l[i] = (cnt[i] + 1) % (1000000007 - 1);         else           l[i] = (l[i - 1] * (cnt[i] + 1)) % (1000000007 - 1);       } else         l[i] = l[i - 1];     }     r[200000] = cnt[200000];     for (i = 200000; i >= 2; i--) {       if (cnt[i]) {         if (r[i + 1] == 0)           r[i] = (cnt[i] + 1) % (1000000007 - 1);         else           r[i] = (r[i + 1] * (cnt[i] + 1)) % (1000000007 - 1);       } else         r[i] = r[i + 1];     }     for (i = 2; i <= 200000; i++) {       if (cnt[i]) {         temp = 1;         k = 1;         if (l[i - 1] == 0 && r[i + 1] == 0)           temp = 1;         else if (l[i - 1] == 0)           temp = r[i + 1];         else if (r[i + 1] == 0)           temp = l[i - 1];         else           temp = (r[i + 1] * l[i - 1]) % (1000000007 - 1);         k = ((cnt[i] * (cnt[i] + 1)) / 2) % (1000000007 - 1);         k = (temp * k) % (1000000007 - 1);         ans = (ans * power(i, k)) % 1000000007;       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long UNDEF = -1;   const int INF = 1 << 25;   template <typename T>   inline bool chkmax(T& aa, T bb) {     return aa < bb ? aa = bb, true : false;   }   template <typename T>   inline bool chkmin(T& aa, T bb) {     return aa > bb ? aa = bb, true : false;   }   static char stdinBuffer[1024];   static char* stdinDataEnd = stdinBuffer + sizeof(stdinBuffer);   static const char* stdinPos = stdinDataEnd;   void readAhead(size_t amount) {     size_t remaining = stdinDataEnd - stdinPos;     if (remaining < amount) {       memmove(stdinBuffer, stdinPos, remaining);       size_t sz = fread(stdinBuffer + remaining, 1,                         sizeof(stdinBuffer) - remaining, stdin);       stdinPos = stdinBuffer;       stdinDataEnd = stdinBuffer + remaining + sz;       if (stdinDataEnd != stdinBuffer + sizeof(stdinBuffer)) *stdinDataEnd = 0;     }   }   int readInt() {     readAhead(16);     int x = 0;     bool neg = false;     while (*stdinPos ==     || *stdinPos ==   n ) ++stdinPos;     if (*stdinPos ==  - ) {       ++stdinPos;       neg = true;     }     while (*stdinPos >=  0  && *stdinPos <=  9 ) {       x *= 10;       x += *stdinPos -  0 ;       ++stdinPos;     }     return neg ? -x : x;   }   char readCh() {     readAhead(16);     while (*stdinPos ==     || *stdinPos ==   n ) ++stdinPos;     char ans = *stdinPos;     ++stdinPos;     return ans;   }   const int mn = 1000000;   pair<int, int> vp[mn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n = readInt();     for (int i = 0; i < n; i++) {       int val = readInt();       vp[i] = make_pair(val, i);     }     sort(vp, vp + n);     long long final = 0;     long long sign = -1;     for (int k = 0; k < 2; k++) {       set<int> s;       s.insert(-1);       s.insert(n);       for (int i = 0; i < n; i++) {         int x = vp[i].second;         auto got = s.insert(x);         auto it = got.first;         auto lit = it;         --lit;         auto rit = it;         ++rit;         long long l = x - *lit;         long long r = *rit - x;         long long prod = l * r;         long long val = (long long)vp[i].first * (long long)prod * sign;         final += val;       }       reverse(vp, vp + n);       sign = -sign;     }     printf( %lld n , final);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 0; i < t; i++) {       int n;       cin >> n;       int maxi = 0, mini = 1000000000;       vector<long long int> a(n, 0);       long long int xor1 = 0;       long long int sum1 = 0;       for (int i = 0; i < n; i++) {         cin >> a[i];         xor1 ^= a[i];         sum1 += a[i];       }       sum1 += xor1;       cout << 2 << endl << xor1 <<     << sum1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   char S[111111];   long long cnt1[26], cnt2[26 * 26];   int main() {     scanf( %s , S);     int len = strlen(S);     for (int i = 0; i < len; i++) {       for (int j = 0; j < 26; j++) cnt2[26 * j + S[i] -  a ] += cnt1[j];       cnt1[S[i] -  a ]++;     }     long long ans = 0;     for (int i = 0; i < 26; i++) ans = max(ans, cnt1[i]);     for (int i = 0; i < 26 * 26; i++) ans = max(ans, cnt2[i]);     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d = 2;   bool P[100100];   int A[100100];   vector<pair<int, int> > R;   void criba() {     for (int i = 0; i < 100100; i++) P[i] = 1;     P[0] = 0;     P[1] = 0;     for (int i = 2; i < 100100; i++) {       if (P[i]) {         for (int j = 2 * i; j < 100100; j += i) P[j] = 0;       }     }   }   void solve(int a, int b) {     if (a == b) return;     if (a > b) swap(a, b);     for (int i = b; i > a; i--)       if (P[i - a + 1]) {         swap(A[a], A[i]);         R.push_back(make_pair(a, i));         solve(i, b);         break;       }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> A[i];     criba();     for (int i = 1; i <= n; i++) {       while (A[i] != i) solve(i, A[i]);     }     cout << R.size() << endl;     for (int i = 0; i < R.size(); i++) {       cout << R[i].first <<     << R[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   inline long long int gcd(long long int ga, long long int gb) {     if (!gb) return ga;     return gcd(gb, ga % gb);   }   inline long long int lcm(long long int a, long long int b, long long int c) {     long long int ans = a * b / gcd(a, b);     return ans * c / gcd(ans, c);   }   int main() {     long long int n;     scanf( %lld , &n);     if (n == 1)       printf( 1 );     else if (n == 2)       printf( 2 );     else if (n & 1)       printf( %lld , n * (n - 1) * (n - 2));     else {       long long int ans(1);       for (int i = 1; i <= n; ++i) ans = max(ans, lcm(n, n - 1, i));       printf( %lld , max(ans, max((n - 1) * (n - 2) * (n - 3),                                   n * (n - 1) * (n - 2) / 2)));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, a, b, s = 0;     cin >> n;     map<int, int> m1, m2;     for (i = 1; i < n + 1; ++i) {       int a, b;       cin >> a >> b;       s += m1[a + b]++;       s += m2[a - b]++;     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int a[1200];     while (~scanf( %d , &n)) {       for (int i = 1; i <= 2 * n; i++) scanf( %d , &a[i]);       sort(a + 1, a + 2 * n + 1);       if (a[n] == a[n + 1])         printf( NO n );       else         printf( YES n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 30;   class Solution;   class LinearBasis {    public:     friend class Solution;     LinearBasis() : size(0) { fill(begin(bs), end(bs), 0); }     LinearBasis& operator=(const LinearBasis& other) {       copy(begin(other.bs), end(other.bs), begin(bs));       size = other.size;       return *this;     }     void add(int num) {       for (int i = 0; i < N; ++i) {         if (num & (1 << i)) {           if (bs[i] == 0) {             bs[i] = num;             ++size;             break;           } else {             num ^= bs[i];           }         }       }     }     bool isValid(int num) {       if (num == 0) {         return true;       }       for (int i = 0; i < N; ++i) {         if (num & (1 << i)) {           num ^= bs[i];           if (num == 0) {             return true;           }         }       }       return false;     }       protected:     int bs[N];     int size;   };   class Solution {    public:     Solution(vector<int>& _A, int n) : nums(_A), size(n) { init(); }     int query(int l, int x) {       if (l <= 0) {         return 0;       }       l = min(l, size);       if (lbs[l].isValid(x)) {         return powM(2, l - lbs[l].size);       } else {         return 0;       }     }       private:     int size;     vector<int> nums;     vector<LinearBasis> lbs;     const int M = 1e9 + 7;     void init() {       lbs.clear();       lbs.resize(size + 1);       for (int i = 0; i < size; ++i) {         int a = nums[i];         lbs[i + 1] = lbs[i];         lbs[i + 1].add(a);       }     }     long long normalize(long long a) {       a %= M;       if (a < 0) {         a += M;       }       return a;     }     long long addM(long long a, long long b) { return normalize(a + b); }     long long mulM(long long a, long long b) { return normalize(a * b); }     long long powM(long long x, long long e) {       long long res = 1;       while (e > 0) {         if (e & 0x1) {           res = mulM(res, x);         }         x = mulM(x, x);         e >>= 1;       }       return res;     }   };   int main(int argc, char** argv) {     ios::sync_with_stdio(false);     cin.tie(0);     int n, q;     cin >> n >> q;     vector<int> nums(n);     for (int i = 0; i < n; ++i) {       cin >> nums[i];     }     Solution sol(nums, n);     for (int i = 0, l = 0, x = 0; i < q; ++i) {       cin >> l >> x;       cout << sol.query(l, x) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[100], b[100];   int res[100][3001][101] = {0};   bool us[100][3001][101] = {0};   const int mod = 1000000007;   int work(int ll, int pr = -1, int lpred = -1) {     if (ll < 0) return 0;     if (ll == 0) return 1;     if (pr != -1 && us[pr][ll][lpred] != 0) return res[pr][ll][lpred];     int r = 0;     for (int i = 0; i < n; i++)       if (i != pr) {         if ((lpred == -1) || (a[i] == lpred))           r = (r + work(ll - a[i], i, b[i])) % mod;         if ((a[i] != b[i]) && ((lpred == -1) || (b[i] == lpred)))           r = (r + work(ll - b[i], i, a[i])) % mod;       }     if (pr != -1) {       res[pr][ll][lpred] = r;       us[pr][ll][lpred] = 1;     }     return r;   }   int main() {     ios_base::sync_with_stdio(false);     int l;     cin >> n >> l;     for (int i = 0; i < n; i++) cin >> a[i] >> b[i];     cout << work(l);   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2e6 + 10;   long long n, a[maxn], Begin[maxn], Next[maxn], To[maxn], e, sum;   bool vis[maxn], use[maxn];   inline void add(long long u, long long v) {     To[++e] = v;     Next[e] = Begin[u];     Begin[u] = e;   }   inline void DFS(long long u, long long op) {     if (vis[u]) return;     vis[u] = true;     if (op == 0) {       use[u] = true;       sum += u;     }     for (long long i = Begin[u]; i; i = Next[i]) DFS(To[i], op ^ 1);   }   signed main() {     scanf( %lld , &n);     if (n % 2 == 0) {       puts( First );       for (long long i = (1), _end_ = (n); i <= _end_; ++i) printf( %lld  , i);       for (long long i = (1), _end_ = (n); i <= _end_; ++i) printf( %lld  , i);       fflush(stdout);       return 0;     }     puts( Second );     fflush(stdout);     for (long long i = (1), _end_ = (n + n); i <= _end_; ++i) {       long long x;       scanf( %lld , &x);       if (a[x]) {         add(a[x], i);         add(i, a[x]);       } else         a[x] = i;     }     for (long long i = (1), _end_ = (n); i <= _end_; ++i) {       add(i, i + n);       add(i + n, i);     }     for (long long i = (1), _end_ = (n + n); i <= _end_; ++i)       if (!vis[i]) DFS(i, 0);     if (sum % (n + n) == 0) {       for (long long i = (1), _end_ = (n + n); i <= _end_; ++i)         if (use[i]) printf( %lld  , i);     } else {       for (long long i = (1), _end_ = (n + n); i <= _end_; ++i)         if (!use[i]) printf( %lld  , i);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 gen(chrono::system_clock::now().time_since_epoch().count());   const int M = 3e5 + 7;   const int N = 1e6 + 7;   int n, q, l, r, t[N * 4], ans[N], k, x, tn = 1;   map<int, vector<int> > p;   map<int, vector<pair<int, int> > > otr;   map<int, vector<pair<int, int> > > R;   void update(int v, int tl, int tr, int pos, int x) {     if (tr == tl + 1) {       t[v] = min(t[v], x);       return;     }     int mid = (tl + tr) / 2;     if (pos < mid)       update(v << 1, tl, mid, pos, x);     else       update((v << 1) + 1, mid, tr, pos, x);     t[v] = min(t[v << 1], t[(v << 1) + 1]);     return;   }   long long query(int v, int tl, int tr, int l, int r) {     if (r <= tl || tr <= l) return 1e9;     if (l <= tl && tr <= r) return t[v];     int mid = (tl + tr) / 2;     return min(query(v << 1, tl, mid, l, r), query((v << 1) + 1, mid, tr, l, r));   }   int query(int l, int r) { return query(1, 0, tn, l, r); }   void update(int pos, int x) {     update(1, 0, tn, pos, x);     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     while (tn < N) tn <<= 1;     for (int i = 0; i < n; i++) {       cin >> x;       if (p[x].size()) otr[i].push_back({p[x].back(), i - p[x].back()});       p[x].push_back(i);     }     for (int i = 0; i < q; i++) {       cin >> l >> r;       l--;       r--;       R[r].push_back({l, i});     }     for (int i = 1; i < tn * 2; i++) t[i] = 1e9 + 7;     for (int i = 0; i < q; i++) ans[i] = 1e9 + 7;     for (int i = 1; i < N; i++) {       for (int j = 0; j < otr[i].size(); j++)         update(otr[i][j].first, otr[i][j].second);       for (int j = 0; j < R[i].size(); j++)         ans[R[i][j].second] = query(R[i][j].first, i + 1);     }     for (int i = 0; i < q; i++) cout << (ans[i] >= n * 2 ? -1 : ans[i]) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   std::vector<int> res;   std::vector<int> adj[200005];   std::vector<int> DEPTH(200005);   std::vector<int> NODENUM(200005);   std::vector<int> funct(200005);   vector<bool> taken(200005);   vector<bool> visited(200005);   int dfs(int v, int depth) {     int nodeNum = 0;     visited[v] = 1;     DEPTH[v] = depth;     for (int u : adj[v]) {       if (!visited[u]) {         nodeNum += dfs(u, depth + 1);       }     }     NODENUM[v] = nodeNum;     return NODENUM[v] + 1;   }   long long dfsV2(int v) {     visited[v] = 1;     long long ans = 0;     for (int u : adj[v]) {       if (!visited[u]) {         if (taken[u]) {           ans += (long long)(NODENUM[u] + 1) * DEPTH[u];         } else           ans += (long long)dfsV2(u);       }     }     return ans;   }   bool func(int x, int y) {     if (funct[x] > funct[y]) return true;     return false;   }   void solve() {     int n, k, x, y, i;     cin >> n >> k;     for (i = 0; i < n - 1; i++) {       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     dfs(1, 0);     for (i = 1; i <= n; i++) {       funct[i] = DEPTH[i] - NODENUM[i];       res.push_back(i);     }     sort(res.begin(), res.end(), func);     for (i = 0; i < k; i++) {       taken[res[i]] = 1;     }     for (i = 0; i < n + 2; i++) {       visited[i] = 0;     }     cout << dfsV2(1) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, dig = 0, rem;     cin >> n;     while (n != 0) {       rem = n % 10;       if (rem == 4 || rem == 7) {         dig++;       }       n = n / 10;     }     if (dig == 4 || dig == 7)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int place_to_score[] = {25, 18, 15, 12, 10, 8, 6, 4, 2, 1};   int t, n;   map<string, int> ids;   int next_id = 1;   char names[50][64];   char tmp[64];   int score[50];   int places[50][50];   int main() {     scanf( %d , &t);     for (int i = 0; i < t; i++) {       scanf( %d , &n);       int place = 0;       for (int j = 0; j < n; j++) {         scanf( %s , tmp);         int id = ids[tmp];         if (!id) {           ids[tmp] = id = next_id++;           strcpy(names[id - 1], tmp);         }         id--;         if (place < 10) score[id] += place_to_score[place];         places[id][place]++;         place++;       }     }     vector<int> best;     int points = -1;     for (int i = 0; i < next_id - 1; i++) {       if (score[i] > points) {         best.clear();         points = score[i];       }       if (score[i] == points) best.push_back(i);     }     for (int place = 0; best.size() > 1 && place < next_id - 1; place++) {       vector<int> new_best;       points = -1;       for (int i = 0; i < best.size(); i++) {         if (places[best[i]][place] > points) {           new_best.clear();           points = places[best[i]][place];         }         if (places[best[i]][place] == points) new_best.push_back(best[i]);       }       best = new_best;     }     printf( %s n , names[best[0]]);     best.clear();     points = -1;     for (int i = 0; i < next_id - 1; i++) {       if (places[i][0] > points) {         best.clear();         points = places[i][0];       }       if (places[i][0] == points) best.push_back(i);     }     if (best.size() > 1) {       vector<int> new_best;       points = -1;       for (int i = 0; i < best.size(); i++) {         if (score[best[i]] > points) {           new_best.clear();           points = score[best[i]];         }         if (score[best[i]] == points) new_best.push_back(best[i]);       }       best = new_best;     }     for (int place = 1; best.size() > 1 && place < next_id - 1; place++) {       vector<int> new_best;       points = -1;       for (int i = 0; i < best.size(); i++) {         if (places[best[i]][place] > points) {           new_best.clear();           points = places[best[i]][place];         }         if (places[best[i]][place] == points) new_best.push_back(best[i]);       }       best = new_best;     }     printf( %s n , names[best[0]]);   }
#include <bits/stdc++.h>   using namespace std;   string dst__;   stringstream dss__;   void debug(stringstream& ds) {     cerr << endl;     return;   }   template <typename F, typename... R>   void debug(stringstream& ds, const F& f, const R&... r) {     string n;     ds >> n;     cerr << n <<  =  << f <<    ;     debug(ds, r...);   }   constexpr long long LINF = 334ll << 53;   constexpr int INF = 15 << 26;   constexpr long long MOD = 1E9 + 7;   void sieve(long long n, vector<long long>& p) {     vector<char> isprime(n + 1, 1);     isprime[0] = isprime[1] = 0;     for (long long i = 2; i <= n; i++) {       if (isprime[i]) {         p.push_back(i);         for (long long j = i * i; j <= n; j += i) isprime[j] = 0;       }     }   }   vector<long long> primes;   vector<vector<long long>> dp(22, vector<long long>(1000010));   long long r, c;   long long primeFactor(long long k) {     vector<pair<long long, int>> ret;     for (int i = 0;; ++i) {       if (primes[i] * primes[i] > k) {         if (k != 1ll) ret.push_back(make_pair(k, 1));         break;       }       if (k % primes[i] == 0) {         ret.push_back(make_pair(primes[i], 0));         while (k % primes[i] == 0) {           k /= primes[i];           ret.back().second++;         }       }     }     long long ans = 1;     for (auto& y : ret) {       ans = ans * dp[y.second][r] % MOD;     }     return ans;   }   int main() {     sieve(1000003, primes);     for (int i = 1; i < 22; ++i) {       dp[i][0] = 2;       if (i == 1) {         for (int j = 1; j < 1000010; ++j) {           dp[i][j] = j + 2;         }       } else {         for (int j = 1; j < 1000010; ++j) {           dp[i][j] = dp[i - 1][j] + dp[i][j - 1] % MOD;         }       }     }     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       scanf( %lld%lld , &r, &c);       auto ans = primeFactor(c);       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int cnt[26] = {0};     for (int i = 0; i < s.size(); i++) {       cnt[s[i] -  a ]++;     }     int ans[26] = {0};     vector<int> v;     for (int i = 0; i < 26; i++) {       ans[i] = cnt[i] / 2;       cnt[i] = cnt[i] % 2;       if (cnt[i] == 1) v.push_back(i);     }     for (int i = 0; i < v.size() / 2; i++) {       ans[v[i]]++;     }     int tmp = -1;     if (v.size() % 2 == 1) {       tmp = v[v.size() / 2];     }     for (int i = 0; i < 26; i++) {       for (int j = 0; j < ans[i]; j++) {         cout << (char)( a  + i);       }     }     if (tmp != -1) {       cout << (char)( a  + tmp);     }     for (int i = 25; i >= 0; i--) {       for (int j = 0; j < ans[i]; j++) {         cout << (char)( a  + i);       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:667772160 )   using namespace std;   struct __isoff {     __isoff() {       if (0) freopen( input.txt ,  r , stdin), freopen( output.txt ,  w , stdout);       srand( C  +  T  +  A  +  C  +  Y  +  M  +  B  +  A );     }     ~__isoff() {}   } __osafwf;   const unsigned long long p1 = 31;   const unsigned long long p2 = 29;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int infi = 1e9 + 7;   const long long inf = 1e18 + 7;   const long long dd = 2e5 + 7;   const long long mod = 1e9 + 7;   const int logc = 20;   int up[dd][logc], H[dd], in[dd], out[dd], ti = 0;   vector<int> P[dd];   void dfs(int v, int p = 0, int h = 0) {     H[v] = h;     in[v] = ti++;     up[v][0] = p;     for (int i = 1; i < logc; i++) {       up[v][i] = up[up[v][i - 1]][i - 1];     }     for (auto it : P[v]) {       if (it != p) {         dfs(it, v, h + 1);       }     }     out[v] = ti++;   }   void build() { dfs(0); }   bool is(int a, int b) { return in[a] <= in[b] && out[b] <= out[a]; }   int lca(int a, int b) {     if (is(a, b)) {       return a;     }     if (is(b, a)) {       return b;     }     for (int i = logc - 1; i >= 0; i--) {       int t = up[a][i];       if (!is(t, b)) {         a = t;       }     }     return up[a][0];   }   int dis(int a, int b) { return H[a] + H[b] - 2 * H[lca(a, b)]; }   int main() {     int n;     cin >> n;     vector<int> E;     for (long long i = 0; i < (long long)n - 1; i++) {       int t;       cin >> t;       t--;       P[t].push_back(i + 1);       E.push_back(i + 1);     }     build();     int a = 0, b = 0, l = 0;     for (long long i = 0; i < (long long)n - 1; i++) {       int t = E[i];       if (l < dis(a, t)) {         l = dis(a, t);         b = t;       }       if (l < dis(b, t)) {         l = dis(b, t);         a = t;       }       cout << l <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int modulo = 1e9 + 7;   template <class __Ty>   bool mini(__Ty& a, __Ty b) {     return a > b ? ((a = b) | 1) : (0);   }   template <class __Ty>   bool maxi(__Ty& a, __Ty b) {     return a < b ? ((a = b) | 1) : (0);   }   template <class __Ty>   __Ty add(__Ty a, __Ty b) {     return (a + b) % (__Ty(modulo));   }   template <class __Ty>   __Ty sub(__Ty a, __Ty b) {     __Ty m(modulo);     return ((a - b) % m + m) % m;   }   int a[int(1e6) + 3] = {0};   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     if ((n <= m + 1) && (m <= 2 * (n + 1))) {       m -= n - 1;       for (int i = 1; i < n; ++i) a[i] = 1;       for (int i = 0; i <= n; ++i)         while (m && a[i] < 2) {           m--;           a[i]++;         }       for (int i = 0; i <= n; ++i) {         if (i > 0) cout << 0;         while (a[i]--) cout << 1;       }     } else       cout << -1;     return 0;   }