malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char grid[55][55];   int T, N;   int main() {     cin >> T;     for (int QQQ = 0; QQQ < T; QQQ++) {       cin >> N;       bool works = true;       for (int i = 0; i < N; i++) cin >> grid[i];       for (int r = 0; r < N - 1; r++)         for (int c = 0; c < N - 1; c++)           if (grid[r][c] ==  1  &&               (grid[r + 1][c] ==  0  && grid[r][c + 1] ==  0 ))             works = false;       if (works)         cout <<  YES ;       else         cout <<  NO ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   constexpr int N = 150005;   double x[N], ex[N];   array<double, 4> seg[4 * N];   array<double, 4> merge(const array<double, 4> &l, const array<double, 4> &r) {     array<double, 4> rv;     rv[0] = l[0] + r[0];     rv[1] = max(l[1], l[0] + r[1]);     rv[2] = max(r[2], r[0] + l[2]);     rv[3] = max({l[3], r[3], l[2] + r[1]});     return rv;   }   void build(int at, int b, int e) {     if (b == e) {       seg[at][0] = ex[b];       seg[at][1] = seg[at][2] = seg[at][3] = max(0., ex[b]);       return;     }     build(at * 2, b, ((b + e) / 2));     build(at * 2 + 1, ((b + e) / 2) + 1, e);     seg[at] = merge(seg[at * 2], seg[at * 2 + 1]);   }   array<double, 4> query(int at, int b, int e, int l, int r) {     if (e < l or r < b) return array<double, 4>();     if (l <= b and e <= r) {       return seg[at];     }     auto q1 = query(at * 2, b, ((b + e) / 2), l, r);     auto q2 = query(at * 2 + 1, ((b + e) / 2) + 1, e, l, r);     return merge(q1, q2);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, m, c;     cin >> n >> m >> c;     for (int i = 1; i <= n; i++) cin >> x[i];     for (int i = 1; i < n; i++) {       double p;       cin >> p;       ex[i] = (x[i + 1] - x[i]) * .5 - p * c / 100.0;     }     build(1, 1, n - 1);     double result = 0;     while (m--) {       int l, r;       cin >> l >> r;       auto res = query(1, 1, n - 1, l, r - 1);       result += res[3];     }     cout << setprecision(10) << result << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   vector<int> e[N];   int n, ans, f[N][2], g[N][2];   void dfs1(int x, int fa) {     f[x][0] = 0;     f[x][1] = 0;     int d = e[x].size() - (fa != 0);     for (auto i : e[x])       if (i != fa) {         dfs1(i, x);         f[x][0] = max(f[x][0], max(f[i][0], f[i][1]) - 1);         f[x][1] = max(f[x][1], f[i][0]);       }     f[x][0] += d;     f[x][1]++;   }   void upd(pair<int, int> &x, pair<int, int> &y, pair<int, int> z) {     if (z > x) swap(x, z);     y = max(y, z);   }   void dfs2(int x, int fa) {     if (!fa) g[x][0] = 0, g[x][1] = 0;     pair<int, int> mx1(0, x), mx2(-1, -1), mx3(0, x), mx4(-1, -1);     upd(mx1, mx2, pair<int, int>(max(g[x][0], g[x][1]) - 1, -1));     upd(mx3, mx4, pair<int, int>(g[x][0], -1));     for (auto i : e[x])       if (i != fa) {         upd(mx1, mx2, pair<int, int>(max(f[i][0], f[i][1]) - 1, i));         upd(mx3, mx4, pair<int, int>(f[i][0], i));       }     int d = e[x].size() - 1;     ans = max(ans, max(mx1.first + d + 1, mx3.first));     for (auto i : e[x])       if (i != fa) {         g[i][0] = (mx1.second == i ? mx2.first : mx1.first) + d;         g[i][1] = (mx3.second == i ? mx4.first : mx3.first) + 1;         dfs2(i, x);       }   }   int main() {     srand(time(NULL));     scanf( %d , &n);     for (int i = (int)(1); i <= (int)(n - 1); i++) {       int x, y;       scanf( %d%d , &x, &y);       e[x].push_back(y);       e[y].push_back(x);     }     dfs1(1, 0);     dfs2(1, 0);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long a[100009];   int main() {     long long n, x, y;     int i;     while (cin >> n >> x >> y) {       int flag = 0;       for (i = 1; i <= n - 1; i++) a[i] = 1, y--;       a[n] = y;       if (a[n] <= 0) flag = 1;       long long sum = 0;       for (i = 1; i <= n; i++) {         sum = sum + a[i] * a[i];       }       if (sum < x || flag)         cout <<  -1  << endl;       else {         for (i = 1; i <= n; i++) {           cout << a[i] << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   inline long long int rand(long long int x, long long int y) {     ++y;     return (rng() % (y - x)) + x;   }   long long int n, q, fw[300006], st[300006], en[300006], co, dist[300006], zero,       line[300006], lines, sizee[300006];   vector<long long int> v[300006];   struct fen {     long long int n;     vector<long long int> fw;     void init(long long int x) {       fw.resize(x + 2 + 1);       n = fw.size() - 1;     }     void update(long long int x, long long int y, long long int nv) {       ++y;       for (; x <= n; x += x & (-x)) fw[x] += nv;       for (; y <= n; y += y & (-y)) fw[y] -= nv;     }     long long int sum(long long int x) {       long long int res = 0;       for (; x; x -= x & (-x)) res += fw[x];       return res;     }   } fen[300006];   struct fen2 {     void update(long long int x, long long int y, long long int nv) {       ++y;       for (; x <= n; x += x & (-x)) fw[x] += nv;       for (; y <= n; y += y & (-y)) fw[y] -= nv;     }     long long int sum(long long int x) {       long long int res = 0;       for (; x; x -= x & (-x)) res += fw[x];       return res;     }   } depth;   void dfs(long long int x, long long int p) {     st[x] = co++;     if (p != 1)       line[x] = line[p], sizee[line[p]]++;     else if (x != 1)       line[x] = lines++, sizee[line[x]]++;     for (auto i : v[x]) {       if (i == p) continue;       dist[i] = dist[x] + 1;       dfs(i, x);     }     en[x] = co;   }   int main() {     cin >> n >> q;     for (long long int i = 0; i < n - 1; i++) {       long long int a, b;       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     dfs(1, 1);     for (long long int i = 0; i < lines; i++) fen[i].init(sizee[i]);     for (long long int i = 1; i <= q; i++) {       long long int op;       cin >> op;       if (op == 0) {         long long int v, x, d;         cin >> v >> x >> d;         long long int overflow = d - dist[v];         if (overflow >= 0) depth.update(1, overflow + 1, x);         if (v == 1) continue;         if (overflow >= 0)           fen[line[v]].update(overflow + 2, dist[v] + d + 1, x);         else           fen[line[v]].update(dist[v] - d + 1, dist[v] + d + 1, x);       } else {         long long int v;         cin >> v;         cout << depth.sum(dist[v] + 1) + fen[line[v]].sum(dist[v] + 1) <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i;     double sum, n;     cin >> t;     while (t--) {       cin >> n;       sum = 360 / (180 - n);       if ((sum - (int)sum) == 0)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx2 )   using namespace std;   const int MX = 1005;   int n, a, b;   vector<int> adj[2 * MX][2];   int leaf[MX][2];   int pos[2 * MX][2];   int siz[2 * MX][2];   int best[MX][MX][2];   int ans[MX][2];   pair<int, int> rang[2 * MX][2];   void dfs(int v, int p, int d) {     if (pos[v][d] != -1) rang[v][d] = {pos[v][d], pos[v][d]};     siz[v][d] = 1;     for (int to : adj[v][d]) {       if (to != p) {         dfs(to, v, d);         siz[v][d] += siz[to][d];         rang[v][d].first = min(rang[v][d].first, rang[to][d].first);         rang[v][d].second = max(rang[v][d].second, rang[to][d].second);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> a;     for (int i = 0; i < a; i++) pos[i][0] = -1, rang[i][0] = {1e9, -1e9};     for (int i = 0; i < a - 1; i++) {       int p;       cin >> p;       adj[p - 1][0].push_back(i + 1);     }     for (int i = 0; i < n; i++) {       cin >> leaf[i][0], leaf[i][0]--;       pos[leaf[i][0]][0] = i;     }     cin >> b;     for (int i = 0; i < b; i++) pos[i][1] = -1, rang[i][1] = {1e9, -1e9};     for (int i = 0; i < b - 1; i++) {       int p;       cin >> p;       adj[p - 1][1].push_back(i + 1);     }     for (int i = 0; i < n; i++) {       cin >> leaf[i][1], leaf[i][1]--;       pos[leaf[i][1]][1] = i;     }     dfs(0, -1, 0);     dfs(0, -1, 1);     for (int i = 0; i < a; i++) {       auto cur = rang[i][0];       best[cur.first][cur.second][0] =           max(best[cur.first][cur.second][0], siz[i][0] - (i == 0));     }     for (int i = 0; i < b; i++) {       auto cur = rang[i][1];       best[cur.first][cur.second][1] =           max(best[cur.first][cur.second][1], siz[i][1] - (i == 0));     }     for (int c = 0; c < 2; c++) {       for (int len = 2; len < n + 1; len++) {         for (int st = 0; st < n; st++) {           if (st + len - 1 < n) {             int l = st, r = st + len - 1;             for (int k = l; k < r + 1; k++) {               if (k < r)                 best[l][r][c] =                     max(best[l][r][c], best[l][k][c] + best[k + 1][r][c]);             }           }         }       }     }     for (int i = 0; i < n + 1; i++) ans[i][0] = -1e9, ans[i][1] = -1e9;     ans[0][0] = 0, ans[0][1] = 0;     for (int i = 1; i < n + 1; i++) {       for (int j = 0; j < i; j++) {         ans[i][0] = max(ans[i][0], ans[j][1] + best[j][i - 1][1]);         ans[i][1] = max(ans[i][1], ans[j][0] + best[j][i - 1][0]);       }     }     cout << max(ans[n][0], ans[n][1]) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   ifstream file( input.txt );   int main() {     int ta = 0, tb = 0, tc = 0, v = 2;     string str;     cin >> str;     for (int i = 0; i < str.size(); i++) {       if (str[i] ==  a )         ta++;       else if (str[i] ==  b )         tb++;       else         tc++;     }     for (int i = 0; i < str.size() - 1; i++)       if (int(str[i]) > str[i + 1]) {         v--;         break;       }     if (tc != ta && tc != tb)       v--;     else if (ta == 0 || tb == 0 || tc == 0)       v--;     if (v == 2) {       cout <<  YES ;     } else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int M = 2e3 + 5;   const int INF = 0x7fffffff;   const int mod = 998244353;   const double eps = 1e-8;   const double pi = acos(-1);   int n, m;   char str[N];   int f[N][26];   template <class T>   inline void read(T &x) {     char c;     x = 1;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) x = -1;     T res = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) res = res * 10 + c -  0 ;     x *= res;   }   int main() {     scanf( %s , str + 1);     read(n);     int len = strlen(str + 1);     for (int i = 1; i <= len; i++) {       for (int j = 0; j <= 25; j++) {         if (str[i] -  a  == j)           f[i][j] = f[i - 1][j] + 1;         else           f[i][j] = f[i - 1][j];       }     }     while (n--) {       int l, r;       read(l);       read(r);       int cnt = 0;       for (int i = 0; i <= 25; i++) {         if (f[r][i] - f[l - 1][i] > 0) cnt++;       }       if ((cnt >= 3) || (l == r) || (str[l] != str[r]))         cout <<  Yes n ;       else         cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   template <class T>   inline bool chmax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <class T>   inline bool chmin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   const long long MAX = 5100000;   const long long INF = 1LL << 60;   const long long mod = 1000000007LL;   using namespace std;   long long t[200500];   long long tmp[200500];   int main() {     long long n;     scanf( %lld , &n);     long long a[3];     scanf( %lld %lld %lld , &a[0], &a[1], &a[2]);     sort(a, a + 3);     multiset<long long> ms;     for (long long i = 0; i < n; i++) {       scanf( %lld , &t[i]);       ms.emplace(t[i]);     }     if (*ms.rbegin() > a[0] + a[1] + a[2]) {       puts( -1 );       return 0;     }     long long res = 0;     while (!ms.empty() && *ms.rbegin() > a[1] + a[2]) {       res++;       ms.erase(--ms.end());     }     while (!ms.empty() && *ms.rbegin() > a[0] + a[2]) {       res++;       ms.erase(--ms.end());       auto itr = ms.upper_bound(a[0]);       if (itr == ms.begin()) continue;       itr--;       ms.erase(itr);     }     while (!ms.empty() && *ms.rbegin() > a[2] && *ms.rbegin() > a[0] + a[1]) {       res++;       ms.erase(--ms.end());       if (ms.empty()) break;       auto itr = ms.upper_bound(a[1]);       if (itr == ms.begin()) continue;       itr--;       ms.erase(itr);     }     while (!ms.empty()) {       res++;       if (a[0] + a[1] <= a[2]) {         ms.erase(--ms.end());         if (ms.empty()) break;         if (*ms.begin() <= a[0]) {           ms.erase(ms.begin());           if (ms.empty()) break;           auto itr = ms.upper_bound(a[1]);           if (itr == ms.begin()) continue;           itr--;           ms.erase(itr);         } else if (*ms.begin() <= a[0] + a[1]) {           auto itr = ms.upper_bound(a[1] + a[0]);           itr--;           ms.erase(itr);         }       } else {         if (*ms.rbegin() <= a[2]) {           auto itr = ms.upper_bound(a[1]);           if (!(*ms.begin() > a[0] || itr == ms.begin() || itr == ++ms.begin())) {             ms.erase(--ms.end());             if (ms.empty()) break;             ms.erase(ms.begin());             if (ms.empty()) break;             auto itr = ms.upper_bound(a[1]);             itr--;             ms.erase(itr);             continue;           }         }         ms.erase(--ms.end());         auto itr = ms.upper_bound(a[2]);         if (itr != ms.begin()) {           itr--;           ms.erase(itr);         }       }     }     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double us1[210];   double us2[210];   int deal(double *us, int s, int e, int p) {     int flag = 0;     for (int i = 1; i <= 200; i++) {       if (us[i] < 1e-4 / 200.) continue;       double dd = us[i] * (100 - p) / 100.;       dd /= (e - s + 1);       us[i] = us[i] / 100. * p;       flag = 1;       for (int ss = s; ss <= e; ss++) {         us[max(i - ss, 0)] += dd;       }     }     return flag;   }   int main() {     int hp1, t1, s1, e1, p1;     int hp2, t2, s2, e2, p2;     cin >> hp1 >> t1 >> s1 >> e1 >> p1;     cin >> hp2 >> t2 >> s2 >> e2 >> p2;     if (p1 == 100) {       cout << 0.0;       return 0;     }     if (p2 == 100) {       cout << 1.0;       return 0;     }     int nt1 = 0, nt2 = 0;     for (int i = 0; i <= 200; i++) {       us1[i] = 0.;       us2[i] = 0.;     }     us1[hp1] = 1.;     us2[hp2] = 1.;     double ret = 0;     while (1) {       if (nt1 <= nt2) {         nt1 += t1;         deal(us2, s1, e1, p1);         ret += (1. - us1[0]) * us2[0];         us2[0] = 0;       } else if (nt1 > nt2) {         nt2 += t2;         if (!deal(us1, s2, e2, p2)) break;       }     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   using namespace std;   const int maxn = 200000;   int t[4 * maxn];   int p[maxn];   int n;   int mina(int x, int y) {     if (x == -1) return y;     if (y == -1) return x;     return (p[x] < p[y] ? x : y);   }   void build(int x, int cl, int cr) {     if (cr - cl > 1) {       build(2 * x, cl, (cl + cr) / 2);       build(2 * x + 1, (cl + cr) / 2, cr);       t[x] = mina(t[2 * x], t[2 * x + 1]);     } else       t[x] = cl;   }   int get(int x, int cl, int cr, int l, int r) {     if (cr <= l || r <= cl) return -1;     if (l <= cl && cr <= r) return t[x];     return mina(get(2 * x, cl, (cl + cr) / 2, l, r),                 get(2 * x + 1, (cl + cr) / 2, cr, l, r));   }   int a[maxn], dpl[maxn], dpr[maxn];   int mx = 0;   void dfs(int i, int cl, int cr, int cd) {     dpl[i] = dpr[i] = 1;     if (i != cl) {       int u = get(1, 0, maxn, cl, i);       dfs(u, cl, i, cd + 1);       dpl[i] += max(dpl[u], dpr[u]);     }     if (cr - i > 1) {       int u = get(1, 0, maxn, i + 1, cr);       dfs(u, i + 1, cr, cd + 1);       dpr[i] += max(dpr[u], dpl[u]);     }   }   pair<int, int> solve(int sd) {     for (int i = sd; i < n; i++) p[i - sd] = a[i];     for (int i = n - sd; i < n; i++) p[i] = a[i - n + sd];     build(1, 0, maxn);     mx = 0;     int st = get(1, 0, maxn, 0, n);     dfs(st, 0, n, 1);     return {max(dpl[st], dpr[st]), dpl[st] - dpr[st]};   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int ans = solve(0).first;     int mi = 0;     int st = get(1, 0, maxn, 0, n);     int l = 0, r = st;     while (r - l > 10) {       int md = (l + r) / 2;       if (solve(md).second >= 0)         l = md;       else         r = md;     }     for (int i = l; i <= r; i++) {       int fuck = solve(i).first;       if (fuck < ans) {         mi = i;       }       ans = min(ans, fuck);     }     l = st;     r = n - 1;     while (r - l > 10) {       int md = (l + r) / 2;       if (solve(md).second >= 0)         l = md;       else         r = md;     }     for (int i = l; i <= r; i++) {       int fuck = solve(i).first;       if (fuck < ans) {         mi = i;       }       ans = min(ans, fuck);     }     cout << ans <<     << mi;     return 0;   }
#include <bits/stdc++.h>   int a[500];   int temp1[500];   int temp2[500];   int sum[500];   void merge(int l, int mid, int r) {     int i, j, k;     for (i = l; i <= mid; i++) temp1[i - l] = a[i];     temp1[i - l] = 10000000;     for (j = mid + 1; j <= r; j++) temp2[j - mid - 1] = a[j];     temp2[j - mid - 1] = 1000000;     i = 0;     j = 0;     k = l;     while (k <= r) {       if (temp1[i] < temp2[j]) {         a[k] = temp1[i];         i++;       } else {         a[k] = temp2[j];         j++;       }       k++;     }   }   void sorti(int l, int r) {     if (l >= r) return;     int mid = (l + r) / 2;     sorti(l, mid);     sorti(mid + 1, r);     merge(l, mid, r);   }   int main() {     int n;     scanf( %d , &n);     int i, j, k;     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     int left = 0, right = 0;     for (i = 1; i <= n; i++) {       sum[i] = sum[i - 1] + a[i];     }     int val, val1;     int ans = 360;     for (i = 1; i <= n; i++) {       for (j = i; j <= n; j++) {         val1 = (sum[j] - sum[i - 1]);         val = 360 - val1;         val = val > val1 ? (val - val1) : (val1 - val);         ans = ans > val ? val : ans;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100005];   int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   map<string, int> my;   void check(char* s) {     if (((s[0]) >=  0  && (s[0]) <=  9 ) && ((s[1]) >=  0  && (s[1]) <=  9 ) &&         ((s[3]) >=  0  && (s[3]) <=  9 ) && ((s[4]) >=  0  && (s[4]) <=  9 ) &&         ((s[6]) >=  0  && (s[6]) <=  9 ) && ((s[7]) >=  0  && (s[7]) <=  9 ) &&         ((s[8]) >=  0  && (s[8]) <=  9 ) && ((s[9]) >=  0  && (s[9]) <=  9 ) &&         s[2] ==  -  && s[5] ==  - ) {       int d = atoi(s);       int m = atoi(s + 3);       int y = atoi(string(s + 6, s + 10).c_str());       if (m <= 12 && d > 0 && d <= day[m - 1] && y >= 2013 && y <= 2015) {         ++my[string(s, s + 10)];       }     }   }   int main() {     gets(s);     int n = strlen(s);     for (int i = 0; i + 10 <= n; ++i) check(s + i);     string res(  );     int max = -1;     for (typeof((my).begin()) it = (my).begin(), _e = (my).end(); it != _e; ++it)       if (it->second > max) {         max = it->second;         res = it->first;       }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 2e5 + 5;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     int tc;     cin >> tc;     while (tc--) {       string s;       cin >> s;       int a = 0, b = 0, c = 0;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  A )           a++;         else if (s[i] ==  B )           b++;         else           c++;       }       if (a + c == b)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 4 ;   int a[N] , prefMin[N] , prefMax[N] , suffixMin[N] , suffixMax[N];   int main()   {   ios_base::sync_with_stdio(0);       cin.tie(0);       int t ;       cin >> t ;       while(t--){            int n , m , q  , sum =0 , s1 = 0 , s2 =0;            cin >> n >> m ;            string s;            cin >> s;            s =  #  + s ;            for(int i = 1 ; i<=n ;++i){               if(s[i] ==  + )                   sum++ ;               else                   sum--;               a[i] = sum;               prefMin[i] = min(prefMin[i-1] ,sum);               prefMax[i] = max(prefMax[i-1] , sum);            }            suffixMin[n+1] = suffixMax[n+1] = 0 ;            sum = 0;            for(int i = n ; i>=1; --i){               if(s[i] ==  + )                   s1++ , s2++;               else                  s1-- , s2--;               s1 = min(s1 , 0);               s2 = max(s2 ,0);               suffixMin[i] = s1;               suffixMax[i] = s2;            }            while(m--){               int l , r ;               cin >> l >> r;               int maxi = max(prefMax[l-1] , suffixMax[r+1] + a[l-1]) ;      int mini = min(prefMin[l-1] , suffixMin[r+1] + a[l-1]) ;      cout<<maxi+abs(mini)+1<<   n  ;            }             }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) f = -1;     for (; ch >=  0  && ch <=  9 ; ch = getchar())       x = (x << 1) + (x << 3) + ch -  0 ;     return x * f;   }   const int N = 2e5 + 5;   struct BIT {     int tree[N];     void add(int x) {       for (; x < N; x += x & -x) ++tree[x];     }     int query(int x) {       int res = 0;       for (; x; x -= x & -x) res += tree[x];       return res;     }   } bit;   struct SegmentTree {     int size[N << 2];     void build(int cur, int l, int r) {       if (l == r) {         size[cur] = 1;         return;       }       build((cur << 1), l, (l + r >> 1));       build((cur << 1 | 1), (l + r >> 1) + 1, r);       size[cur] = size[(cur << 1)] + size[(cur << 1 | 1)];     }     int kth(int cur, int l, int r, int k) {       if (l == r) {         size[cur] = 0;         return l;       }       int res = 0;       if (k <= size[(cur << 1)])         res = kth((cur << 1), l, (l + r >> 1), k);       else         res = kth((cur << 1 | 1), (l + r >> 1) + 1, r, k - size[(cur << 1)]);       size[cur] = size[(cur << 1)] + size[(cur << 1 | 1)];       return res;     }   } sgt;   int p[N];   int main() {     int n = read();     for (int i = 1; i <= n; ++i) {       int x = read();       p[i] += x - bit.query(x);       bit.add(x + 1);     }     memset(bit.tree, 0, sizeof(bit.tree));     for (int i = 1; i <= n; ++i) {       int x = read();       p[i] += x - bit.query(x);       bit.add(x + 1);     }     for (int i = n; i >= 1; --i) {       p[i - 1] += p[i] / (n - i + 1);       p[i] %= (n - i + 1);     }     sgt.build(1, 1, n);     for (int i = 1; i <= n; ++i) printf( %d  , sgt.kth(1, 1, n, p[i] + 1) - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c;     long long x0, y0, x, y;     cin >> a >> b >> c >> x0 >> y0 >> x >> y;     c += a * x0;     c += b * y0;     c = -c;     x -= x0;     y -= y0;     if (x < 0) a = -a, x = -x;     if (y < 0) b = -b, y = -y;     if (c < 0) a = -a, b = -b, c = -c;     if (!x || !y || a * b >= 0)       printf( %.12f n , 1.0 * (x + y));     else {       double u = min(1.0 * x, max(0., 1.0 * c / a)),              v = max(0., min(1.0 * x, 1.0 * (c - b * y) / a)),              uu = 1.0 * (c - a * u) / b, vv = 1.0 * (c - a * v) / b;       printf( %.12f n , u + uu + sqrt((v - u) * (v - u) + (vv - uu) * (vv - uu)) +                             x + y - v - vv);     }   }