malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, s, T, ans;   int ar[101];   bool ok[301];   int dp[301][301];   int res[301][301];   int tmp[301][301];   int ways[24][301][301];   vector<int> v;   int main() {     scanf( %d%d , &n, &T);     for (int i = 1; i <= n; i++) {       scanf( %d , &ar[i]);       ok[ar[i]] = true;     }     for (int i = 1; i < 301; i++)       if (ok[i]) v.push_back(i);     s = v.size();     for (int h = 0; h < s; h++) {       int head = v[h];       dp[head][head] = 1;       for (int i = 1; i <= n; i++) {         int mx = dp[head][ar[i]];         for (int j = 1; j <= ar[i]; j++)           if (dp[head][j]) mx = max(mx, dp[head][j] + 1);         dp[head][ar[i]] = mx;       }     }     for (int i = 1; i < 301; i++)       for (int j = 1; j < 301; j++) ways[0][i][j] = max(dp[i][j] - 1, 0);     for (int kd = 1; (1 << kd) <= T; kd++)       for (int i = 0; i < s; i++)         for (int j = i; j < s; j++)           for (int k = i; k <= j; k++) {             int vi = v[i];             int vj = v[j];             int vk = v[k];             ways[kd][vi][vj] = max(ways[kd][vi][vj],                                    ways[kd - 1][vi][vk] + ways[kd - 1][vk][vj]);           }     for (int kd = 0; (1 << kd) <= T; kd++)       if (T & (1 << kd)) {         memset(tmp, 0, sizeof(tmp));         for (int i = 0; i < s; i++)           for (int j = i; j < s; j++)             for (int k = i; k <= j; k++) {               int vi = v[i];               int vj = v[j];               int vk = v[k];               tmp[vi][vj] = max(tmp[vi][vj], res[vi][vk] + ways[kd][vk][vj]);             }         for (int i = 0; i < s; i++)           for (int j = 0; j < s; j++) res[v[i]][v[j]] = tmp[v[i]][v[j]];       }     for (int i = 0; i < s; i++)       for (int j = 0; j < s; j++) ans = max(ans, res[v[i]][v[j]]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int main(void) {     char s[1001];     scanf( %s , s);     if (s[0] > 64 && s[0] < 91)       printf( %s , s);     else {       s[0] -= 32;       for (int i = 0; i < strlen(s); i++) printf( %c , s[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, h;   bool ok(long long x) {     long long ans = 0;     if (x >= 2e9) return 1;     if (x <= h)       ans = x * (x + 1) / 2;     else {       ans = h * (h + 1) / 2 + (x - h) * h;       long long high = x - h - 1;       long long t1 = high / 2, t2 = high - t1;       ans += t1 * (t1 + 1) / 2 + t2 * (t2 + 1) / 2;     }     if (ans >= n)       return 1;     else       return 0;   }   int main() {     cin >> n >> h;     long long l = 1, r = 1e18 + 1;     long long mid = (l + r) / 2;     while (l < r) {       mid = (l + r) / 2;       if (ok(mid))         r = mid;       else         l = mid + 1;     }     printf( %lld n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double mm = 0;   int xs[4];   int ys[4];   int mxs[4];   int mys[4];   int used[1001][1001];   long double di(int x1, int y1, int x2, int y2) {     return sqrt(abs((long double)x1 - (long double)x2) *                     abs((long double)x1 - (long double)x2) +                 abs((long double)y1 - (long double)y2) *                     abs((long double)y1 - (long double)y2));   }   int n, m;   void dfs(int x, int y, int d, long double ma) {     if (x < 0 || y < 0) return;     if (x > n || y > m) return;     if (used[x][y]) return;     used[x][y] = 1;     xs[d] = x;     ys[d] = y;     if (d == 3) {       if (ma > mm) {         mm = ma;         for (int i = 0; i < 4; i++) {           mxs[i] = xs[i];           mys[i] = ys[i];         }       }       used[x][y] = 0;       return;     }     for (int i = 0; i < 4; i++) {       for (int ii = 0; ii < 4; ii++) {         dfs(i, ii, d + 1, ma + di(x, y, i, ii));       }     }     for (int i = 0; i < 4; i++) {       for (int ii = 0; ii < 4; ii++) {         dfs(n - i, m - ii, d + 1, ma + di(x, y, n - i, m - ii));       }     }     used[x][y] = 0;   }   int main() {     cin >> n >> m;     for (int i = 0; i < 4; i++) {       for (int ii = 0; ii < 4; ii++) {         dfs(i, ii, 0, 0);       }     }     for (int i = 0; i < 4; i++) {       cout << mxs[i] <<     << mys[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > al, dist;   int n, m;   bool done[5000];   vector<int> bfs(const vector<vector<int> >& al, int s) {     queue<int> q;     vector<int> dist(al.size(), INT_MAX);     dist[s] = 0;     q.push(s);     while (!q.empty()) {       int i = q.front();       q.pop();       for (int j : al[i])         if (dist[j] == INT_MAX) {           dist[j] = dist[i] + 1;           q.push(j);         }     }     return dist;   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> m;     int r = n;     al.resize(n);     dist.resize(n);     int i, j;     for (int c = 0; c < m; c++) {       cin >> i >> j;       i--;       j--;       al[i].push_back(j);     }     for (int s = 0; s < n; s++) dist[s] = bfs(al, s);     for (int i = 0; i < n; i++)       if (!done[i]) {         vector<int> comp{i};         done[i] = 1;         bool outgo = 0;         for (int j = 0; j < n; j++)           if (dist[i][j] != INT_MAX && i != j) {             if (dist[j][i] != INT_MAX) {               comp.push_back(j);               done[j] = 1;             } else               outgo = 1;           }         if (!outgo && comp.size() > 1) {           int m = INT_MAX;           for (int c = 0; c < comp.size(); c++)             for (int d = 0; d < comp.size(); d++)               if (c != d)                 m = min(m, dist[comp[c]][comp[d]] + dist[comp[d]][comp[c]]);           r += 998 * m + 1;         }       }     cout << r <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3006;   struct arr {     int x, y, i;   } a[maxn];   int r, c, n, K;   int pos[maxn], L[maxn], R[maxn];   long long ans;   bool cmpx(arr x, arr y) {     if (x.x == y.x) return x.y < y.y;     return x.x < y.x;   }   bool cmpy(arr x, arr y) {     if (x.y == y.y) return x.x < y.x;     return x.y < y.y;   }   int main() {     scanf( %d%d%d%d , &r, &c, &n, &K);     for (int i = 1; i <= n; i++) scanf( %d%d , &a[i].x, &a[i].y);     sort(a + 1, a + n + 1, cmpy);     for (int i = 1; i <= n; i++) a[i].i = i;     sort(a + 1, a + n + 1, cmpx);     for (int i = 1; i <= n; i++) L[i] = i - 1;     for (int i = 1; i <= n; i++) R[i] = i + 1;     for (int i = 1; i <= n; i++) pos[a[i].i] = i;     R[0] = 1;     L[n + 1] = n;     pos[n + 1] = n + 1;     a[n + 1].x = r + 1;     a[n + 1].y = c + 1;     int nn = n;     for (int i = r; i >= 1; i--) {       int t = 0;       long long tmp = 0;       for (int j = 1; j <= n && a[j].x <= i; t = j++)         R[L[a[j].i]] = R[a[j].i], L[R[a[j].i]] = L[a[j].i];       for (int j = i, k = t; j >= 1; ans += tmp, j--) {         for (; a[k].x == j; k--) {           R[L[a[k].i]] = a[k].i;           L[R[a[k].i]] = a[k].i;           int val = 1, lp = a[k].i, rp = a[k].i;           for (; L[lp] && val < K; lp = L[lp], val++)             ;           for (; lp <= a[k].i; lp = R[lp], val--) {             for (; R[rp] <= n && val < K; rp = R[rp], val++)               ;             if (val < K) break;             long long tmp_1 = a[pos[lp]].y - a[pos[L[lp]]].y;             long long tmp_2 = a[pos[R[rp]]].y - a[pos[rp]].y;             tmp += tmp_1 * tmp_2;           }         }       }       while (a[nn].x == i) {         R[L[a[nn].i]] = R[a[nn].i];         L[R[a[nn].i]] = L[a[nn].i];         nn--;       }     }     printf( %lld n , ans);     return 0;   }
/*Allah Vorosha*/   #include<bits/stdc++.h>   #define ll long long   #define ld long double   #define pb push_back   #define in insert   #define rev reverse   #define all(x) (x).begin(),(x).end()   #define all2(x) (x).rbegin(),(x).rend()   #define sz(v) (int)v.size()   #define yes cout <<  YES n    #define no cout <<  NO n ;   #define take for(auto &it : a) cin >> it;   #define vi vector<int>   #define vii vector<pair<int, int > >   #define vl vector<ll>   #define fi first   #define se second   #define l_b lower_bound   #define u_b upper_bound   #define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();   #define tail cout <<   n       using namespace std;      template<class T> void read(T &x) { cin >> x; }   template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }   template<class T> void print1(const T &x) { cout << x <<   n ; }   template<class T, class ...U> void print1(const T &x, const U& ... u) { print1(x); print1(u...); }   template<class T> void print2(const T &x) { cout << x <<    ; }   template<class T, class ...U> void print2(const T &x, const U& ... u) { print2(x); print2(u...); }      int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};   //int n, m;      bool valid (int x, int y) {       //return (x >= 0 && x < n && y >= 0 && y < m);   }      bool vis[55][55];      const int N = 1005, mod = 1e9 + 7, M = 5e5 + 5;   const ll inf = 9e18;   int cs = 1;      void solve() {       ll n, c;       read(n, c);       vi a(n);       take;       vi b(n - 1);       for(auto &it : b)           cin >> it;       ll hi = c, low = 1, mid, ans;       while(hi >= low) {           mid = (hi + low) >> 1;           ll day = mid;           ll tk = 0;           bool ok = 0;           for(int i = 0; i < n; i++) {               if(tk + a[i] * day >= c) {                   ok = 1; break;               }               else {                   if(i == n - 1) {                       if(tk + a[i] * day >= c) {                           ok = 1;                           break;                       }                   }                   else {                       if(tk >= b[i]) {                           tk -= b[i];                           day--;                       }                       else {                           ll k = b[i] - tk;                           ll l = k / a[i] + (k % a[i] != 0);                           day -= l + 1;                           tk += l * a[i];                           tk -= b[i];                       }                   }               }               //if(mid == 6) print1(day);               if(day < 0) {                   break;               }           }           if(ok) {               ans = mid;               hi = mid - 1;           }           else {               low = mid + 1;           }       }       cout << ans <<   n ;   }      int main() {       ios;       int tc;       read(tc);       while(tc--)       solve();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1;   long long a[N];   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     priority_queue<pair<long long, int>, vector<pair<long long, int>>,                    greater<pair<long long, int>>>         q;     for (int i = 1; i <= n; ++i) {       int x;       cin >> x;       q.push({x, i});     }     long long ans(0);     while (!q.empty()) {       pair<long long, int> p = q.top();       q.pop();       if (q.top().first == p.first && !q.empty()) {         int x = q.top().second;         q.pop();         q.push({p.first * 2, x});       } else {         ans++;         a[p.second] = p.first;       }     }     cout << ans << endl;     for (int i = 1; i <= n; ++i)       if (a[i] != 0) cout << a[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int n, m, i, ans = 0, cish, h, sd = 0, c;     int q, j;     scanf( %d , &q);     int a[10][10] = {{0},                      {1, 2, 3, 4, 5, 6, 7, 8, 9, 0},                      {2, 4, 6, 8, 0},                      {3, 6, 9, 2, 5, 8, 1, 4, 7, 0},                      {4, 8, 2, 6, 0},                      {5, 0},                      {6, 2, 8, 4, 0},                      {7, 4, 1, 8, 5, 2, 9, 6, 3, 0},                      {8, 6, 4, 2, 0},                      {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}};     for (j = 0; j < q; j++) {       scanf( %lld%lld , &n, &m);       c = m % 10;       switch (c) {         case 1:         case 3:         case 7:         case 9:           cish = 10;           h = 45;           break;         case 2:         case 4:         case 6:         case 8:           cish = 5;           h = 20;           break;         case 5:           cish = 2;           h = 5;           break;         case 0:           cish = 1;           h = 0;           break;       }       int y;       for (y = 0; y < (n / m) % cish; y++) sd += a[c][y];       ans = (n / m) / cish * h + sd;       printf( %lld n , ans);       ans = 0;       sd = 0;     }     return 0;   }
#include <bits/stdc++.h>   const double pi = acos(-1.0);   const double eps = 1e-9;   using namespace std;   int k, n1, n2, n3, t1, t2, t3;   void solve() {     cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;     set<pair<long long, int>> st[3];     for (int i = 1; i <= 1000; i++) {       if (i <= n1) {         st[0].insert({0, i});       }       if (i <= n2) {         st[1].insert({0, i});       }       if (i <= n3) {         st[2].insert({0, i});       }     }     long long ans = 0;     while (k--) {       auto beg0 = *st[0].begin();       auto beg1 = *st[1].begin();       auto beg2 = *st[2].begin();       auto last0 = beg0, last1 = beg1, last2 = beg2;       st[0].erase(beg0);       st[1].erase(beg1);       st[2].erase(beg2);       beg0.first += t1;       beg1.first = max(beg1.first + t2, beg0.first + t2);       beg2.first = max(beg2.first + t3, beg1.first + t3);       ans = max(ans, beg2.first);       beg1.first = beg2.first - t3;       beg0.first = beg1.first - t2;       assert(last0.first <= beg0.first);       assert(last1.first <= beg1.first);       assert(last2.first <= beg2.first);       st[0].insert(beg0);       st[1].insert(beg1);       st[2].insert(beg2);     }     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);     cout.setf(ios::fixed), cout.precision(7);     int step = 1;     for (int i = 1; i <= step; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long ans = 0, f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       ans = ans * 10 + c -  0 ;       c = getchar();     }     return ans * f;   }   const long long N = 2e5 + 5;   long long t, n, m, k, x[N], y[N], ans, mmax[N];   signed main() {     t = read();     while (t--) {       n = read();       k = read();       for (long long i = 1; i <= n; ++i) x[i] = read();       for (long long i = 1; i <= n; ++i) y[i] = read();       sort(x + 1, x + 1 + n);       long long now = 0;       ans = 0;       for (long long i = 1; i <= n; ++i) {         long long len = upper_bound(x + 1, x + 1 + n, x[i] + k) - x - 1;         now = max(now, mmax[i]);         ans = max(ans, len - i + 1 + now);         mmax[len + 1] = max(mmax[len + 1], len - i + 1);       }       for (long long i = 1; i <= n + 1; ++i) mmax[i] = 0;       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[4] = {0, 0, -1, 1};   const int dy[4] = {-1, 1, 0, 0};   int i, j, x, y, n, m, e[26], b[510][510], l, ans, flag, xx, yy;   char c, s[100010];   int main() {     scanf( %d%d%d%d , &n, &m, &x, &y);     scanf(  %s , s);     l = strlen(s);     ans = 1;     printf( 1 );     e[ L  -  A ] = 0;     e[ R  -  A ] = 1;     e[ U  -  A ] = 2;     e[ D  -  A ] = 3;     memset(b, 0, sizeof(b));     b[x][y] = 1;     flag = 0;     for (i = 0; i < l; i++) {       xx = x + dx[e[s[i] -  A ]];       yy = y + dy[e[s[i] -  A ]];       if (flag || xx < 1 || xx > n || yy < 1 || yy > m) {         if (i == l - 1) {           printf(  %d n , n * m - ans);           continue;         }         printf(  0 );         continue;       }       x = xx;       y = yy;       if (b[xx][yy] == 1) {         if (i == l - 1) {           printf(  %d n , n * m - ans);           continue;         }         printf(  0 );         continue;       }       ans++;       b[x][y] = 1;       if (i == l - 1) {         printf(  %d n , n * m + 1 - ans);         continue;       }       printf(  1 );     }     puts(  );     return 0;   }
#include<iostream>   #include<cstdio>   #include<cstring>   #include<algorithm>   #include<vector>   using namespace std;   int n,m;   char s[200009],t[200009];   int f[200009],g[200009];   vector<int> p[30];   int main()   {    scanf( %d%d ,&n,&m);    scanf( %s%s ,s+1,t+1);    for(int i=1;i<=n;i++)     s[i]-= a -1;    for(int i=1;i<=m;i++)     t[i]-= a -1;    for(int i=1;i<=n;i++)     p[s[i]].push_back(i);    for(int i=1;i<=m;i++)     f[i]=*upper_bound(p[t[i]].begin(),p[t[i]].end(),f[i-1]);    g[m+1]=n+1;    for(int i=m;i>=1;i--)     g[i]=*(lower_bound(p[t[i]].begin(),p[t[i]].end(),g[i+1])-1);    int ans=0;    for(int i=1;i<=m-1;i++)     ans=max(ans,g[i+1]-f[i]);    printf( %d ,ans);    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long in, temp = 0, t = 0;     int casos;     cin >> casos;     for (int i = 0; i < casos; i++) {       cin >> in;       temp = in * (in + 1) / 2;       for (long long i = 0;; i++) {         if ((1 << i) > in) {           break;         } else {           long long j = 1 << i;           t = t + j;         }       }       temp = temp - 2 * t;       cout << temp << endl;       t = 0;       temp = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1000000007;   const int N = 105;   int n, m, k, nl, d[N][N], ok;   struct point {     int x, y;     point(){};     point(int x, int y) : x(x), y(y) {}   };   string a[N];   vector<point> l[N * N];   int s[N * N], p[N * N];   void input() {     cin >> n >> m >> k;     getline(cin, a[0]);     for (int i = 0; i < n; i++) {       getline(cin, a[i]);     }   }   int vx[] = {0, 1, 0, -1};   int vy[] = {-1, 0, 1, 0};   int check(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   void dfs(int x, int y) {     l[nl].push_back(point(x, y));     s[nl]++;     d[x][y] = 1;     for (int k = 0; k < 4; k++) {       int u = x + vx[k];       int v = y + vy[k];       if (!check(u, v)) {         ok = 0;         continue;       }       if (a[u][v] !=  .  || d[u][v]) continue;       dfs(u, v);     }   }   int cmp(int x, int y) { return s[x] < s[y]; }   void solve() {     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  .  && !d[i][j]) {           l[nl].clear();           s[nl] = 0;           p[nl] = nl;           ok = 1;           dfs(i, j);           if (ok) nl++;         }       }     }     sort(p, p + nl, cmp);     int ans = 0;     for (int i = 0; i < nl - k; i++) {       ans += s[p[i]];       for (int j = 0; j < l[p[i]].size(); j++) {         int u = l[p[i]][j].x;         int v = l[p[i]][j].y;         a[u][v] =  * ;       }     }     cout << ans << endl;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cout << a[i][j];       }       cout << endl;     }   }   int main() {     int test = 1;     while (test--) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fpm(long long b, long long e, long long m) {     long long t = 1;     for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;     return t;   }   template <class T>   inline bool chkmin(T &a, T b) {     return a > b ? a = b, true : false;   }   template <class T>   inline bool chkmax(T &a, T b) {     return a < b ? a = b, true : false;   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class edge>   struct Graph {     vector<vector<edge> > adj;     Graph(int n) {       adj.clear();       adj.resize(n + 5);     }     Graph() { adj.clear(); }     void resize(int n) { adj.resize(n + 5); }     void add(int s, edge e) { adj[s].push_back(e); }     void del(int s, edge e) {       adj[s].erase(find((adj[s]).begin(), (adj[s]).end(), e));     }     int deg(int v) { return adj[v].size(); }     vector<edge> &operator[](int t) { return adj[t]; }   };   struct crd {     long double x, y, z;     void read() { cin >> x >> y >> z; }     void out() { cerr <<  (  << x <<  ,   << y <<  ,   << z <<  ) ; }     crd operator^(crd &w) {       return (crd){y * w.z - w.y * z, z * w.x - w.z * x, x * w.y - y * w.x};     }     long double operator*(crd &w) { return x * w.x + y * w.y + z * w.z; }     crd operator+(crd &w) { return (crd){x + w.x, y + w.y, z + w.z}; }     crd operator-(crd &w) { return (crd){x - w.x, y - w.y, z - w.z}; }     crd operator*(long double &w) { return (crd){x * w, y * w, z * w}; }     long double len() { return sqrt(x * x + y * y + z * z); }   };   crd A, p, O, v;   long double R, r;   long double sphere(crd o, long double r) {     o = o - A;     crd plane = o ^ v;     crd vert = v ^ plane;     long double mindis = o * vert / vert.len();     if (mindis > R + r || o * v < 0) return 1e300;     o.out(), vert.out(), plane.out(), ({});     long double dist = o.len();     long double run =         sqrt(sqr(dist) - sqr(mindis)) - sqrt(sqr(R + r) - sqr(mindis));     return run / v.len();   }   int main() {     ios_base::sync_with_stdio(false);     long double ans = 1e300;     A.read(), v.read();     v.out(), cerr << endl;     int n, m;     cin >> R >> n;     for (int i = 1; i <= n; ++i) {       O.read();       cin >> r >> m;       ans = min(ans, sphere(O, r));       for (; m--;) p.read(), ans = min(ans, sphere(O + p, 0));     }     cout << setprecision(15) << (ans > 1e200 ? -1 : ans) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void ioe() {     freopen( in_3.txt ,  r , stdin);     freopen( out_3.txt ,  w , stdout);     freopen( er_3.txt ,  w , stderr);   }   struct lex_compare {    public:     bool operator()(const pair<long long, long long>& lhs,                     const pair<long long, long long>& rhs) const {       return (lhs.second > rhs.second);     }   };   long long pw(long long a, long long b, long long m) {     if (b == 0) return 1;     long long t = (pw(a, b / 2, m)) % m;     t = (t * t) % m;     if (b % 2 == 0) return t;     return (a * t) % m;   }   long long gc(long long a, long long b) {     if (b == 0) return a;     return gc(b, a % b);   }   vector<string> splt(string x, char w) {     vector<string> v;     string s;     int l = x.length();     for (long long i = 0; i < l; i++) {       if (x[i] == w) {         v.push_back(s);         s =   ;       } else {         s.push_back(x[i]);       }     }     v.push_back(s);     return v;   }   class node {    public:     long long id, a, l;     vector<node*> v;     vector<pair<node*, long long>> vm;     node* prt = NULL;     long long s = -1, x = 0, y = 0;     node(long long x = 0, long long y = 0) {       id = y, a = x, l = 0;       vm.clear(), v.clear();       prt = NULL;       s = -1, x = 0, y = 0;     }     void adn(node* t) { v.push_back(t), l++; }     void adn(node* t, long long x) { vm.push_back({t, x}), l++; }   };   node* nnd(long long a = 0, long long i = 1) {     node* t = new node(a, i);     return t;   }   void solve() {     long long n;     cin >> n;     char a[n][n];     for (long long i = 0; i < n; i++)       for (long long j = 0; j < n; j++) cin >> a[i][j];     long long t = 0;     for (long long i = 0; i < n; i++)       for (long long j = 0; j < n; j++) {         long long x = 0;         if (i > 0 && a[i - 1][j] ==  o ) x++;         if (j > 0 && a[i][j - 1] ==  o ) x++;         if ((i < n - 1) && a[i + 1][j] ==  o ) x++;         if ((j < n - 1) && a[i][j + 1] ==  o ) x++;         if (x % 2 == 1) t++;       }     if (t == 0)       cout <<  YES n ;     else       cout <<  NO n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t = 1;     long long f = t;     while (f--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 3.14159265359;   double ans, x, y;   int n, zeros, ones;   int main() {     scanf( %d , &n);     for (int i = 0; i < 2 * n; ++i) {       scanf( %lf , &y);       x -= y - int(y);       if (y == int(y))         ++zeros;       else         ++ones;     }     assert(zeros + ones == 2 * n);     int i = 0;     while (i < min(n, ones) && fabs(x) >= fabs(x + 1)) x += 1.0, ++i;     while (i < n && zeros) ++i, --zeros;     while (i < n) x += 1.0, ++i;     printf( %.3lf , fabs(x));     return 0;   }