malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000 + 4;   char s[maxn];   int a[maxn];   void get(bitset<maxn> &B) {     scanf( %s , s);     int m = strlen(s);     int x = 12;     for (int i = 0; i < m; i++) a[m - 1 - i] = s[i] -  0 ;     m--;     for (int i = 0; i < maxn && x >= 0; i++) {       int rem = 0;       for (int j = m; j >= 0; j--) a[j] += rem * 10, rem = (a[j] & 1), a[j] >>= 1;       B[i] = rem;       while (m >= 0 && !a[m]) m--;       x = rand() + m;     }   }   int pos[maxn];   bitset<maxn> b[maxn], st[maxn];   int main() {     if (fopen( in ,  r )) {       freopen( in ,  r , stdin);       freopen( out ,  w , stdout);     }     memset(pos, -1, sizeof(pos));     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       get(b[i]);       st[i][i] = 1;       bool ok = 1;       for (int j = 0; j < maxn; j++)         if (b[i][j]) {           if (pos[j] == -1) {             ok = 0;             pos[j] = i;             break;           }           b[i] ^= b[pos[j]];           st[i] ^= st[pos[j]];         }       if (!ok) {         printf( 0 n );         continue;       }       st[i][i] = 0;       printf( %d , st[i].count());       for (int j = 0; j < maxn; j++)         if (st[i][j]) printf(  %d , j);       printf(  n );     }   }
#include <bits/stdc++.h>   long long mpow(long long a, long long n, long long mod) {     long long ret = 1;     long long b = a;     while (n) {       if (n & 1) ret = (ret * b) % mod;       b = (b * b) % mod;       n >>= 1;     }     return (long long)ret;   }   using namespace std;   int main() {     cin.sync_with_stdio(0);     int i, j, n, m, k, s;     cin >> n >> m >> k >> s;     int a[4][10];     for (j = 0; j < 10; j++) a[0][j] = -1e9, a[2][j] = -1e9;     for (j = 0; j < 10; j++) a[1][j] = 1e9, a[3][j] = 1e9;     for (i = 0; i < n; i++)       for (j = 0; j < m; j++) {         long long p;         cin >> p;         a[0][p] = max(a[0][p], i + j);         a[1][p] = min(a[1][p], i + j);         a[2][p] = max(a[2][p], i - j);         a[3][p] = min(a[3][p], i - j);       }     int p;     cin >> p;     int ans = -1;     for (j = 1; j < s; j++) {       int q;       cin >> q;       ans = max(ans, a[0][p] - a[1][q]);       ans = max(ans, a[0][q] - a[1][p]);       ans = max(ans, a[2][p] - a[3][q]);       ans = max(ans, a[2][q] - a[3][p]);       p = q;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 400, LOGN = 19;   int n, q, a[N], dpLCA[LOGN][N], lca[N], kraw[N], dist[N];   vector<pair<int, int> > G[N];   long long dp[N], dp2[N], tree[N], odl[N], wynik[N], pom[N];   vector<int> zapytania[N];   void insert(int v, long long x) {     while (v <= n) {       tree[v] += x;       v += (v & (-v));     }   }   long long query(int v) {     long long wynik = 0;     while (v > 0) {       wynik += tree[v];       v -= (v & (-v));     }     return wynik;   }   long long pytaj(int a, int b) {     if (a > b) return 0;     return query(b) - query(a - 1);   }   void preDFS(int u) {     dp[u] = a[u];     for (auto v : G[u]) {       if (v.first != dpLCA[0][u]) {         dpLCA[0][v.first] = u;         dist[v.first] = dist[u] + 1;         odl[v.first] = odl[u] + v.second;         kraw[v.first] = v.second;         preDFS(v.first);         pom[v.first] = max(0LL, dp[v.first] - 2 * v.second);         dp[u] += pom[v.first];       }     }   }   int LCA(int a, int b) {     if (dist[a] < dist[b]) swap(a, b);     int d = dist[a] - dist[b];     for (int i = 0; i < LOGN; i++)       if (d & (1 << i)) a = dpLCA[i][a];     if (a == b) return a;     for (int i = LOGN - 1; i >= 0; i--) {       if (dpLCA[i][a] != dpLCA[i][b]) {         a = dpLCA[i][a];         b = dpLCA[i][b];       }     }     return dpLCA[0][a];   }   void preDP(int u) {     int ojciec = dpLCA[0][u];     dp2[u] = dp[u] + (u != 1 ? max(0LL, dp[ojciec] - 2 * kraw[u]) : 0);     long long blep = dp[u] - (u != 1 ? pom[u] : 0);     insert(dist[u], blep);     for (auto ID : zapytania[u]) wynik[ID] += pytaj(dist[lca[ID]], dist[u]);     for (auto v : G[u]) {       if (v.first != dpLCA[0][u]) {         long long pomek = dp[u];         dp[u] = dp2[u] - pom[v.first];         preDP(v.first);         dp[u] = pomek;       }     }     insert(dist[u], -blep);   }   int32_t main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i < n; i++) {       int a, b, c;       scanf( %d%d%d , &a, &b, &c);       G[a].push_back({b, c});       G[b].push_back({a, c});     }     dpLCA[0][1] = 1;     dist[1] = 1;     preDFS(1);     for (int i = 1; i < LOGN; i++)       for (int j = 1; j <= n; j++) dpLCA[i][j] = dpLCA[i - 1][dpLCA[i - 1][j]];     for (int i = 1; i <= q; i++) {       int a, b;       scanf( %d%d , &a, &b);       lca[i] = LCA(a, b);       wynik[i] = -(odl[a] + odl[b] - 2 * odl[lca[i]]);       zapytania[a].push_back(i);       zapytania[b].push_back(i);     }     preDP(1);     for (int i = 1; i <= q; i++) {       int u = lca[i];       int ojciec = dpLCA[0][u];       wynik[i] = wynik[i] - dp[u];       long long pomek = dp[ojciec];       dp[ojciec] = dp2[ojciec] - pom[u];       printf( %lld n ,              wynik[i] +                  (u != 1 ? max(0LL, dp[ojciec] - 2 * kraw[u]) + 2 * pom[u] : 0));       dp[ojciec] = pomek;     }     getchar();     getchar();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};   int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};   int main() {     int tc = 1;     cin >> tc;     for (int cs = 1; cs <= tc; cs++) {       string s;       cin >> s;       vector<int> v;       for (int i = (int)s.size() - 3; i >= 0; i--) {         if (s[i] ==  o  && s[i + 1] ==  n  && s[i + 2] ==  e ) {           if (i > 0 && s[i - 1] ==  o ) {             s[i + 1] =  x ;             v.push_back(i + 2);           } else {             s[i] =  x ;             v.push_back(i + 1);           }         } else if (s[i] ==  t  && s[i + 1] ==  w  && s[i + 2] ==  o ) {           if (i > 0 && s[i - 1] ==  t ) {             s[i + 1] =  x ;             v.push_back(i + 2);           } else {             s[i] =  x ;             v.push_back(i + 1);           }         }       }       cout << v.size() <<   n ;       for (int i = 0; i < v.size(); i++) {         cout << v[i] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   const long long MAX = -1000000000000000000;   const long long MIN = 1000000000000000000;   const long long inf = 1000000000;   const long long KOK = 100000;   const long long LOG = 30;   const long long li = 500005;   const long long mod = 1000000007;   int n, m, b[li], a[li], k, flag, t, kuc[li], buy[li];   int cev;   string s;   vector<int> v;   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     for (int i = 0; i <= li - 5; i++) {       buy[i] = inf;       kuc[i] = inf;     }     cin >> n >> s;     int m = s.size();     if (m % n != 0) {       string ss{};       string sss{};       int at = 0;       ss +=  1 ;       for (int i = 1; i < n; i++) ss +=  0 ;       while (at < m) {         at += n;         sss += ss;       }       cout << sss << endl;       return 0;     }     int cev1 = 0;     for (int i = (int)s.size() - 1; i >= 0; i--) {       if (s[i] < s[i % n]) {         cev++;         kuc[i % n] = i;       }       if (s[i] > s[i % n]) {         buy[i % n] = i;       }       if (s[i] == s[i % n]) cev1++;     }     for (int i = 0; i < n; i++) {       if (buy[i] < kuc[i])         break;       else if (buy[i] > kuc[i]) {         string ss{};         string sss{};         for (int i = 0; i < n; i++) ss += s[i];         int at = 0;         while (at < m) {           at += n;           sss += ss;         }         cout << sss << endl;         return 0;       }     }     if (cev + cev1 == m && cev1 != m) {       string ss{};       string sss{};       for (int i = 0; i < n; i++) ss += s[i];       int at = 0;       while (at < m) {         at += n;         sss += ss;       }       cout << sss << endl;       return 0;     }     string ss{};     string sss{};     for (int i = 0; i < n - 1; i++) ss += s[i];     if (s[n - 1] -  0  + 1 >= 10) flag = 1;     ss += (s[n - 1] -  0  + 1) % 10 +  0 ;     int yer = n - 2;     while (flag == 1) {       flag = 0;       if (yer < 0) {         flag = 1;         break;       }       if (ss[yer] -  0  + 1 >= 10) flag = 1;       ss[yer] = (ss[yer] -  0  + 1) % 10 +  0 ;       yer--;     }     if (flag == 1) {       string ss{};       string sss{};       int at = 0;       ss +=  1 ;       for (int i = 1; i < n; i++) ss +=  0 ;       while (at <= (int)s.size()) {         at += n;         sss += ss;       }       cout << sss << endl;       return 0;     }     int at = 0;     while (at < m) {       at += n;       sss += ss;     }     cout << sss << endl;     return 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   int a[MAXN], b[MAXN];   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 0; i < n / k; ++i) {       scanf( %d , &a[i]);     }     for (int i = 0; i < n / k; ++i) {       scanf( %d , &b[i]);     }     long long ans = 1;     int mx = 10;     for (int i = 1; i < k; ++i) {       mx *= 10;     }     int mn = mx / 10;     --mx;     for (int i = 0; i < n / k; ++i) {       int cur = mx / a[i];       int l = b[i] * mn, r = (b[i] + 1) * mn - 1;       if (r >= l) {         cur -= r / a[i];         if (l > 0) cur += (l - 1) / a[i];       }       if (b[i] != 0) ++cur;       ans = (ans * (long long)cur) % 1000000007;     }     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inft = 1000000009;   const int MAXN = 1000006;   const int T = 1024 * 1024;   int drz[2][2 * T];   vector<int> X;   pair<int, int> Q[MAXN];   char C[MAXN];   bool used[MAXN];   int ask(int a, int nr) {     int ans = -1;     a += T;     while (a) {       ans = max(ans, drz[nr][a]);       a /= 2;     }     return ans;   }   void add(int a, int b, int value, int nr) {     a += T;     b += T;     while (a <= b) {       if (a % 2 == 1) {         drz[nr][a] = max(drz[nr][a], value);         a++;       }       if (b % 2 == 0) {         drz[nr][b] = max(drz[nr][b], value);         b--;       }       a /= 2;       b /= 2;     }   }   void solve() {     int n, m;     scanf( %d%d , &n, &m);     X.push_back(0);     X.push_back(n + 1);     for (int i = 0; i < (m); ++i) {       int a, b;       char c;       scanf( %d%d %c , &a, &b, &c);       X.push_back(a);       X.push_back(b);       Q[i] = pair<int, int>(a, b);       C[i] = c;     }     sort((X).begin(), (X).end());     X.resize(unique((X).begin(), (X).end()) - X.begin());     for (int j = 0; j < (2); ++j)       for (int i = 0; i < (2 * T); ++i) drz[j][i] = -1;     add(0, T - 1, 0, 0);     add(0, T - 1, 0, 1);     for (int i = 0; i < (m); ++i) {       int aa = lower_bound((X).begin(), (X).end(), Q[i].first) - X.begin();       if (used[aa]) {         printf( 0 n );         continue;       }       used[aa] = 1;       if (C[i] ==  L ) {         int nr = lower_bound((X).begin(), (X).end(), Q[i].second) - X.begin();         int ans = ask(nr, 0);         printf( %d n , Q[i].first - X[ans]);         add(ans, lower_bound((X).begin(), (X).end(), Q[i].first) - X.begin(), nr,             1);       } else {         int nr = lower_bound((X).begin(), (X).end(), Q[i].first) - X.begin();         int ans = ask(nr, 1);         printf( %d n , Q[i].second - X[ans]);         add(ans, lower_bound((X).begin(), (X).end(), Q[i].second) - X.begin(), nr,             0);       }     }   }   int main() {     int t = 1;     for (int i = 0; i < (t); ++i) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(long long &x, long long &y) { return x >= y; }   long long mode = pow(10, 9) + 7;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     long long a[n + 1];     a[0] = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans = ans + abs(a[i] - a[i - 1]) + 2;     }     cout << ans - 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long int LINF = 0x3f3f3f3f3f3f3f;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int k;     cin >> k;     string second, t;     int freq[130];     while (k--) {       memset(freq, 0, sizeof(freq));       int n;       vector<pair<int, int> > ans;       cin >> n;       cin >> second >> t;       for (int i = 0; i < n; i++) {         freq[second[i]]++;         freq[t[i]]++;       }       for (int i = 0; i < 130; i++) {         if (freq[i] % 2) {           cout <<  No                 <<   n ;           goto fim;         }       }       for (int i = 0; i < n; i++) {         if (second[i] == t[i]) continue;         int opa = 0;         for (int j = i + 1; j < n; j++)           if (second[j] == second[i]) {             swap(second[j], t[i]);             ans.push_back({j, i});             opa = 1;             break;           }         if (opa) continue;         for (int j = i + 1; j < n; j++) {           if (second[i] == t[j]) {             swap(second[j], t[j]);             ans.push_back({j, j});             swap(t[i], second[j]);             ans.push_back({j, i});             break;           }         }       }       cout <<  Yes             <<   n ;       cout << ans.size() <<   n ;       for (auto a : ans) cout << a.first + 1 <<     << a.second + 1 << endl;     fim:       continue;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int main() {     ios::sync_with_stdio(false);     int n;     while (cin >> n) {       int a, b, c, d, sum = 0, i = 0, mx = -1, my = -1, mix = N, miy = N;       for (i = 0; i < n; i++) {         cin >> a >> b >> c >> d;         sum += abs(a - c) * abs(d - b);         mx = max(mx, max(a, c));         my = max(my, max(d, b));         mix = min(mix, min(a, c));         miy = min(miy, min(d, b));       }       if (((mx - mix) != (my - miy)) || (mx - mix) * (my - miy) != sum)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-12;   pair<long long, long long> save[200005];   long long cnt[50];   int main(void) {     long long n;     cin >> n;     if (n & 1) {       char ch;       while (cin >> ch)         ;       cout <<  no ;       return 0;     }     for (long long i = 1; i <= n; i++) {       cin >> save[i].first >> save[i].second;     }     long long half = n / 2;     long double x0 = (save[1].first + save[half + 1].first) / 2.0;     long double y0 = (save[1].second + save[half + 1].second) / 2.0;     for (int i = 2; i <= half; i++) {       if (fabs((save[i].first + save[half + i].first) / 2.0 - x0) < eps &&           fabs((save[i].second + save[half + i].second) / 2.0 - y0) < eps) {         ;       } else {         cout <<  no ;         return 0;       }     }     cout <<  yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 51;   const long long MOD = 1e9 + 7;   const double eps = 1e-8;   int n, a[N], b[N];   vector<pair<int, int> > v;   double dp[N][N][N], thresh;   bool vis[N][N][N];   double calc(int i, int g, int e) {     if (i == n) return 0.0;     double &r = dp[i][g][e];     if (vis[i][g][e]) return r;     vis[i][g][e] = 1;     int g2 = g, e2 = e;     if (i && v[i].first != v[i - 1].first) {       g2 += e2;       e2 = 0;     }     r = calc(i + 1, g2, e2 + 1) + v[i].first - thresh * v[i].second;     if (g2) r = min(r, calc(i + 1, g2 - 1, e2));     return r;   }   bool check(double m) {     memset(vis, 0, sizeof vis);     thresh = m;     double r = calc(0, 0, 0);     return !(r > eps);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , a + i);     for (int i = 0; i < n; i++) {       scanf( %d , b + i);       v.push_back(make_pair(a[i], b[i]));     }     sort(v.begin(), v.end());     reverse(v.begin(), v.end());     double l = 0, r = 5e9 + 1, m, ans = 0.0;     int it = 80;     while (l < r && it) {       m = (l + r) / 2;       it--;       if (check(m)) {         ans = m;         r = m;       } else         l = m;     }     printf( %.0lf n , ceil(ans * 1000));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100004], d[32];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int j = 0; j < n; j++) {       int x = a[j];       for (int i = 0; x > 0; i++) {         d[i] += x % 2;         x /= 2;       }     }     int p = 1, e = 0;     for (int i = 0; i < 32; i++) {       if (d[i] == 1) {         e += p;       }       p *= 2;     }     int c = -1, m = 0;     for (int i = 0; i < n; i++) {       int x = a[i] & e;       if (x > m) {         m = x;         c = i;       }     }     if (c != -1) {       cout << a[c] <<    ;     }     for (int j = 0; j < n; j++) {       if (c != j) cout << a[j] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   const int mxN = 2e5 + 10;   vector<int> arr(mxN);   vector<pair<int, int> > offers(mxN);   bool isPossible(int day) {     vector<int> lst(n, -1);     for (int i = 0; i < m; i++) {       if (offers[i].first <= day) {         lst[offers[i].second] = max(lst[offers[i].second], offers[i].first);       }     }     vector<vector<int> > off(2 * mxN);     for (int i = 0; i < n; i++) {       if (lst[i] != -1) {         off[lst[i]].push_back(i);       }     }     int curr_money = 0;     vector<int> need = arr;     for (int i = 0; i <= day; i++) {       ++curr_money;       if (i > mxN || off[i].size() == 0) {         continue;       }       for (auto it : off[i]) {         if (curr_money >= need[it]) {           curr_money -= need[it];           need[it] = 0;         } else {           need[it] -= curr_money;           curr_money = 0;           break;         }       }     }     return accumulate(need.begin(), need.end(), 0) * 2 <= curr_money;   }   long long int binarySearch(int low, int high) {     int answer;     while (high >= low) {       int mid = (low + high) / 2;       if (isPossible(mid)) {         answer = mid;         high = mid - 1;       } else {         low = mid + 1;       }     }     return answer;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     for (int i = 0; i < m; i++) {       cin >> offers[i].first >> offers[i].second;       offers[i].first--;       offers[i].second--;     }     cout << binarySearch(0, 2 * mxN) + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   const int M = 100005;   int n, m;   int in_degree[N];   bool visited[N];   bool tree_edge[M];   bool directed[M];   vector<int> choose[N];   vector<pair<int, int> > adj[N];   inline void dfs(int u, int p) {     visited[u] = true;     for (auto edge : adj[u]) {       int v = edge.first;       int i = edge.second;       if (v == p) {         continue;       }       if (not visited[v]) {         dfs(v, u);         tree_edge[i] = true;       } else if (not directed[i]) {         in_degree[v]++;         directed[i] = true;         choose[v].push_back(u);       }     }   }   inline void solve(int u, int p) {     for (auto edge : adj[u]) {       int v = edge.first;       int i = edge.second;       if ((not tree_edge[i]) || (v == p)) {         continue;       }       solve(v, u);     }     if (p != -1) {       if (in_degree[u] & 1) {         in_degree[u]++;         choose[u].push_back(p);       } else {         in_degree[p]++;         choose[p].push_back(u);       }     }   }   int main() {     cin >> n >> m;     if (m & 1) {       cout <<  No solution  << endl;       return 0;     }     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back({v, i});       adj[v].push_back({u, i});     }     dfs(1, -1);     solve(1, -1);     for (int i = 1; i <= n; i++) {       while ((int)choose[i].size() > 0) {         int u = choose[i].back();         choose[i].pop_back();         int v = choose[i].back();         choose[i].pop_back();         cout << u <<     << i <<     << v << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int n, m;   long long c[maxn], ans, s;   vector<int> g[maxn];   bool v[maxn];   void dfs(int a) {     s = min(s, c[a]);     v[a] = 1;     for (int i = 0; i < g[a].size(); i++) {       int b = g[a][i];       if (!v[b]) dfs(b);     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %lld , &c[i]);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d %d , &x, &y);       g[x].push_back(y);       g[y].push_back(x);     }     ans = 0;     for (int i = 1; i <= n; i++) {       if (v[i]) continue;       s = (1e9) + 1;       dfs(i);       ans += s;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool mul_overflow(long long a, long long b) { return (a > (LLONG_MAX / b)); }   bool add_overflow(long long a, long long b) { return (a > (LLONG_MAX - b)); }   const int N = 1e6 + 5;   int n;   long double a[N][3];   bool sol(long double mid) {     long double l = -1e8, r = 1e8;     for (int i = 1; i <= n; i++) {       long double rs = 2 * mid * a[i][2] - a[i][2] * a[i][2];       if (rs < 0) {         l = -1e8, r = 1e8;       } else {         l = max(l, a[i][1] - sqrt(rs));         r = min(r, a[i][1] + sqrt(rs));       }     }     cout << (l <= r) <<   n ;     return (l <= r);   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i][1] >> a[i][2];     }     int f = -1;     if (a[1][1] >= 0 && a[1][2] >= 0 || a[1][2] >= 0 && a[1][1] <= 0)       f = 1;     else       f = 0;     for (int i = 2; i <= n; i++) {       if (f == 1) {         if (!(a[i][1] >= 0 && a[i][2] >= 0 || a[i][2] >= 0 && a[i][1] <= 0)) {           cout <<  -1 n ;           return 0;         }       } else {         if (a[i][1] >= 0 && a[i][2] >= 0 || a[i][2] >= 0 && a[i][1] <= 0) {           cout <<  -1 n ;           return 0;         }       }     }     if (n == 1) {       cout << a[1][2] / 2 <<   n ;       return 0;     }     long double lo = 0, hi = 1e18;     for (int i = 1; i <= 100; i++) {       long double xl = -1e18, xr = 1e18;       long double r = (lo + hi) / 2;       bool f = 0;       for (int i = 1; i <= n; i++) {         long double x = a[i][1], y = abs(a[i][2]);         long double t = 2 * y * r - y * y;         if (t < 0) {           f = 1;           break;         }         t = sqrt(t);         xl = max(xl, x - t);         xr = min(xr, x + t);       }       if (f == false && xr > xl) {         hi = r;       } else         lo = r;     }     cout << fixed << setprecision(11) << lo <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[1000005];   int main() {     while (scanf(  %s , str) != EOF) {       int i, len = strlen(str);       long long m, l = 0, r = 0;       for (i = 0; i < len; i++)         if (str[i] ==  ^ ) m = i;       for (i = 0; i < len; i++)         if (str[i] >=  1  && str[i] <=  9 ) {           if (i < m)             l += (m - i) * (str[i] -  0 );           else             r += (i - m) * (str[i] -  0 );         }       if (l > r)         printf( left n );       else if (r > l)         printf( right n );       else         printf( balance n );     }   }
#include <bits/stdc++.h>   using namespace std;   int from[101], to[101], p;   int main() {     int n, m, x, y;     cin >> n >> m;     memset(to, -1, sizeof to);     for (int i = 1; i <= n; i++) {       cin >> x >> y;       for (int j = x; j <= y; j++) to[j] = max(to[j], y);     }     int now = 0;     for (; now <= m;) {       if (to[now] == -1 || to[now] == now) break;       if (now == m || (now <= m and to[now] >= m)) {         cout <<  YES ;         return 0;       }       now = to[now];     }     cout <<  NO ;     return 0;   }